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