Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / bin / generate_export_file.pl
blobb857b0674045251a0b15d94bd557614a076ac1a7
1 #!/usr/bin/env perl
2 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
3 & eval 'exec perl -S $0 $argv:q'
4 if 0;
6 # -*- perl -*-
7 # Replacement for the old trusty GenExportH.bat
8 # Creates the nice little *_export file which is used for
9 # importing and exporting of symbols in DLLs.
10 # (they are soooo cute!)
12 use Getopt::Std;
14 ##############################################################################
15 # Grab the options
17 $flags = join (" ", @ARGV);
19 if (!getopts ('df:hsn') || $opt_h) {
20 print STDERR
21 "generate_export_file.pl [-d] [-f dependency] [-n] library_name\n",
22 "\n",
23 " -d Turn on debug mode\n",
24 " -f Adds a dependency to another *_HAS_DLL macro\n",
25 " -n Do not add in ACE_AS_STATIC_LIBS check\n",
26 "\n",
27 "generate_export_file creates the *_export files that are used\n",
28 "in exporting of symbols for DLLs (and not exporting them when\n",
29 "the library is static). If library_name is something like\n",
30 "\"Foo\", then the file will contain definitions for Foo_Export\n",
31 "and FOO_SINGLETON_DECLARE, etc. which will be controlled by\n",
32 "FOO_HAS_DLL, etc.\n";
33 exit (1);
36 if (defined $opt_d) {
37 print STDERR "Debugging Turned on\n";
39 if (defined $opt_f) {
40 print STDERR "Dependency to $opt_f\n";
43 if (defined $opt_n) {
44 print STDERR "ACE_AS_STATIC_LIBS turned off\n";
49 if ($#ARGV < 0) {
50 print STDERR "No library_name specified, use -h for help\n";
51 exit (1);
54 $name = shift @ARGV;
55 $ucname = uc $name;
57 ##############################################################################
58 # Prologue
60 $prologue = '
61 // -*- C++ -*-
62 // Definition for Win32 Export directives.
63 // This file is generated automatically by generate_export_file.pl '."$flags".'
64 // ------------------------------'."
65 #ifndef -UC-_EXPORT_H
66 #define -UC-_EXPORT_H
68 #include \"ace/config-all.h\"
72 ##############################################################################
73 # Static Stuff
75 if (!defined $opt_n)
77 $static_stuff = "
78 #if defined (ACE_AS_STATIC_LIBS) && !defined (-UC-_HAS_DLL)
79 # define -UC-_HAS_DLL 0
80 #endif /* ACE_AS_STATIC_LIBS && -UC-_HAS_DLL */
84 ##############################################################################
85 # Dependencies
87 if (defined $opt_f)
89 $has_dll = "
90 #if defined ($opt_f)
91 # if !defined (-UC-_HAS_DLL)
92 # define -UC-_HAS_DLL 0
93 # endif /* ! -UC-_HAS_DLL */
94 #else
95 # if !defined (-UC-_HAS_DLL)
96 # define -UC-_HAS_DLL 1
97 # endif /* ! -UC-_HAS_DLL */
98 #endif
101 else
103 $has_dll = "
104 #if !defined (-UC-_HAS_DLL)
105 # define -UC-_HAS_DLL 1
106 #endif /* ! -UC-_HAS_DLL */
110 ##############################################################################
111 # Epilogue
113 $epilogue = "
114 #if defined (-UC-_HAS_DLL) && (-UC-_HAS_DLL == 1)
115 # if defined (-UC-_BUILD_DLL)
116 # define -NC-_Export ACE_Proper_Export_Flag
117 # define -UC-_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
118 # define -UC-_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
119 # else /* -UC-_BUILD_DLL */
120 # define -NC-_Export ACE_Proper_Import_Flag
121 # define -UC-_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
122 # define -UC-_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
123 # endif /* -UC-_BUILD_DLL */
124 #else /* -UC-_HAS_DLL == 1 */
125 # define -NC-_Export
126 # define -UC-_SINGLETON_DECLARATION(T)
127 # define -UC-_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
128 #endif /* -UC-_HAS_DLL == 1 */
130 // Set -UC-_NTRACE = 0 to turn on library specific tracing even if
131 // tracing is turned off for ACE.
132 #if !defined (-UC-_NTRACE)
133 # if (ACE_NTRACE == 1)
134 # define -UC-_NTRACE 1
135 # else /* (ACE_NTRACE == 1) */
136 # define -UC-_NTRACE 0
137 # endif /* (ACE_NTRACE == 1) */
138 #endif /* !-UC-_NTRACE */
140 #if (-UC-_NTRACE == 1)
141 # define -UC-_TRACE(X)
142 #else /* (-UC-_NTRACE == 1) */
143 # if !defined (ACE_HAS_TRACE)
144 # define ACE_HAS_TRACE
145 # endif /* ACE_HAS_TRACE */
146 # define -UC-_TRACE(X) ACE_TRACE_IMPL(X)
147 # include \"ace/Trace.h\"
148 #endif /* (-UC-_NTRACE == 1) */
150 #endif /* -UC-_EXPORT_H */
152 // End of auto generated file.
155 ##############################################################################
156 # Print the stuff out
158 foreach $export ($prologue, $static_stuff, $has_dll, $epilogue)
160 ## -NC- stands for normal case, the name as it is
161 ## -UC- stands for the name all upper case
162 map { s/-NC-/$name/g; s/-UC-/$ucname/g; } $export;
164 print $export;