]>
Commit | Line | Data |
---|---|---|
e84193e4 RL |
1 | ## descrip.mms to build OpenSSL on OpenVMS |
2 | ## | |
3 | ## {- join("\n## ", @autowarntext) -} | |
4 | {- | |
5 | use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; | |
bbb9413b | 6 | use File::Basename; |
e84193e4 | 7 | |
c162a8c3 | 8 | (our $osslprefix_q = platform->osslprefix()) =~ s/\$/\\\$/; |
e84193e4 | 9 | |
c162a8c3 | 10 | our $sover_dirname = platform->shlib_version_as_filename(); |
e8fb1295 RL |
11 | our $osslver = sprintf "%02d%02d", split(/\./, $config{version}); |
12 | ||
e84193e4 RL |
13 | our $sourcedir = $config{sourcedir}; |
14 | our $builddir = $config{builddir}; | |
15 | sub sourcefile { | |
16 | catfile($sourcedir, @_); | |
17 | } | |
18 | sub buildfile { | |
19 | catfile($builddir, @_); | |
20 | } | |
21 | sub sourcedir { | |
22 | catdir($sourcedir, @_); | |
23 | } | |
24 | sub builddir { | |
25 | catdir($builddir, @_); | |
26 | } | |
27 | sub tree { | |
28 | (my $x = shift) =~ s|\]$|...]|; | |
29 | $x | |
30 | } | |
31 | sub move { | |
32 | my $f = catdir(@_); | |
33 | my $b = abs2rel(rel2abs("."),rel2abs($f)); | |
34 | $sourcedir = catdir($b,$sourcedir) | |
35 | if !file_name_is_absolute($sourcedir); | |
36 | $builddir = catdir($b,$builddir) | |
37 | if !file_name_is_absolute($builddir); | |
38 | ""; | |
39 | } | |
40 | ||
4813ad2d RL |
41 | # Because we need to make two computations of these data, |
42 | # we store them in arrays for reuse | |
33105818 | 43 | our @libs = |
c162a8c3 | 44 | map { platform->staticname($_) } |
33105818 RL |
45 | @{$unified_info{libraries}}; |
46 | our @shlibs = | |
c162a8c3 RL |
47 | map { platform->sharedname($_) // () } |
48 | @{$unified_info{libraries}}; | |
33105818 | 49 | our @install_libs = |
c162a8c3 | 50 | map { platform->staticname($_) } |
ac6bba6f RL |
51 | grep { !$unified_info{attributes}->{$_}->{noinst} } |
52 | @{$unified_info{libraries}}; | |
33105818 | 53 | our @install_shlibs = |
c162a8c3 | 54 | map { platform->sharedname($_) // () } |
ac6bba6f RL |
55 | grep { !$unified_info{attributes}->{$_}->{noinst} } |
56 | @{$unified_info{libraries}}; | |
57 | our @install_engines = | |
1842f369 RL |
58 | grep { !$unified_info{attributes}->{$_}->{noinst} |
59 | && $unified_info{attributes}->{$_}->{engine} } | |
60 | @{$unified_info{modules}}; | |
ac6bba6f RL |
61 | our @install_programs = |
62 | grep { !$unified_info{attributes}->{$_}->{noinst} } | |
63 | @{$unified_info{programs}}; | |
994e86a9 RL |
64 | our @install_bin_scripts = |
65 | grep { !$unified_info{attributes}->{$_}->{noinst} | |
66 | && !$unified_info{attributes}->{$_}->{misc} } | |
67 | @{$unified_info{scripts}}; | |
68 | our @install_misc_scripts = | |
69 | grep { !$unified_info{attributes}->{$_}->{noinst} | |
70 | && $unified_info{attributes}->{$_}->{misc} } | |
71 | @{$unified_info{scripts}}; | |
4813ad2d | 72 | |
e84193e4 RL |
73 | # This is a horrible hack, but is needed because recursive inclusion of files |
74 | # in different directories does not work well with HP C. | |
75 | my $sd = sourcedir("crypto", "async", "arch"); | |
76 | foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) { | |
c162a8c3 RL |
77 | my $obj = platform->obj($_); |
78 | $unified_info{before}->{$obj} | |
4813ad2d RL |
79 | = qq(arch_include = F\$PARSE("$sd","A.;",,,"SYNTAX_ONLY") - "A.;" |
80 | define arch 'arch_include'); | |
c162a8c3 | 81 | $unified_info{after}->{$obj} |
e84193e4 RL |
82 | = qq(deassign arch); |
83 | } | |
84 | my $sd1 = sourcedir("ssl","record"); | |
85 | my $sd2 = sourcedir("ssl","statem"); | |
5a5b85d1 RL |
86 | my @ssl_locl_users = grep(/^\[\.(?:ssl\.(?:record|statem)|test)\].*\.o$/, |
87 | keys %{$unified_info{sources}}); | |
5c3dbd2e | 88 | foreach (@ssl_locl_users) { |
c162a8c3 RL |
89 | my $obj = platform->obj($_); |
90 | $unified_info{before}->{$obj} | |
4813ad2d RL |
91 | = qq(record_include = F\$PARSE("$sd1","A.;",,,"SYNTAX_ONLY") - "A.;" |
92 | define record 'record_include' | |
93 | statem_include = F\$PARSE("$sd2","A.;",,,"SYNTAX_ONLY") - "A.;" | |
94 | define statem 'statem_include'); | |
c162a8c3 | 95 | $unified_info{after}->{$obj} |
e84193e4 RL |
96 | = qq(deassign statem |
97 | deassign record); | |
98 | } | |
75726420 RL |
99 | # This makes sure things get built in the order they need |
100 | # to. You're welcome. | |
101 | sub dependmagic { | |
102 | my $target = shift; | |
103 | ||
984cf15e | 104 | return "$target : build_generated\n\t\pipe \$(MMS) \$(MMSQUALIFIERS) depend && \$(MMS) \$(MMSQUALIFIERS) _$target\n_$target"; |
75726420 | 105 | } |
e84193e4 RL |
106 | ""; |
107 | -} | |
108 | PLATFORM={- $config{target} -} | |
109 | OPTIONS={- $config{options} -} | |
110 | CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -}) | |
111 | SRCDIR={- $config{sourcedir} -} | |
b867c707 | 112 | BLDDIR={- $config{builddir} -} |
e84193e4 | 113 | |
e8173157 RL |
114 | # Allow both V and VERBOSE to indicate verbosity. This only applies |
115 | # to testing. | |
116 | VERBOSE=$(V) | |
117 | ||
16942e08 | 118 | VERSION={- "$config{full_version}" -} |
e84193e4 RL |
119 | MAJOR={- $config{major} -} |
120 | MINOR={- $config{minor} -} | |
3a63dbef | 121 | SHLIB_VERSION_NUMBER={- $config{shlib_version} -} |
e84193e4 RL |
122 | SHLIB_TARGET={- $target{shared_target} -} |
123 | ||
33105818 | 124 | LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @libs) -} |
4813ad2d | 125 | SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -} |
1842f369 | 126 | MODULES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{modules}}) -} |
1e3d16b0 | 127 | PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -} |
e84193e4 | 128 | SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -} |
952a9d1a | 129 | {- output_off() if $disabled{makedepend}; "" -} |
c162a8c3 | 130 | DEPS={- our @deps = map { platform->isobj($_) ? platform->dep($_) : $_ } |
c058fcd7 RL |
131 | grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } |
132 | keys %{$unified_info{sources}}; | |
133 | join(", ", map { "-\n\t".$_ } @deps); -} | |
952a9d1a | 134 | {- output_on() if $disabled{makedepend}; "" -} |
4813ad2d | 135 | GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -} |
8258975c | 136 | GENERATED={- # common0.tmpl provides @generated |
c162a8c3 | 137 | join(", ", map { platform->convertext($_) } @generated) -} |
7cae3864 | 138 | |
33105818 | 139 | INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -} |
0f01b7bc | 140 | INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -} |
ac6bba6f RL |
141 | INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @install_engines) -} |
142 | INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @install_programs) -} | |
994e86a9 RL |
143 | BIN_SCRIPTS={- join(", ", @install_bin_scripts) -} |
144 | MISC_SCRIPTS={- join(", ", @install_misc_scripts) -} | |
e84193e4 | 145 | |
6a74806e RL |
146 | APPS_OPENSSL={- use File::Spec::Functions; |
147 | catfile("apps","openssl") -} | |
148 | ||
3c65577f | 149 | # DESTDIR is for package builders so that they can configure for, say, |
e84193e4 RL |
150 | # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER]. |
151 | # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run | |
3c65577f RL |
152 | # MMS with /MACROS=(DESTDIR=STAGING:[USER]). The result will end up in |
153 | # STAGING:[USER.OPENSSL]. | |
e84193e4 | 154 | # Normally it is left empty. |
3c65577f | 155 | DESTDIR= |
e84193e4 RL |
156 | |
157 | # Do not edit this manually. Use Configure --prefix=DIR to change this! | |
e8fb1295 RL |
158 | INSTALLTOP={- our $installtop = |
159 | catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]"; | |
40ea24b0 RL |
160 | $installtop -} |
161 | SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -} | |
e84193e4 | 162 | # This is the standard central area to store certificates, private keys... |
661a3963 | 163 | OPENSSLDIR={- catdir($config{openssldir}) or |
667c6bfe RL |
164 | $config{prefix} ? catdir($config{prefix},"COMMON") |
165 | : "SYS\$COMMON:[OPENSSL-COMMON]" -} | |
afea0067 | 166 | # The same, but for C |
c162a8c3 | 167 | OPENSSLDIR_C={- platform->osslprefix() -}DATAROOT:[000000] |
1842f369 | 168 | # Where installed ENGINE modules reside, for C |
c162a8c3 | 169 | ENGINESDIR_C={- platform->osslprefix() -}ENGINES{- $sover_dirname.$target{pointer_size} -}: |
3f4e8d66 RL |
170 | # Where modules reside, for C |
171 | MODULESDIR_C={- platform->osslprefix() -}MODULES{- $sover_dirname.$target{pointer_size} -}: | |
e84193e4 | 172 | |
abe256e7 RL |
173 | ##### User defined commands and flags ################################ |
174 | ||
175 | CC={- $config{CC} -} | |
176 | CPP={- $config{CPP} -} | |
177 | DEFINES={- our $defines1 = join('', map { ",$_" } @{$config{CPPDEFINES}}) -} | |
5de20b26 | 178 | INCLUDES={- our $includes1 = join(',', @{$config{CPPINCLUDES}}) -} |
abe256e7 RL |
179 | CPPFLAGS={- our $cppflags1 = join('', @{$config{CPPFLAGS}}) -} |
180 | CFLAGS={- join('', @{$config{CFLAGS}}) -} | |
181 | LDFLAGS={- join('', @{$config{LFLAGS}}) -} | |
182 | EX_LIBS={- join('', map { ",$_" } @{$config{LDLIBS}}) -} | |
e84193e4 | 183 | |
9e265322 | 184 | PERL={- $config{PERL} -} |
e84193e4 | 185 | |
abe256e7 RL |
186 | AS={- $config{AS} -} |
187 | ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -} | |
188 | ||
189 | ##### Special command flags ########################################## | |
190 | ||
ab7134ef | 191 | ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY) |
abe256e7 RL |
192 | |
193 | ##### Project flags ################################################## | |
194 | ||
195 | # Variables starting with CNF_ are common variables for all product types | |
196 | ||
197 | CNF_ASFLAGS={- join('', $target{asflags} || (), | |
198 | @{$config{asflags}}) -} | |
9c5f2ea6 RL |
199 | CNF_DEFINES={- our $defines2 = join('', (map { ",$_" } @{$target{defines}}, |
200 | @{$config{defines}}), | |
201 | "'extradefines'") -} | |
abe256e7 RL |
202 | CNF_INCLUDES={- our $includes2 = join(',', @{$target{includes}}, |
203 | @{$config{includes}}) -} | |
204 | CNF_CPPFLAGS={- our $cppflags2 = join('', $target{cppflags} || (), | |
205 | @{$config{cppflags}}) -} | |
206 | CNF_CFLAGS={- join('', $target{cflags} || (), | |
207 | @{$config{cflags}}) -} | |
208 | CNF_CXXFLAGS={- join('', $target{cxxflags} || (), | |
209 | @{$config{cxxflags}}) -} | |
210 | CNF_LDFLAGS={- join('', $target{lflags} || (), | |
211 | @{$config{lflags}}) -} | |
212 | CNF_EX_LIBS={- join('', map{ ",$_" } @{$target{ex_libs}}, | |
213 | @{$config{ex_libs}}) -} | |
214 | ||
215 | # Variables starting with LIB_ are used to build library object files | |
216 | # and shared libraries. | |
217 | # Variables starting with DSO_ are used to build DSOs and their object files. | |
218 | # Variables starting with BIN_ are used to build programs and their object | |
219 | # files. | |
220 | ||
221 | LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (), | |
222 | @{$config{lib_asflags}}, | |
223 | '$(CNF_ASFLAGS)', '$(ASFLAGS)') -} | |
58d6be5b RL |
224 | LIB_DEFINES={- our $lib_defines = |
225 | join('', (map { ",$_" } @{$target{lib_defines}}, | |
abe256e7 RL |
226 | @{$target{shared_defines}}, |
227 | @{$config{lib_defines}}, | |
5de20b26 | 228 | @{$config{shared_defines}})); |
58d6be5b RL |
229 | join('', $lib_defines, |
230 | (map { ",$_" } 'OPENSSLDIR="""$(OPENSSLDIR_C)"""', | |
3f4e8d66 RL |
231 | 'ENGINESDIR="""$(ENGINESDIR_C)"""', |
232 | 'MODULESDIR="""$(MODULESDIR_C)"""'), | |
abe256e7 | 233 | '$(CNF_DEFINES)', '$(DEFINES)') -} |
58d6be5b RL |
234 | LIB_INCLUDES={- our $lib_includes = |
235 | join(',', @{$target{lib_includes}}, | |
abe256e7 RL |
236 | @{$target{shared_includes}}, |
237 | @{$config{lib_includes}}, | |
238 | @{$config{shared_includes}}) -} | |
58d6be5b RL |
239 | LIB_CPPFLAGS={- our $lib_cppflags = |
240 | join('', $target{lib_cppflags} || (), | |
abe256e7 RL |
241 | $target{shared_cppflags} || (), |
242 | @{$config{lib_cppflags}}, | |
58d6be5b RL |
243 | @{$config{shared_cppflag}}); |
244 | join('', "'qual_includes'", | |
5de20b26 | 245 | '/DEFINE=(__dummy$(LIB_DEFINES))', |
58d6be5b | 246 | $lib_cppflags, |
abe256e7 RL |
247 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} |
248 | LIB_CFLAGS={- join('', $target{lib_cflags} || (), | |
249 | $target{shared_cflag} || (), | |
250 | @{$config{lib_cflags}}, | |
251 | @{$config{shared_cflag}}, | |
252 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} | |
253 | LIB_LDFLAGS={- join('', $target{lib_lflags} || (), | |
254 | $target{shared_ldflag} || (), | |
255 | @{$config{lib_lflags}}, | |
256 | @{$config{shared_ldflag}}, | |
257 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} | |
258 | LIB_EX_LIBS=$(CNF_EX_LIBS)$(EX_LIBS) | |
259 | DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (), | |
260 | $target{module_asflags} || (), | |
261 | @{$config{dso_asflags}}, | |
262 | @{$config{module_asflags}}, | |
263 | '$(CNF_ASFLAGS)', '$(ASFLAGS)') -} | |
264 | DSO_DEFINES={- join('', (map { ",$_" } @{$target{dso_defines}}, | |
265 | @{$target{module_defines}}, | |
266 | @{$config{dso_defines}}, | |
267 | @{$config{module_defines}}), | |
268 | '$(CNF_DEFINES)', '$(DEFINES)') -} | |
269 | DSO_INCLUDES={- join(',', @{$target{dso_includes}}, | |
270 | @{$target{module_includes}}, | |
271 | @{$config{dso_includes}}, | |
272 | @{$config{module_includes}}) -} | |
273 | DSO_CPPFLAGS={- join('', "'qual_includes'", | |
274 | '/DEFINE=(__dummy$(DSO_DEFINES))', | |
275 | $target{dso_cppflags} || (), | |
276 | $target{module_cppflags} || (), | |
277 | @{$config{dso_cppflags}}, | |
278 | @{$config{module_cppflags}}, | |
279 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} | |
280 | DSO_CFLAGS={- join('', $target{dso_cflags} || (), | |
281 | $target{module_cflags} || (), | |
282 | @{$config{dso_cflags}}, | |
283 | @{$config{module_cflags}}, | |
284 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} | |
285 | DSO_LDFLAGS={- join('', $target{dso_lflags} || (), | |
286 | $target{module_ldflags} || (), | |
287 | @{$config{dso_lflags}}, | |
288 | @{$config{module_ldflags}}, | |
289 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} | |
290 | DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) | |
291 | BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (), | |
292 | @{$config{bin_asflags}}, | |
293 | '$(CNF_ASFLAGS)', '$(ASFLAGS)') -} | |
294 | BIN_DEFINES={- join('', (map { ",$_" } @{$target{bin_defines}}, | |
295 | @{$config{bin_defines}}), | |
296 | '$(CNF_DEFINES)', '$(DEFINES)') -} | |
297 | BIN_INCLUDES={- join(',', @{$target{bin_includes}}, | |
298 | @{$config{bin_includes}}) -} | |
299 | BIN_CPPFLAGS={- join('', "'qual_includes'", | |
300 | '/DEFINE=(__dummy$(DSO_DEFINES))', | |
301 | $target{bin_cppflags} || (), | |
302 | @{$config{bin_cppflag}}, | |
303 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} | |
c40af30e RL |
304 | BIN_CFLAGS={- join('', $target{bin_cflags} || (), |
305 | @{$config{bin_cflags}}, | |
abe256e7 RL |
306 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
307 | BIN_LDFLAGS={- join('', $target{bin_lflags} || (), | |
308 | @{$config{bin_lflags}} || (), | |
309 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} | |
310 | BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) | |
311 | NO_INST_LIB_CFLAGS={- join('', $target{no_inst_lib_cflags} | |
312 | // $target{lib_cflags} | |
313 | // (), | |
314 | $target{shared_cflag} || (), | |
315 | @{$config{lib_cflags}}, | |
316 | @{$config{shared_cflag}}, | |
317 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} | |
c40af30e RL |
318 | NO_INST_DSO_CFLAGS={- join('', $target{no_inst_dso_cflags} |
319 | // $target{dso_cflags} | |
320 | // (), | |
321 | $target{no_inst_module_cflags} | |
322 | // $target{module_cflags} | |
abe256e7 | 323 | // (), |
abe256e7 | 324 | @{$config{dso_cflags}}, |
c40af30e | 325 | @{$config{module_cflags}}, |
abe256e7 RL |
326 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
327 | NO_INST_BIN_CFLAGS={- join('', $target{no_inst_bin_cflags} | |
328 | // $target{bin_cflags} | |
329 | // (), | |
330 | @{$config{bin_cflags}}, | |
331 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} | |
332 | ||
ab7134ef | 333 | PERLASM_SCHEME={- $target{perlasm_scheme} -} |
e84193e4 | 334 | |
abe256e7 | 335 | # CPPFLAGS_Q is used for one thing only: to build up buildinf.h |
58d6be5b RL |
336 | CPPFLAGS_Q={- (my $c = $lib_cppflags.$cppflags2.$cppflags1) =~ s|"|""|g; |
337 | (my $d = $lib_defines.$defines2.$defines1) =~ s|"|""|g; | |
338 | my $i = join(',', $lib_includes || (), $includes2 || (), | |
339 | $includes1 || ()); | |
abe256e7 RL |
340 | my $x = $c; |
341 | $x .= "/INCLUDE=($i)" if $i; | |
342 | $x .= "/DEFINE=($d)" if $d; | |
343 | $x; -} | |
344 | ||
e84193e4 RL |
345 | # .FIRST and .LAST are special targets with MMS and MMK. |
346 | # The defines in there are for C. includes that look like | |
347 | # this: | |
348 | # | |
349 | # #include <openssl/foo.h> | |
350 | # #include "internal/bar.h" | |
351 | # | |
352 | # will use the logical names to find the files. Expecting | |
353 | # DECompHP C to find files in subdirectories of whatever was | |
354 | # given with /INCLUDE is a fantasy, unfortunately. | |
355 | NODEBUG=@ | |
356 | .FIRST : | |
357 | $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;" | |
15766632 | 358 | $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;" |
e84193e4 RL |
359 | $(NODEBUG) internal_inc1 = F$PARSE("[.crypto.include.internal]","A.;",,,"SYNTAX_ONLY") - "A.;" |
360 | $(NODEBUG) internal_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;" | |
361 | $(NODEBUG) internal_inc3 = F$PARSE("{- catdir($config{sourcedir},"[.crypto.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;" | |
362 | $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2' | |
363 | $(NODEBUG) DEFINE internal 'internal_inc1','internal_inc2','internal_inc3' | |
3c65577f | 364 | $(NODEBUG) staging_dir = "$(DESTDIR)" |
6bd1ef90 RL |
365 | $(NODEBUG) staging_instdir = "" |
366 | $(NODEBUG) staging_datadir = "" | |
e84193e4 | 367 | $(NODEBUG) IF staging_dir .NES. "" THEN - |
6bd1ef90 RL |
368 | staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY") |
369 | $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN - | |
370 | staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]" | |
371 | $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN - | |
372 | staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]" | |
373 | $(NODEBUG) IF staging_dir .NES. "" THEN - | |
374 | staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY") | |
375 | $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN - | |
376 | staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]" | |
377 | $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN - | |
378 | staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]" | |
e84193e4 RL |
379 | $(NODEBUG) ! |
380 | $(NODEBUG) ! Installation logical names | |
381 | $(NODEBUG) ! | |
6bd1ef90 RL |
382 | $(NODEBUG) installtop = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]" |
383 | $(NODEBUG) datatop = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]" | |
384 | $(NODEBUG) DEFINE ossl_installroot 'installtop' | |
385 | $(NODEBUG) DEFINE ossl_dataroot 'datatop' | |
e84193e4 RL |
386 | $(NODEBUG) ! |
387 | $(NODEBUG) ! Figure out the architecture | |
388 | $(NODEBUG) ! | |
3ee24d4a | 389 | $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase") |
e84193e4 RL |
390 | $(NODEBUG) ! |
391 | $(NODEBUG) ! Set up logical names for the libraries, so LINK and | |
392 | $(NODEBUG) ! running programs can use them. | |
393 | $(NODEBUG) ! | |
33105818 | 394 | $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } @shlibs) || "!" -} |
e84193e4 RL |
395 | |
396 | .LAST : | |
33105818 | 397 | $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -} |
6bd1ef90 | 398 | $(NODEBUG) DEASSIGN ossl_dataroot |
e84193e4 RL |
399 | $(NODEBUG) DEASSIGN ossl_installroot |
400 | $(NODEBUG) DEASSIGN internal | |
401 | $(NODEBUG) DEASSIGN openssl | |
402 | .DEFAULT : | |
403 | @ ! MMS cannot handle no actions... | |
404 | ||
405 | # The main targets ################################################### | |
406 | ||
1842f369 | 407 | {- dependmagic('all'); -} : build_libs_nodep, build_modules_nodep, build_programs_nodep |
75726420 | 408 | {- dependmagic('build_libs'); -} : build_libs_nodep |
1842f369 | 409 | {- dependmagic('build_modules'); -} : build_modules_nodep |
75726420 | 410 | {- dependmagic('build_programs'); -} : build_programs_nodep |
c058fcd7 | 411 | |
75726420 | 412 | build_generated : $(GENERATED_MANDATORY) |
8478a703 | 413 | build_libs_nodep : $(LIBS), $(SHLIBS) |
1842f369 | 414 | build_modules_nodep : $(MODULES) |
1e3d16b0 | 415 | build_programs_nodep : $(PROGRAMS), $(SCRIPTS) |
c058fcd7 | 416 | |
1e3d16b0 RL |
417 | # Kept around for backward compatibility |
418 | build_apps build_tests : build_programs | |
419 | ||
9b03b91b RL |
420 | # Convenience target to prebuild all generated files, not just the mandatory |
421 | # ones | |
422 | build_all_generated : $(GENERATED_MANDATORY) $(GENERATED) | |
18d15882 AP |
423 | @ ! {- output_off() if $disabled{makedepend}; "" -} |
424 | @ WRITE SYS$OUTPUT "Warning: consider configuring with no-makedepend, because if" | |
425 | @ WRITE SYS$OUTPUT " target system doesn't have $(PERL)," | |
426 | @ WRITE SYS$OUTPUT " then make will fail..." | |
427 | @ ! {- output_on() if $disabled{makedepend}; "" -} | |
9b03b91b | 428 | |
75726420 | 429 | test : tests |
1842f369 | 430 | {- dependmagic('tests'); -} : build_programs_nodep, build_modules_nodep |
d90a6beb | 431 | @ ! {- output_off() if $disabled{tests}; "" -} |
e84193e4 | 432 | SET DEFAULT [.test]{- move("test") -} |
41f571e1 | 433 | CREATE/DIR [.test-runs] |
e84193e4 RL |
434 | DEFINE SRCTOP {- sourcedir() -} |
435 | DEFINE BLDTOP {- builddir() -} | |
41f571e1 | 436 | DEFINE RESULT_D {- builddir(qw(test test-runs)) -} |
a717738b | 437 | DEFINE OPENSSL_ENGINES {- builddir("engines") -} |
6d4bc8a3 | 438 | DEFINE OPENSSL_DEBUG_MEMORY "on" |
e8173157 | 439 | IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)" |
e84193e4 | 440 | $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS) |
6d4bc8a3 | 441 | DEASSIGN OPENSSL_DEBUG_MEMORY |
a717738b | 442 | DEASSIGN OPENSSL_ENGINES |
e84193e4 RL |
443 | DEASSIGN BLDTOP |
444 | DEASSIGN SRCTOP | |
445 | SET DEFAULT [-]{- move("..") -} | |
d90a6beb MC |
446 | @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} |
447 | @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options" | |
448 | @ ! {- output_on() if !$disabled{tests}; "" -} | |
e84193e4 RL |
449 | |
450 | list-tests : | |
4813ad2d RL |
451 | @ ! {- output_off() if $disabled{tests}; "" -} |
452 | @ DEFINE SRCTOP {- sourcedir() -} | |
453 | @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list | |
454 | @ DEASSIGN SRCTOP | |
455 | @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} | |
456 | @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options" | |
457 | @ ! {- output_on() if !$disabled{tests}; "" -} | |
e84193e4 | 458 | |
4813ad2d | 459 | install : install_sw install_ssldirs install_docs |
a8a421b1 RL |
460 | @ WRITE SYS$OUTPUT "" |
461 | @ WRITE SYS$OUTPUT "######################################################################" | |
462 | @ WRITE SYS$OUTPUT "" | |
687237e9 | 463 | @ IF "$(DESTDIR)" .EQS. "" THEN - |
6bd1ef90 RL |
464 | PIPE ( WRITE SYS$OUTPUT "Installation complete" ; - |
465 | WRITE SYS$OUTPUT "" ; - | |
e78884d7 RL |
466 | WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; - |
467 | WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; - | |
6bd1ef90 RL |
468 | WRITE SYS$OUTPUT "" ) |
469 | @ IF "$(DESTDIR)" .NES. "" THEN - | |
470 | PIPE ( WRITE SYS$OUTPUT "Staging installation complete" ; - | |
471 | WRITE SYS$OUTPUT "" ; - | |
472 | WRITE SYS$OUTPUT "Finish or package in such a way that the contents of the directory tree" ; - | |
473 | WRITE SYS$OUTPUT staging_instdir ; - | |
474 | WRITE SYS$OUTPUT "ends up in $(INSTALLTOP)," ; - | |
475 | WRITE SYS$OUTPUT "and that the contents of the contents of the directory tree" ; - | |
476 | WRITE SYS$OUTPUT staging_datadir ; - | |
477 | WRITE SYS$OUTPUT "ends up in $(OPENSSLDIR)" ; - | |
478 | WRITE SYS$OUTPUT "" ; - | |
479 | WRITE SYS$OUTPUT "When in its final destination," ; - | |
e8fb1295 RL |
480 | WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; - |
481 | WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; - | |
687237e9 | 482 | WRITE SYS$OUTPUT "" ) |
e84193e4 | 483 | |
3426de22 | 484 | check_install : |
e8fb1295 | 485 | spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com |
3426de22 | 486 | |
e84193e4 RL |
487 | uninstall : uninstall_docs uninstall_sw |
488 | ||
4813ad2d | 489 | # Because VMS wants the generation number (or *) to delete files, we can't |
1842f369 | 490 | # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(MODULES) directly. |
4813ad2d | 491 | libclean : |
33105818 | 492 | {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -} |
81183680 | 493 | {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -} |
4813ad2d | 494 | |
e84193e4 | 495 | clean : libclean |
1ae4c07e | 496 | {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -} |
1842f369 | 497 | {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{modules}}) || "@ !" -} |
4813ad2d | 498 | {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -} |
90b3a620 | 499 | {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -} |
4813ad2d RL |
500 | {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -} |
501 | - DELETE [...]*.MAP;* | |
502 | - DELETE [...]*.D;* | |
503 | - DELETE [...]*.OBJ;*,*.LIS;* | |
504 | - DELETE []CXX$DEMANGLER_DB.;* | |
505 | - DELETE [.VMS]openssl_startup.com;* | |
506 | - DELETE [.VMS]openssl_shutdown.com;* | |
507 | - DELETE []vmsconfig.pm;* | |
e84193e4 | 508 | |
7cae3864 RL |
509 | distclean : clean |
510 | - DELETE configdata.pm;* | |
511 | - DELETE descrip.mms;* | |
512 | ||
c058fcd7 RL |
513 | depend : descrip.mms |
514 | descrip.mms : FORCE | |
952a9d1a | 515 | @ ! {- output_off() if $disabled{makedepend}; "" -} |
c39785d4 | 516 | @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "VMS C" |
952a9d1a | 517 | @ ! {- output_on() if $disabled{makedepend}; "" -} |
e84193e4 RL |
518 | |
519 | # Install helper targets ############################################# | |
520 | ||
e8d01a60 | 521 | install_sw : install_dev install_engines install_runtime - |
82c78ee4 | 522 | install_startup install_ivp |
4813ad2d | 523 | |
c1123d9f | 524 | uninstall_sw : uninstall_dev uninstall_engines uninstall_runtime - |
82c78ee4 | 525 | uninstall_startup uninstall_ivp |
e84193e4 | 526 | |
4813ad2d | 527 | install_docs : install_html_docs |
e84193e4 | 528 | |
4813ad2d | 529 | uninstall_docs : uninstall_html_docs |
e84193e4 | 530 | |
4813ad2d RL |
531 | install_ssldirs : check_INSTALLTOP |
532 | - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000] | |
533 | IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN - | |
534 | CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS] | |
535 | IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN - | |
536 | CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE] | |
537 | IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN - | |
538 | CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC] | |
539 | COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC] | |
540 | @ ! Install configuration file | |
cb926df2 RL |
541 | COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} - |
542 | ossl_dataroot:[000000]openssl.cnf-dist | |
543 | IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN - | |
544 | COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} - | |
545 | ossl_dataroot:[000000]openssl.cnf | |
c7af65c7 RS |
546 | @ ! Install CTLOG configuration file |
547 | COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} - | |
548 | ossl_dataroot:[000000]ct_log_list.cnf-dist | |
549 | IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN - | |
550 | COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} - | |
551 | ossl_dataroot:[000000]ct_log_list.cnf | |
e84193e4 | 552 | |
c1123d9f | 553 | install_dev : check_INSTALLTOP install_runtime_libs |
e84193e4 RL |
554 | @ WRITE SYS$OUTPUT "*** Installing development files" |
555 | @ ! Install header files | |
b3514b47 | 556 | - CREATE/DIR ossl_installroot:[include.openssl] |
e84193e4 | 557 | COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl] |
36b53720 | 558 | @ ! Install static (development) libraries |
b3514b47 | 559 | - CREATE/DIR ossl_installroot:[LIB.'arch'] |
e84193e4 | 560 | {- join("\n ", |
a8a421b1 | 561 | map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" } |
33105818 | 562 | @install_libs) -} |
e84193e4 | 563 | |
1842f369 RL |
564 | install_engines : check_INSTALLTOP install_runtime_libs build_modules |
565 | @ {- output_off() unless scalar @install_engines; "" -} ! | |
566 | @ WRITE SYS$OUTPUT "*** Installing ENGINE modules" | |
d4453024 | 567 | - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch'] |
f27f64e1 | 568 | {- join("\n ", |
d4453024 | 569 | map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" } |
ac6bba6f | 570 | @install_engines) -} |
1842f369 | 571 | @ {- output_on() unless scalar @install_engines; "" -} ! |
e84193e4 | 572 | |
e9994901 | 573 | install_runtime : install_programs |
c1123d9f | 574 | |
e8d01a60 | 575 | install_runtime_libs : check_INSTALLTOP build_libs |
c1123d9f RL |
576 | @ {- output_off() if $disabled{shared}; "" -} ! |
577 | @ WRITE SYS$OUTPUT "*** Installing shareable images" | |
578 | @ ! Install shared (runtime) libraries | |
579 | - CREATE/DIR ossl_installroot:[LIB.'arch'] | |
580 | {- join("\n ", | |
581 | map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" } | |
582 | @install_shlibs) -} | |
583 | @ {- output_on() if $disabled{shared}; "" -} ! | |
584 | ||
e8d01a60 | 585 | install_programs : check_INSTALLTOP install_runtime_libs build_programs |
c1123d9f RL |
586 | @ {- output_off() if $disabled{apps}; "" -} ! |
587 | @ ! Install the main program | |
588 | - CREATE/DIR ossl_installroot:[EXE.'arch'] | |
589 | COPY/PROT=W:RE [.APPS]openssl.EXE - | |
590 | ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE | |
591 | @ ! Install scripts | |
592 | COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE] | |
593 | @ ! {- output_on() if $disabled{apps}; "" -} | |
594 | ||
4813ad2d | 595 | install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com - |
dbb3aba1 | 596 | [.VMS]openssl_utils.com, check_INSTALLTOP |
b3514b47 | 597 | - CREATE/DIR ossl_installroot:[SYS$STARTUP] |
e8fb1295 RL |
598 | COPY/PROT=W:RE [.VMS]openssl_startup.com - |
599 | ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com | |
600 | COPY/PROT=W:RE [.VMS]openssl_shutdown.com - | |
601 | ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com | |
602 | COPY/PROT=W:RE [.VMS]openssl_utils.com - | |
603 | ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com | |
e84193e4 | 604 | |
3426de22 RL |
605 | install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP |
606 | - CREATE/DIR ossl_installroot:[SYSTEST] | |
e8fb1295 RL |
607 | COPY/PROT=W:RE [.VMS]openssl_ivp.com - |
608 | ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com | |
3426de22 | 609 | |
e073fd15 | 610 | [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -} |
b3514b47 | 611 | - CREATE/DIR [.VMS] |
e84193e4 RL |
612 | $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} - |
613 | {- sourcefile("VMS", "openssl_startup.com.in") -} - | |
614 | > [.VMS]openssl_startup.com | |
615 | ||
dbb3aba1 RL |
616 | [.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -} |
617 | - CREATE/DIR [.VMS] | |
618 | $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} - | |
619 | {- sourcefile("VMS", "openssl_utils.com.in") -} - | |
620 | > [.VMS]openssl_utils.com | |
621 | ||
e073fd15 | 622 | [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -} |
b3514b47 | 623 | - CREATE/DIR [.VMS] |
e84193e4 RL |
624 | $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} - |
625 | {- sourcefile("VMS", "openssl_shutdown.com.in") -} - | |
626 | > [.VMS]openssl_shutdown.com | |
627 | ||
3426de22 RL |
628 | [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -} |
629 | - CREATE/DIR [.VMS] | |
630 | $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} - | |
631 | {- sourcefile("VMS", "openssl_ivp.com.in") -} - | |
632 | > [.VMS]openssl_ivp.com | |
633 | ||
27f42b46 | 634 | vmsconfig.pm : configdata.pm |
e84193e4 RL |
635 | OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm |
636 | WRITE CONFIG "package vmsconfig;" | |
637 | WRITE CONFIG "use strict; use warnings;" | |
638 | WRITE CONFIG "use Exporter;" | |
639 | WRITE CONFIG "our @ISA = qw(Exporter);" | |
0f2d3e4e | 640 | WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);" |
e84193e4 | 641 | WRITE CONFIG "our %config = (" |
34d5490a RL |
642 | WRITE CONFIG " target => '","{- $config{target} -}","'," |
643 | WRITE CONFIG " version => '","{- $config{version} -}","'," | |
539ea812 | 644 | WRITE CONFIG " shlib_version => '","{- $config{shlib_version} -}","'," |
34d5490a RL |
645 | WRITE CONFIG " shlib_major => '","{- $config{shlib_major} -}","'," |
646 | WRITE CONFIG " shlib_minor => '","{- $config{shlib_minor} -}","'," | |
84af1bae | 647 | WRITE CONFIG " no_shared => '","{- $disabled{shared} -}","'," |
e84193e4 RL |
648 | WRITE CONFIG " INSTALLTOP => '$(INSTALLTOP)'," |
649 | WRITE CONFIG " OPENSSLDIR => '$(OPENSSLDIR)'," | |
34d5490a | 650 | WRITE CONFIG " pointer_size => '","{- $target{pointer_size} -}","'," |
e84193e4 RL |
651 | WRITE CONFIG ");" |
652 | WRITE CONFIG "our %target = ();" | |
0f2d3e4e | 653 | WRITE CONFIG "our %disabled = ();" |
e84193e4 RL |
654 | WRITE CONFIG "our %withargs = ();" |
655 | WRITE CONFIG "our %unified_info = ();" | |
656 | WRITE CONFIG "1;" | |
657 | CLOSE CONFIG | |
658 | ||
e990ec52 | 659 | install_html_docs : check_INSTALLTOP |
9ad7f6c6 RL |
660 | sourcedir = F$PARSE("{- $sourcedir -}A.;","[]") - "]A.;" + ".DOC]" |
661 | $(PERL) {- sourcefile("util", "process_docs.pl") -} - | |
662 | --sourcedir='sourcedir' --destdir=ossl_installroot:[HTML] - | |
663 | --type=html | |
e990ec52 | 664 | |
e84193e4 RL |
665 | check_INSTALLTOP : |
666 | @ IF "$(INSTALLTOP)" .EQS. "" THEN - | |
667 | WRITE SYS$ERROR "INSTALLTOP should not be empty" | |
668 | @ IF "$(INSTALLTOP)" .EQS. "" THEN - | |
669 | EXIT %x10000002 | |
670 | ||
671 | # Helper targets ##################################################### | |
672 | ||
e84193e4 RL |
673 | # Developer targets ################################################## |
674 | ||
675 | debug_logicals : | |
7285ac09 | 676 | SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot |
e84193e4 RL |
677 | |
678 | # Building targets ################################################### | |
679 | ||
41240e68 | 680 | configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -} |
a1b6933e | 681 | perl configdata.pm -r |
e84193e4 RL |
682 | @ WRITE SYS$OUTPUT "*************************************************" |
683 | @ WRITE SYS$OUTPUT "*** ***" | |
684 | @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***" | |
685 | @ WRITE SYS$OUTPUT "*** ***" | |
686 | @ WRITE SYS$OUTPUT "*************************************************" | |
27f42b46 | 687 | @ PIPE ( EXIT %X10000000 ) |
e84193e4 | 688 | |
34544072 | 689 | reconfigure reconf : |
a1b6933e | 690 | perl configdata.pm -r |
bf01fbbf | 691 | |
e84193e4 RL |
692 | {- |
693 | use File::Basename; | |
694 | use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/; | |
66ddf178 | 695 | |
186a31e5 RL |
696 | # Helper function to figure out dependencies on libraries |
697 | # It takes a list of library names and outputs a list of dependencies | |
698 | sub compute_lib_depends { | |
c162a8c3 RL |
699 | # Depending on shared libraries: |
700 | # On Windows POSIX layers, we depend on {libname}.dll.a | |
701 | # On Unix platforms, we depend on {shlibname}.so | |
77550dbf RL |
702 | return map { |
703 | { lib => platform->sharedlib($_) // platform->staticlib($_), | |
704 | attrs => $unified_info{attributes}->{$_} } | |
705 | } @_; | |
186a31e5 RL |
706 | } |
707 | ||
ab7134ef RL |
708 | # Helper function to deal with inclusion directory specs. |
709 | # We have to deal with two things: | |
710 | # 1. comma separation and no possibility of trailing comma | |
711 | # 2. no inclusion directories given at all | |
712 | # 3. long compiler command lines | |
713 | # To resolve 1, we need to iterate through the sources of inclusion | |
714 | # directories, and only add a comma when needed. | |
715 | # To resolve 2, we need to have a variable that will hold the whole | |
716 | # inclusion qualifier, or be the empty string if there are no inclusion | |
717 | # directories. That's the symbol 'qual_includes' that's used in CPPFLAGS | |
718 | # To resolve 3, we creata a logical name TMP_INCLUDES: to hold the list | |
719 | # of inclusion directories. | |
720 | # | |
721 | # This function returns a list of two lists, one being the collection of | |
722 | # commands to execute before the compiler is called, and the other being | |
723 | # the collection of commands to execute after. It takes as arguments the | |
724 | # collection of strings to include as directory specs. | |
725 | sub includes { | |
726 | my @stuff = ( @_ ); | |
727 | my @before = ( | |
728 | 'qual_includes :=', | |
729 | ); | |
730 | my @after = ( | |
731 | 'DELETE/SYMBOL/LOCAL qual_includes', | |
732 | ); | |
733 | ||
734 | if (scalar @stuff > 0) { | |
735 | push @before, 'tmp_includes := '.shift(@stuff); | |
736 | while (@stuff) { | |
737 | push @before, 'tmp_add := '.shift(@stuff); | |
738 | push @before, 'IF tmp_includes .NES. "" .AND. tmp_add .NES. "" THEN tmp_includes = tmp_includes + ","'; | |
739 | push @before, 'tmp_includes = tmp_includes + tmp_add'; | |
740 | } | |
741 | push @before, "IF tmp_includes .NES. \"\" THEN DEFINE tmp_includes 'tmp_includes'"; | |
742 | push @before, 'IF tmp_includes .NES. "" THEN qual_includes := /INCLUDE=(tmp_includes:)'; | |
743 | push @before, 'DELETE/SYMBOL/LOCAL tmp_includes'; | |
744 | push @before, 'DELETE/SYMBOL/LOCAL tmp_add'; | |
745 | push @after, 'DEASSIGN tmp_includes:' | |
746 | } | |
747 | return ([ @before ], [ @after ]); | |
748 | } | |
749 | ||
66ddf178 RL |
750 | sub generatesrc { |
751 | my %args = @_; | |
752 | my $generator = join(" ", @{$args{generator}}); | |
8d34daf0 RL |
753 | my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}}); |
754 | my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}}); | |
66ddf178 | 755 | |
c162a8c3 RL |
756 | if (platform->isdef($args{src})) { |
757 | my $target = platform->def($args{src}); | |
ef2dfc99 | 758 | my $mkdef = sourcefile('util', 'mkdef.pl'); |
66a24ab8 RL |
759 | my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : ''; |
760 | my $ord_name = | |
761 | $args{generator}->[1] || basename($args{product}, '.EXE'); | |
36d3acb9 RL |
762 | my $case_insensitive = |
763 | $target{$args{intent}.'_cflags'} =~ m|/NAMES=[^/]*AS_IS|i | |
764 | ? '' : ' --case-insensitive'; | |
ef2dfc99 | 765 | return <<"EOF"; |
66a24ab8 | 766 | $target : $args{generator}->[0] $deps $mkdef |
36d3acb9 | 767 | \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name "--OS" "VMS"$case_insensitive > $target |
ef2dfc99 | 768 | EOF |
c162a8c3 | 769 | } elsif (!platform->isasm($args{src})) { |
ef2dfc99 | 770 | my $target = $args{src}; |
7cae3864 RL |
771 | if ($args{generator}->[0] =~ m|^.*\.in$|) { |
772 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, | |
773 | "util", "dofile.pl")), | |
774 | rel2abs($config{builddir})); | |
775 | return <<"EOF"; | |
ab7134ef | 776 | $target : $args{generator}->[0] $deps |
7cae3864 | 777 | \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\ |
ab7134ef | 778 | "-o$target{build_file}" $generator > \$\@ |
7cae3864 RL |
779 | EOF |
780 | } else { | |
781 | return <<"EOF"; | |
ab7134ef RL |
782 | $target : $args{generator}->[0] $deps |
783 | \$(PERL)$generator_incs $generator > \$\@ | |
66ddf178 | 784 | EOF |
7cae3864 | 785 | } |
66ddf178 | 786 | } else { |
c162a8c3 | 787 | my $target = platform->asm($args{src}); |
ab7134ef RL |
788 | if ($args{generator}->[0] =~ /\.pl$/) { |
789 | $generator = '$(PERL)'.$generator_incs.' '.$generator; | |
790 | } elsif ($args{generator}->[0] =~ /\.S$/) { | |
791 | $generator = undef; | |
792 | } else { | |
793 | die "Generator type for $src unknown: $generator\n"; | |
794 | } | |
795 | ||
8bc0147f | 796 | my $cppflags = { |
9dfc8680 | 797 | shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', |
8bc0147f RL |
798 | lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', |
799 | dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)', | |
800 | bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)' | |
801 | } -> {$args{intent}}; | |
9dfc8680 RL |
802 | my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)', |
803 | lib => '$(LIB_INCLUDES)', | |
ab7134ef RL |
804 | dso => '$(DSO_INCLUDES)', |
805 | bin => '$(BIN_INCLUDES)' } -> {$args{intent}}, | |
abe256e7 | 806 | '$(CNF_INCLUDES)', |
ab7134ef RL |
807 | '$(INCLUDES)', |
808 | @{$args{incs}}); | |
809 | my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!'; | |
810 | my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!'; | |
0a37ff4d | 811 | my $defs = join("", map { ",".$_ } @{$args{defs}}); |
ab7134ef RL |
812 | if (defined($generator)) { |
813 | # If the target is named foo.S in build.info, we want to | |
814 | # end up generating foo.s in two steps. | |
815 | if ($args{src} =~ /\.S$/) { | |
816 | return <<"EOF"; | |
817 | $target : $args{generator}->[0] $deps | |
818 | $generator \$\@-S | |
819 | \@ $incs_on | |
0a37ff4d | 820 | \@ extradefines = "$defs" |
ab7134ef | 821 | PIPE \$(CPP) $cppflags \$\@-S | - |
e4366648 | 822 | \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@-i |
0a37ff4d | 823 | \@ DELETE/SYMBOL/LOCAL extradefines |
ab7134ef RL |
824 | \@ $incs_off |
825 | RENAME \$\@-i \$\@ | |
f19d20b6 | 826 | DELETE \$\@-S; |
ab7134ef RL |
827 | EOF |
828 | } | |
829 | # Otherwise.... | |
830 | return <<"EOF"; | |
831 | $target : $args{generator}->[0] $deps | |
832 | $generator \$\@ | |
833 | EOF | |
834 | } | |
835 | return <<"EOF"; | |
836 | $target : $args{generator}->[0] $deps | |
837 | \@ $incs_on | |
0a37ff4d | 838 | \@ extradefines = "$defs" |
ab7134ef RL |
839 | SHOW SYMBOL qual_includes |
840 | PIPE \$(CPP) $cppflags $args{generator}->[0] | - | |
841 | \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@ | |
0a37ff4d | 842 | \@ DELETE/SYMBOL/LOCAL extradefines |
ab7134ef RL |
843 | \@ $incs_off |
844 | EOF | |
66ddf178 RL |
845 | } |
846 | } | |
847 | ||
e84193e4 | 848 | sub src2obj { |
d88736df | 849 | my $asmext = platform->asmext(); |
e84193e4 | 850 | my %args = @_; |
d88736df RL |
851 | my @srcs = |
852 | map { my $x = $_; | |
853 | (platform->isasm($x) && grep { $x eq $_ } @generated) | |
854 | ? platform->asm($x) : $x } | |
855 | ( @{$args{srcs}} ); | |
c162a8c3 | 856 | my $obj = platform->obj($args{obj}); |
d88736df | 857 | my $dep = platform->dep($args{obj}); |
ab7134ef | 858 | my $deps = join(", -\n\t\t", @srcs, @{$args{deps}}); |
e84193e4 RL |
859 | |
860 | # Because VMS C isn't very good at combining a /INCLUDE path with | |
861 | # #includes having a relative directory (like '#include "../foo.h"), | |
862 | # the best choice is to move to the first source file's intended | |
863 | # directory before compiling, and make sure to write the object file | |
864 | # in the correct position (important when the object tree is other | |
865 | # than the source tree). | |
866 | my $forward = dirname($args{srcs}->[0]); | |
867 | my $backward = abs2rel(rel2abs("."), rel2abs($forward)); | |
868 | my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward)); | |
d88736df RL |
869 | my $objn = basename($obj); |
870 | my $depd = abs2rel(rel2abs(dirname($dep)), rel2abs($forward)); | |
871 | my $depn = basename($dep); | |
e84193e4 | 872 | my $srcs = |
ab7134ef | 873 | join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs); |
c162a8c3 RL |
874 | my $before = $unified_info{before}->{$obj} || "\@ !"; |
875 | my $after = $unified_info{after}->{$obj} || "\@ !"; | |
876 | ||
ab7134ef | 877 | my $cflags; |
5cae2d34 | 878 | if ($args{attrs}->{noinst}) { |
9dfc8680 RL |
879 | $cflags = { shlib => '$(NO_INST_LIB_CFLAGS)', |
880 | lib => '$(NO_INST_LIB_CFLAGS)', | |
722c9762 RL |
881 | dso => '$(NO_INST_DSO_CFLAGS)', |
882 | bin => '$(NO_INST_BIN_CFLAGS)' } -> {$args{intent}}; | |
5cae2d34 RL |
883 | } else { |
884 | $cflags = { shlib => '$(LIB_CFLAGS)', | |
885 | lib => '$(LIB_CFLAGS)', | |
886 | dso => '$(DSO_CFLAGS)', | |
887 | bin => '$(BIN_CFLAGS)' } -> {$args{intent}}; | |
1750142f | 888 | } |
9dfc8680 RL |
889 | $cflags .= { shlib => '$(LIB_CPPFLAGS)', |
890 | lib => '$(LIB_CPPFLAGS)', | |
8c3bc594 RL |
891 | dso => '$(DSO_CPPFLAGS)', |
892 | bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}}; | |
0a37ff4d | 893 | my $defs = join("", map { ",".$_ } @{$args{defs}}); |
e4366648 RL |
894 | my $asflags = { shlib => ' $(LIB_ASFLAGS)', |
895 | lib => ' $(LIB_ASFLAGS)', | |
896 | dso => ' $(DSO_ASFLAGS)', | |
897 | bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}}; | |
ab7134ef | 898 | |
9dfc8680 RL |
899 | my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)', |
900 | lib => '$(LIB_INCLUDES)', | |
ab7134ef RL |
901 | dso => '$(DSO_INCLUDES)', |
902 | bin => '$(BIN_INCLUDES)' } -> {$args{intent}}, | |
903 | '$(INCLUDES)', | |
904 | map { | |
905 | file_name_is_absolute($_) | |
906 | ? $_ : catdir($backward,$_) | |
907 | } @{$args{incs}}); | |
908 | my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!'; | |
909 | my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!'; | |
e4366648 | 910 | |
d88736df | 911 | if ($srcs[0] =~ /\Q${asmext}\E$/) { |
e4366648 | 912 | return <<"EOF"; |
d88736df | 913 | $obj : $deps |
e4366648 RL |
914 | ${before} |
915 | SET DEFAULT $forward | |
d88736df | 916 | \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn} $srcs |
e4366648 RL |
917 | SET DEFAULT $backward |
918 | ${after} | |
d88736df | 919 | - PURGE $obj |
e4366648 RL |
920 | EOF |
921 | } elsif ($srcs[0] =~ /.S$/) { | |
922 | return <<"EOF"; | |
d88736df | 923 | $obj : $deps |
e4366648 RL |
924 | ${before} |
925 | SET DEFAULT $forward | |
926 | \@ $incs_on | |
927 | \@ extradefines = "$defs" | |
928 | PIPE \$(CPP) ${cflags} $srcs | - | |
929 | \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" - | |
d88736df | 930 | > ${objd}${objn}-asm |
e4366648 RL |
931 | \@ DELETE/SYMBOL/LOCAL extradefines |
932 | \@ $incs_off | |
933 | SET DEFAULT $backward | |
934 | ${after} | |
d88736df RL |
935 | \$(AS) $asflags \$(ASOUTFLAG)$obj $obj-asm |
936 | - PURGE $obj | |
e4366648 RL |
937 | EOF |
938 | } | |
939 | ||
952a9d1a | 940 | my $depbuild = $disabled{makedepend} ? "" |
d88736df | 941 | : " /MMS=(FILE=${depd}${depn},TARGET=$obj)"; |
e84193e4 | 942 | |
c39785d4 | 943 | return <<"EOF"; |
c162a8c3 | 944 | $obj : $deps |
70ef9057 RL |
945 | ${before} |
946 | SET DEFAULT $forward | |
722c9762 | 947 | \@ $incs_on |
0a37ff4d | 948 | \@ extradefines = "$defs" |
d88736df | 949 | \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn} /REPOSITORY=$backward $srcs |
0a37ff4d | 950 | \@ DELETE/SYMBOL/LOCAL extradefines |
722c9762 | 951 | \@ $incs_off |
e84193e4 RL |
952 | SET DEFAULT $backward |
953 | ${after} | |
c162a8c3 | 954 | - PURGE $obj |
ea7df7ea | 955 | EOF |
e84193e4 | 956 | } |
f6196227 | 957 | sub obj2shlib { |
e84193e4 | 958 | my %args = @_; |
c162a8c3 RL |
959 | my $shlibname = platform->sharedname($args{lib}); |
960 | my $shlib = platform->sharedlib($args{lib}); | |
961 | my @objs = map { platform->convertext($_) } | |
962 | grep { platform->isobj($_) } | |
b78eb0b6 | 963 | @{$args{objs}}; |
c162a8c3 RL |
964 | my @defs = map { platform->convertext($_) } |
965 | grep { platform->isdef($_) } | |
ef2dfc99 | 966 | @{$args{objs}}; |
186a31e5 | 967 | my @deps = compute_lib_depends(@{$args{deps}}); |
81183680 | 968 | die "More than one symbol vector" if scalar @defs > 1; |
77550dbf | 969 | my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps); |
84af1bae | 970 | my $shlib_target = $disabled{shared} ? "" : $target{shared_target}; |
e84193e4 RL |
971 | my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir}, |
972 | "VMS", "translatesyms.pl")), | |
973 | rel2abs($config{builddir})); | |
974 | # The "[]" hack is because in .OPT files, each line inherits the | |
975 | # previous line's file spec as default, so if no directory spec | |
976 | # is present in the current line and the previous line has one that | |
977 | # doesn't apply, you're in for a surprise. | |
b78eb0b6 RL |
978 | my $write_opt1 = |
979 | join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_; | |
980 | "WRITE OPT_FILE \"$x" } @objs). | |
981 | "\""; | |
982 | my $write_opt2 = | |
77550dbf RL |
983 | join("\n\t", map { my $x = $_->{lib} =~ /\[/ |
984 | ? $_->{lib} : "[]".$_->{lib}; | |
e84193e4 | 985 | $x =~ s|(\.EXE)|$1/SHARE|; |
ef3c88cf | 986 | $x =~ s|(\.OLB)|$1/LIB|; |
e84193e4 RL |
987 | "WRITE OPT_FILE \"$x\"" } @deps) |
988 | || "\@ !"; | |
a2880aec | 989 | return <<"EOF" |
c162a8c3 | 990 | $shlib : $deps |
81183680 | 991 | \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated |
c162a8c3 | 992 | OPEN/WRITE/SHARE=READ OPT_FILE $shlibname-components.OPT |
b78eb0b6 RL |
993 | $write_opt1 |
994 | $write_opt2 | |
995 | CLOSE OPT_FILE | |
abe256e7 | 996 | LINK \$(LIB_LDFLAGS)/SHARE=\$\@ $defs[0]-translated/OPT,- |
c162a8c3 RL |
997 | $shlibname-components.OPT/OPT \$(LIB_EX_LIBS) |
998 | DELETE $defs[0]-translated;*,$shlibname-components.OPT;* | |
999 | PURGE $shlibname.EXE,$shlibname.MAP | |
e84193e4 | 1000 | EOF |
a2880aec RL |
1001 | . ($config{target} =~ m|alpha| ? "" : <<"EOF" |
1002 | SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@ | |
1003 | EOF | |
1004 | ); | |
e84193e4 | 1005 | } |
5386287c | 1006 | sub obj2dso { |
e84193e4 | 1007 | my %args = @_; |
c162a8c3 RL |
1008 | my $dsoname = platform->dsoname($args{lib}); |
1009 | my $dso = platform->dso($args{lib}); | |
1010 | my @objs = map { platform->convertext($_) } | |
1011 | grep { platform->isobj($_) } | |
66a24ab8 | 1012 | @{$args{objs}}; |
c162a8c3 RL |
1013 | my @defs = map { platform->convertext($_) } |
1014 | grep { platform->isdef($_) } | |
66a24ab8 | 1015 | @{$args{objs}}; |
186a31e5 | 1016 | my @deps = compute_lib_depends(@{$args{deps}}); |
77550dbf | 1017 | my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps); |
66a24ab8 | 1018 | die "More than one symbol vector" if scalar @defs > 1; |
84af1bae | 1019 | my $shlib_target = $disabled{shared} ? "" : $target{shared_target}; |
e84193e4 RL |
1020 | # The "[]" hack is because in .OPT files, each line inherits the |
1021 | # previous line's file spec as default, so if no directory spec | |
1022 | # is present in the current line and the previous line has one that | |
1023 | # doesn't apply, you're in for a surprise. | |
47852e6a | 1024 | my $write_opt1 = |
e84193e4 RL |
1025 | join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_; |
1026 | "WRITE OPT_FILE \"$x" } @objs). | |
47852e6a RL |
1027 | "\""; |
1028 | my $write_opt2 = | |
77550dbf RL |
1029 | join("\n\t", map { my $x = $_->{lib} =~ /\[/ |
1030 | ? $_->{lib} : "[]".$_->{lib}; | |
e84193e4 | 1031 | $x =~ s|(\.EXE)|$1/SHARE|; |
ef3c88cf | 1032 | $x =~ s|(\.OLB)|$1/LIB|; |
e84193e4 RL |
1033 | "WRITE OPT_FILE \"$x\"" } @deps) |
1034 | || "\@ !"; | |
a2880aec | 1035 | return <<"EOF" |
c162a8c3 RL |
1036 | $dso : $deps |
1037 | OPEN/WRITE/SHARE=READ OPT_FILE $dsoname-components.OPT | |
47852e6a RL |
1038 | $write_opt1 |
1039 | $write_opt2 | |
e84193e4 | 1040 | CLOSE OPT_FILE |
66a24ab8 | 1041 | LINK \$(DSO_LDFLAGS)/SHARE=\$\@ $defs[0]/OPT,- |
c162a8c3 RL |
1042 | $dsoname-components.OPT/OPT \$(DSO_EX_LIBS) |
1043 | - PURGE $dsoname.EXE,$dsoname.OPT,$dsoname.MAP | |
e84193e4 | 1044 | EOF |
a2880aec RL |
1045 | . ($config{target} =~ m|alpha| ? "" : <<"EOF" |
1046 | SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@ | |
1047 | EOF | |
1048 | ); | |
e84193e4 RL |
1049 | } |
1050 | sub obj2lib { | |
1051 | my %args = @_; | |
c162a8c3 RL |
1052 | my $lib = platform->staticlib($args{lib}); |
1053 | my @objs = map { platform->convertext($_) } | |
1054 | grep { platform->isobj($_) } | |
1055 | @{$args{objs}}; | |
81183680 | 1056 | my $objs = join(", -\n\t\t", @objs); |
c162a8c3 | 1057 | my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib $_" } @objs)); |
e84193e4 | 1058 | return <<"EOF"; |
c162a8c3 RL |
1059 | $lib : $objs |
1060 | LIBRARY/CREATE/OBJECT $lib | |
e84193e4 | 1061 | $fill_lib |
c162a8c3 | 1062 | - PURGE $lib |
e84193e4 RL |
1063 | EOF |
1064 | } | |
1065 | sub obj2bin { | |
1066 | my %args = @_; | |
c162a8c3 RL |
1067 | my $bin = platform->bin($args{bin}); |
1068 | my $binname = platform->binname($args{bin}); | |
1069 | my @objs = map { platform->convertext($_) } | |
1070 | grep { platform->isobj($_) } | |
1071 | @{$args{objs}}; | |
b3e5db40 | 1072 | my $objs = join(",", @objs); |
186a31e5 | 1073 | my @deps = compute_lib_depends(@{$args{deps}}); |
77550dbf | 1074 | my $deps = join(", -\n\t\t", @objs, map { $_->{lib} } @deps); |
b3e5db40 | 1075 | |
77550dbf | 1076 | my $olb_count = scalar grep(m|\.OLB$|, map { $_->{lib} } @deps); |
b3e5db40 RL |
1077 | my $analyse_objs = "@ !"; |
1078 | if ($olb_count > 0) { | |
1079 | my $analyse_quals = | |
1080 | $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB"; | |
1081 | $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1" | |
1082 | } | |
e84193e4 RL |
1083 | # The "[]" hack is because in .OPT files, each line inherits the |
1084 | # previous line's file spec as default, so if no directory spec | |
1085 | # is present in the current line and the previous line has one that | |
1086 | # doesn't apply, you're in for a surprise. | |
47852e6a | 1087 | my $write_opt1 = |
e84193e4 | 1088 | join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_; |
b3e5db40 | 1089 | "\@ WRITE OPT_FILE \"$x" } @objs). |
47852e6a RL |
1090 | "\""; |
1091 | my $write_opt2 = | |
77550dbf RL |
1092 | join("\n\t", "WRITE OPT_FILE \"CASE_SENSITIVE=YES\"", |
1093 | map { my @lines = (); | |
1094 | use Data::Dumper; | |
77550dbf RL |
1095 | my $x = $_->{lib} =~ /\[/ |
1096 | ? $_->{lib} : "[]".$_->{lib}; | |
b3e5db40 RL |
1097 | if ($x =~ m|\.EXE$|) { |
1098 | push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\""; | |
1099 | } elsif ($x =~ m|\.OLB$|) { | |
77550dbf RL |
1100 | # Special hack to include the MAIN object |
1101 | # module explicitly. This will only be done | |
1102 | # if there isn't a 'main' in the program's | |
1103 | # object modules already. | |
1104 | my $main = $_->{attrs}->{has_main} | |
1105 | ? '/INCLUDE=main' : ''; | |
df443918 | 1106 | push @lines, |
77550dbf | 1107 | "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB$main\"", |
b3e5db40 RL |
1108 | "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\"" |
1109 | } | |
1110 | @lines | |
1111 | } @deps) | |
e84193e4 | 1112 | || "\@ !"; |
bbdec3f2 RL |
1113 | # The linking commands looks a bit complex, but it's for good reason. |
1114 | # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and | |
1115 | # bar.obj happens to have a symbol that also exists in libsomething.exe, | |
1116 | # the linker will warn about it, loudly, and will then choose to pick | |
1117 | # the first copy encountered (the one in bar.obj in this example). | |
1118 | # On Unix and on Windows, the corresponding maneuvre goes through | |
1119 | # silently with the same effect. | |
1120 | # With some test programs, made for checking the internals of OpenSSL, | |
1121 | # we do this kind of linking deliberately, picking a few specific object | |
1122 | # files from within [.crypto] or [.ssl] so we can reach symbols that are | |
1123 | # otherwise unreachable (since the shareable images only exports the | |
1124 | # symbols listed in [.util]*.num), and then with the shared libraries | |
1125 | # themselves. So we need to silence the warning about multiply defined | |
1126 | # symbols, to mimic the way linking work on Unix and Windows, and so | |
1127 | # the build isn't interrupted (MMS stops when warnings are signaled, | |
1128 | # by default), and so someone building doesn't have to worry where it | |
1129 | # isn't necessary. If there are other warnings, however, we show them | |
1130 | # and let it break the build. | |
a2880aec | 1131 | return <<"EOF" |
c162a8c3 | 1132 | $bin : $deps |
b3e5db40 | 1133 | $analyse_objs |
c162a8c3 | 1134 | @ OPEN/WRITE/SHARE=READ OPT_FILE $binname.OPT |
47852e6a RL |
1135 | $write_opt1 |
1136 | $write_opt2 | |
b3e5db40 | 1137 | @ CLOSE OPT_FILE |
c162a8c3 RL |
1138 | TYPE $binname.OPT ! For debugging |
1139 | - pipe SPAWN/WAIT/NOLOG/OUT=$binname.LINKLOG - | |
1140 | LINK \$(BIN_LDFLAGS)/EXEC=\$\@ $binname.OPT/OPT \$(BIN_EX_LIBS) ; - | |
bbdec3f2 RL |
1141 | link_status = \$status ; link_severity = link_status .AND. 7 |
1142 | @ search_severity = 1 | |
1143 | -@ IF link_severity .EQ. 0 THEN - | |
c162a8c3 | 1144 | pipe SEARCH $binname.LINKLOG "%","-"/MATCH=AND | - |
bbdec3f2 RL |
1145 | SPAWN/WAIT/NOLOG/OUT=NLA0: - |
1146 | SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; - | |
1147 | search_severity = \$severity | |
1148 | @ ! search_severity is 3 when the last search didn't find any matching | |
1149 | @ ! string: %SEARCH-I-NOMATCHES, no strings matched | |
fb0abdce RL |
1150 | @ ! If that was the result, we pretend linking got through without |
1151 | @ ! fault or warning. | |
1152 | @ IF search_severity .EQ. 3 THEN link_severity = 1 | |
1153 | @ ! At this point, if link_severity shows that there was a fault | |
1154 | @ ! or warning, make sure to restore the linking status. | |
c162a8c3 RL |
1155 | -@ IF .NOT. link_severity THEN TYPE $binname.LINKLOG |
1156 | -@ DELETE $binname.LINKLOG;* | |
fb0abdce | 1157 | @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status' |
c162a8c3 | 1158 | - PURGE $bin,$binname.OPT |
e84193e4 | 1159 | EOF |
b3e5db40 | 1160 | . ($config{target} =~ m|alpha| ? "" : <<"EOF" |
a2880aec RL |
1161 | SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@ |
1162 | EOF | |
1163 | ); | |
e84193e4 RL |
1164 | } |
1165 | sub in2script { | |
1166 | my %args = @_; | |
1167 | my $script = $args{script}; | |
1168 | return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite! | |
1169 | my $sources = join(" ", @{$args{sources}}); | |
1170 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, | |
1171 | "util", "dofile.pl")), | |
1172 | rel2abs($config{builddir})); | |
1173 | return <<"EOF"; | |
1174 | $script : $sources | |
b867c707 | 1175 | \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile - |
ba327ade | 1176 | "-o$target{build_file}" $sources > $script |
e84193e4 RL |
1177 | SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script |
1178 | PURGE $script | |
1179 | EOF | |
1180 | } | |
1181 | "" # Important! This becomes part of the template result. | |
1182 | -} |