2 eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}'
3 & eval 'exec perl -w -S $0 $argv:q'
6 # ******************************************************************
10 # Description: Generate an export header file for use with various compilers
11 # ******************************************************************
13 # ******************************************************************
15 # ******************************************************************
21 # ******************************************************************
23 # ******************************************************************
27 # ******************************************************************
29 # ******************************************************************
31 sub generate_export_header
{
32 my($name, $output) = @_;
33 my $fh = new FileHandle
();
36 if (open($fh, ">$output")) {
39 #ifndef ${name}_EXPORT_H
40 #define ${name}_EXPORT_H
42 #if !defined(${name}_HAS_DLL)
43 # if defined(${name}_AS_STATIC_LIBS)
44 # define ${name}_HAS_DLL 0
46 # define ${name}_HAS_DLL 1
50 #if (${name}_HAS_DLL == 1)
51 # if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550)
52 # if defined(${name}_BUILD_DLL)
53 # define ${name}_Export __symbolic
55 # define ${name}_Export __global
57 # elif defined(WIN32) || defined(UNDER_CE) || defined(__CYGWIN__)
58 # if defined(${name}_BUILD_DLL)
59 # define ${name}_Export __declspec(dllexport)
61 # define ${name}_Export __declspec(dllimport)
63 # elif (defined(__GNUC__) && (__GNUC__ >= 4))
64 # if defined(${name}_BUILD_DLL)
65 # define ${name}_Export __attribute__((visibility("default")))
67 # define ${name}_Export
70 # define ${name}_Export
73 # define ${name}_Export
80 print "Output written to $output\n";
83 print STDERR
"ERROR: Unable to write to $output\n";
93 print STDERR
"$str\n" if (defined $str);
94 print STDERR
"Generate Export Header v$version\n",
95 "Usage: ", basename
($0), " <library name> [output file]\n";
99 # ******************************************************************
101 # ******************************************************************
106 if (!defined $name) {
109 elsif (index($name, '-') == 0) {
113 if (!defined $output) {
114 $output = $name . '_' . ($name =~ /^[A-Z]/ ?
'E' : 'e') .
118 if ($name =~ s/^\d+//) {
119 print "WARNING: Removing beginning numbers from export name.\n";
121 if ($name =~ s/-\s/_/g) {
122 print "WARNING: Converting dashes and ",
123 "whitespace to underscores in export name.\n";
126 exit(generate_export_header
($name, $output));