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