2 eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}'
3 & eval 'exec perl -w -S $0 $argv:q'
6 # ******************************************************************
9 # Description: Generate an export header file for use with various compilers
10 # ******************************************************************
12 # ******************************************************************
14 # ******************************************************************
20 # ******************************************************************
22 # ******************************************************************
26 # ******************************************************************
28 # ******************************************************************
30 sub generate_export_header
{
31 my($name, $output) = @_;
32 my $fh = new FileHandle
();
35 if (open($fh, ">$output")) {
38 #ifndef ${name}_EXPORT_H
39 #define ${name}_EXPORT_H
41 #if !defined(${name}_HAS_DLL)
42 # if defined(${name}_AS_STATIC_LIBS)
43 # define ${name}_HAS_DLL 0
45 # define ${name}_HAS_DLL 1
49 #if (${name}_HAS_DLL == 1)
50 # if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550)
51 # if defined(${name}_BUILD_DLL)
52 # define ${name}_Export __symbolic
54 # define ${name}_Export __global
56 # elif defined(WIN32) || defined(UNDER_CE) || defined(__CYGWIN__)
57 # if defined(${name}_BUILD_DLL)
58 # define ${name}_Export __declspec(dllexport)
60 # define ${name}_Export __declspec(dllimport)
62 # elif (defined(__GNUC__) && (__GNUC__ >= 4))
63 # if defined(${name}_BUILD_DLL)
64 # define ${name}_Export __attribute__((visibility("default")))
66 # define ${name}_Export
69 # define ${name}_Export
72 # define ${name}_Export
79 print "Output written to $output\n";
82 print STDERR
"ERROR: Unable to write to $output\n";
92 print STDERR
"$str\n" if (defined $str);
93 print STDERR
"Generate Export Header v$version\n",
94 "Usage: ", basename
($0), " <library name> [output file]\n";
98 # ******************************************************************
100 # ******************************************************************
105 if (!defined $name) {
108 elsif (index($name, '-') == 0) {
112 if (!defined $output) {
113 $output = $name . '_' . ($name =~ /^[A-Z]/ ?
'E' : 'e') .
117 if ($name =~ s/^\d+//) {
118 print "WARNING: Removing beginning numbers from export name.\n";
120 if ($name =~ s/-\s/_/g) {
121 print "WARNING: Converting dashes and ",
122 "whitespace to underscores in export name.\n";
125 exit(generate_export_header
($name, $output));