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