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