summaryrefslogtreecommitdiff
path: root/bin/generate_export_file.pl
blob: 7349f816e4c20e8d3a9d2525986f729e955c7517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

# $Id$
# Replacement for the old trusty GenExportH.bat
# Creates the nice little *_export file which is used for
# importing and exporting of symbols in DLLs.
# (they are soooo cute!)

use Getopt::Std;

##############################################################################
# Grab the options

$flags = join (" ", @ARGV);

if (!getopts ('df:hsn') || $opt_h) {
    print STDERR
          "generate_export_file.pl [-d] [-f dependency] [-n] library_name\n",
          "\n",
          "    -d         Turn on debug mode\n",
          "    -f         Adds a dependency to another *_HAS_DLL macro\n",
          "    -n         Do not add in ACE_AS_STATIC_LIBS check\n",
          "\n",
          "generate_export_file creates the *_export files that are used\n",
          "in exporting of symbols for DLLs (and not exporting them when\n",
          "the library is static).  If library_name is something like\n",
          "\"Foo\", then the file will contain definitions for Foo_Export\n",
          "and FOO_SINGLETON_DECLARE, etc. which will be controlled by\n",
          "FOO_HAS_DLL, etc.\n";
    exit (1);
}

if (defined $opt_d) {
    print STDERR "Debugging Turned on\n";

    if (defined $opt_f) {
        print STDERR "Dependency to $opt_f\n";
    }

    if (defined $opt_n) {
        print STDERR "ACE_AS_STATIC_LIBS turned off\n";
    }
}


if ($#ARGV < 0) {
    print STDERR "No library_name specified, use -h for help\n";
    exit (1);
}

$name = shift @ARGV;
$ucname = uc $name;

##############################################################################
# Prologue

$prologue = '
// -*- C++ -*-
// ' . '$' . 'Id' . '$
// Definition for Win32 Export directives.
// This file is generated automatically by generate_export_file.pl '."$flags".'
// ------------------------------'."
#ifndef -UC-_EXPORT_H
#define -UC-_EXPORT_H

#include \"ace/config-all.h\"
";


##############################################################################
# Static Stuff

if (!defined $opt_n)
{
    $static_stuff = "
#if defined (ACE_AS_STATIC_LIBS) && !defined (-UC-_HAS_DLL)
#  define -UC-_HAS_DLL 0
#endif /* ACE_AS_STATIC_LIBS && -UC-_HAS_DLL */
";
}

##############################################################################
# Dependencies

if (defined $opt_f)
{
    $has_dll = "
#if defined ($opt_f)
#  if !defined (-UC-_HAS_DLL)
#    define -UC-_HAS_DLL 0
#  endif /* ! -UC-_HAS_DLL */
#else
#  if !defined (-UC-_HAS_DLL)
#    define -UC-_HAS_DLL 1
#  endif /* ! -UC-_HAS_DLL */
#endif
";
}
else
{
    $has_dll = "
#if !defined (-UC-_HAS_DLL)
#  define -UC-_HAS_DLL 1
#endif /* ! -UC-_HAS_DLL */
";
}

##############################################################################
# Epilogue

$epilogue = "
#if defined (-UC-_HAS_DLL) && (-UC-_HAS_DLL == 1)
#  if defined (-UC-_BUILD_DLL)
#    define -NC-_Export ACE_Proper_Export_Flag
#    define -UC-_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
#    define -UC-_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
#  else /* -UC-_BUILD_DLL */
#    define -NC-_Export ACE_Proper_Import_Flag
#    define -UC-_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
#    define -UC-_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
#  endif /* -UC-_BUILD_DLL */
#else /* -UC-_HAS_DLL == 1 */
#  define -NC-_Export
#  define -UC-_SINGLETON_DECLARATION(T)
#  define -UC-_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
#endif /* -UC-_HAS_DLL == 1 */

// Set -UC-_NTRACE = 0 to turn on library specific tracing even if
// tracing is turned off for ACE.
#if !defined (-UC-_NTRACE)
#  if (ACE_NTRACE == 1)
#    define -UC-_NTRACE 1
#  else /* (ACE_NTRACE == 1) */
#    define -UC-_NTRACE 0
#  endif /* (ACE_NTRACE == 1) */
#endif /* !-UC-_NTRACE */

#if (-UC-_NTRACE == 1)
#  define -UC-_TRACE(X)
#else /* (-UC-_NTRACE == 1) */
#  if !defined (ACE_HAS_TRACE)
#    define ACE_HAS_TRACE
#  endif /* ACE_HAS_TRACE */
#  define -UC-_TRACE(X) ACE_TRACE_IMPL(X)
#  include \"ace/Trace.h\"
#endif /* (-UC-_NTRACE == 1) */

#endif /* -UC-_EXPORT_H */

// End of auto generated file.
";

##############################################################################
# Print the stuff out

foreach $export ($prologue, $static_stuff, $has_dll, $epilogue)
{
## -NC- stands for normal case, the name as it is
## -UC- stands for the name all upper case
    map { s/-NC-/$name/g; s/-UC-/$ucname/g; } $export;

    print $export;
};