Commit b1e0209829d6def7b337700204e2adb75fb9282a

Alexei Podtelezhnikov 2018-01-23T22:29:45

[apinames] Anonymous version map for GNU linker. * src/tools/apinames.c (PROGRAM_VERSION): Set to 0.3. (OutputFormat): Add `OUTPUT_GNU_VERMAP'. (names_dump): Handle it. (usage): Updated. (main): Handle new command line flag `-wL'.

diff --git a/ChangeLog b/ChangeLog
index 8b3b75c..20f1951 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2018-01-23  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+	[apinames] Anonymous version map for GNU linker.
+
+	* src/tools/apinames.c (PROGRAM_VERSION): Set to 0.3.
+	(OutputFormat): Add `OUTPUT_GNU_VERMAP'.
+	(names_dump): Handle it.
+	(usage): Updated.
+	(main): Handle new command line flag `-wL'.
+
 2018-01-21  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
 	[unix] Call libtool to clean up.
diff --git a/src/tools/apinames.c b/src/tools/apinames.c
index 73bc99d..06c3260 100644
--- a/src/tools/apinames.c
+++ b/src/tools/apinames.c
@@ -22,7 +22,7 @@
 #include <ctype.h>
 
 #define  PROGRAM_NAME     "apinames"
-#define  PROGRAM_VERSION  "0.2"
+#define  PROGRAM_VERSION  "0.3"
 
 #define  LINEBUFF_SIZE  1024
 
@@ -32,7 +32,8 @@ typedef enum  OutputFormat_
   OUTPUT_WINDOWS_DEF,   /* output a Windows .DEF file for Visual C++ or Mingw */
   OUTPUT_BORLAND_DEF,   /* output a Windows .DEF file for Borland C++         */
   OUTPUT_WATCOM_LBC,    /* output a Watcom Linker Command File                */
-  OUTPUT_NETWARE_IMP    /* output a NetWare ImportFile                        */
+  OUTPUT_NETWARE_IMP,   /* output a NetWare ImportFile                        */
+  OUTPUT_GNU_VERMAP     /* output a version map for GNU or Solaris linker     */
 
 } OutputFormat;
 
@@ -198,6 +199,15 @@ names_dump( FILE*         out,
       }
       break;
 
+    case OUTPUT_GNU_VERMAP:
+      {
+        fprintf( out, "{\n\tglobal:\n" );
+        for ( nn = 0; nn < num_names; nn++ )
+          fprintf( out, "\t\t%s;\n", the_names[nn].name );
+        fprintf( out, "\tlocal:\n\t\t*;\n};\n" );
+      }
+      break;
+
     default:  /* LIST */
       for ( nn = 0; nn < num_names; nn++ )
         fprintf( out, "%s\n", the_names[nn].name );
@@ -323,6 +333,7 @@ usage( void )
    "           -wB    : output .DEF file for Borland C++\n"
    "           -wW    : output Watcom Linker Response File\n"
    "           -wN    : output NetWare Import File\n"
+   "           -wL    : output version map for GNU or Solaris linker\n"
    "\n";
 
   fprintf( stderr,
@@ -410,6 +421,10 @@ int  main( int argc, const char* const*  argv )
             format = OUTPUT_NETWARE_IMP;
             break;
 
+          case 'L':
+            format = OUTPUT_GNU_VERMAP;
+            break;
+
           case 0:
             break;