]> git.ipfire.org Git - thirdparty/openssl.git/blob - Configurations/descrip.mms.tmpl
Fix "Error finalizing cipher loop" when running openssl speed -evp -decrypt
[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 use OpenSSL::Util;
8
9 (our $osslprefix_q = platform->osslprefix()) =~ s/\$/\\\$/;
10
11 our $sover_dirname = platform->shlib_version_as_filename();
12 our $osslver = sprintf "%02d", split(/\./, $config{version});
13
14 our $sourcedir = $config{sourcedir};
15 our $builddir = $config{builddir};
16 sub make_unix_path {
17 # Split the native path
18 (my $vol, my $dirs, my $file) = File::Spec->splitpath($_[0]);
19 my @dirs = File::Spec->splitdir($dirs);
20
21 # Reassemble it as a Unix path
22 $vol =~ s|:$||;
23 return File::Spec::Unix->catpath(
24 '', File::Spec::Unix->catdir('', $vol ? $vol : (), @dirs), $file);
25 }
26 sub sourcefile {
27 catfile($sourcedir, @_);
28 }
29 sub buildfile {
30 catfile($builddir, @_);
31 }
32 sub sourcedir {
33 catdir($sourcedir, @_);
34 }
35 sub builddir {
36 catdir($builddir, @_);
37 }
38 sub tree {
39 (my $x = shift) =~ s|\]$|...]|;
40 $x
41 }
42
43 # Because we need to make two computations of these data,
44 # we store them in arrays for reuse
45 our @libs =
46 map { platform->staticname($_) }
47 @{$unified_info{libraries}};
48 our @shlibs =
49 map { platform->sharedname($_) // () }
50 @{$unified_info{libraries}};
51 our @install_libs =
52 map { platform->staticname($_) }
53 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
54 @{$unified_info{libraries}};
55 our @install_shlibs =
56 map { platform->sharedname($_) // () }
57 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
58 @{$unified_info{libraries}};
59 our @install_engines =
60 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
61 && $unified_info{attributes}->{modules}->{$_}->{engine} }
62 @{$unified_info{modules}};
63 our @install_modules =
64 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
65 && !$unified_info{attributes}->{modules}->{$_}->{engine}
66 && !$unified_info{attributes}->{modules}->{$_}->{fips} }
67 @{$unified_info{modules}};
68 our @install_fipsmodules =
69 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
70 && $unified_info{attributes}->{modules}->{$_}->{fips} }
71 @{$unified_info{modules}};
72 our @install_programs =
73 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
74 @{$unified_info{programs}};
75 our @install_bin_scripts =
76 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
77 && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
78 @{$unified_info{scripts}};
79 our @install_misc_scripts =
80 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
81 && $unified_info{attributes}->{scripts}->{$_}->{misc} }
82 @{$unified_info{scripts}};
83
84 # Configured flags
85
86 our @cnf_asflags = ($target{asflags} || (), @{$config{asflags}});
87 our @cnf_defines = (@{$target{defines}}, @{$config{defines}});
88 our @cnf_includes = (@{$target{includes}}, @{$config{includes}});
89 our @cnf_cppflags = ($target{cppflags} || (), @{$config{cppflags}});
90 our @cnf_cflags = ($target{cflags} || (), @{$config{cflags}});
91 our @cnf_cxxflags = ($target{cxxflags} || (), @{$config{cxxflags}});
92 our @cnf_ldflags = ($target{lflags} || (), @{$config{lflags}});
93 our @cnf_ex_libs = (map{ ",$_" } @{$target{ex_libs}}, @{$config{ex_libs}});
94
95 # Variables starting with $lib_ are used to build library object files
96 # and shared libraries.
97 # Variables starting with $dso_ are used to build DSOs and their object files.
98 # Variables starting with $bin_ are used to build programs and their object
99 # files.
100
101 # The following array is special and is treated separately from the rest of
102 # the lib_ variables.
103 our @lib_cppincludes = (@{$target{lib_includes}}, @{$target{shared_includes}},
104 @{$config{lib_includes}}, @{$config{shared_includes}},
105 @cnf_includes);
106
107 our $lib_cppdefines =
108 join(',', @{$target{lib_defines}}, @{$target{shared_defines}},
109 @{$config{lib_defines}}, @{$config{shared_defines}},
110 @cnf_defines,
111 'OPENSSLDIR="""$(OPENSSLDIR_C)"""',
112 'ENGINESDIR="""$(ENGINESDIR_C)"""',
113 'MODULESDIR="""$(MODULESDIR_C)"""'
114 )
115 . '$(DEFINES)'
116 . "'extradefines'";
117 our $lib_asflags =
118 join(' ', $target{lib_asflags} || (), @{$config{lib_asflags}},
119 @cnf_asflags, '$(ASFLAGS)');
120 our $lib_cppflags =
121 join('', $target{lib_cppflags} || (), $target{shared_cppflags} || (),
122 @{$config{lib_cppflags}}, @{$config{shared_cppflag}},
123 @cnf_cppflags, '/DEFINE=('.$lib_cppdefines.')', '$(CPPFLAGS)');
124 my @lib_cflags = ( $target{lib_cflags} // () );
125 my @lib_cflags_no_inst = ( $target{no_inst_lib_cflags} // @lib_cflags );
126 my @lib_cflags_cont = ( $target{shared_cflag} || (),
127 @{$config{lib_cflags}}, @{$config{shared_cflag}},
128 @cnf_cflags, '$(CFLAGS)');
129 our $lib_cflags = join('', @lib_cflags, @lib_cflags_cont );
130 our $lib_cflags_no_inst = join('', @lib_cflags_no_inst, @lib_cflags_cont );
131 our $lib_ldflags =
132 join('', $target{lib_lflags} || (), $target{shared_ldflag} || (),
133 @{$config{lib_lflags}}, @{$config{shared_ldflag}},
134 @cnf_ldflags, '$(LDFLAGS)');
135 our $lib_ex_libs = join('', @cnf_ex_libs, '$(EX_LIBS)');
136
137 # The following array is special and is treated separately from the rest of
138 # the dso_ variables.
139 our @dso_cppincludes = (@{$target{dso_includes}}, @{$target{module_includes}},
140 @{$config{dso_includes}}, @{$config{module_includes}},
141 @cnf_includes);
142
143 our $dso_cppdefines =
144 join(',', @{$target{dso_defines}}, @{$target{module_defines}},
145 @{$config{dso_defines}}, @{$config{module_defines}},
146 @cnf_defines,
147 )
148 . '$(DEFINES)'
149 . "'extradefines'";
150 our $dso_asflags =
151 join(' ', $target{dso_asflags} || (), $target{module_asflags} || (),
152 @{$config{dso_asflags}}, @{$config{module_asflags}},
153 @cnf_asflags, '$(ASFLAGS)');
154 our $dso_cppflags =
155 join('', $target{dso_cppflags} || (), $target{module_cppflags} || (),
156 @{$config{dso_cppflags}}, @{$config{module_cppflag}},
157 @cnf_cppflags,
158 '/DEFINE=('.$dso_cppdefines.')',
159 '$(CPPFLAGS)');
160 my @dso_cflags = ( $target{dso_cflags} // () );
161 my @dso_cflags_no_inst = ( $target{no_inst_dso_cflags} // @dso_cflags );
162 my @dso_cflags_cont = ( $target{module_cflag} || (),
163 @{$config{dso_cflags}}, @{$config{module_cflag}},
164 @cnf_cflags, '$(CFLAGS)');
165 our $dso_cflags = join('', @dso_cflags, @dso_cflags_cont );
166 our $dso_cflags_no_inst = join('', @dso_cflags_no_inst, @dso_cflags_cont );
167 our $dso_ldflags =
168 join('', $target{dso_lflags} || (), $target{module_ldflag} || (),
169 @{$config{dso_lflags}}, @{$config{module_ldflag}},
170 @cnf_ldflags, '$(LDFLAGS)');
171 our $dso_ex_libs = join('', @cnf_ex_libs, '$(EX_LIBS)');
172
173 # The following array is special and is treated separately from the rest of
174 # the bin_ variables.
175 our @bin_cppincludes = (@{$target{bin_includes}},
176 @{$config{bin_includes}},
177 @cnf_includes);
178
179 our $bin_cppdefines =
180 join(',', @{$target{bin_defines}},
181 @{$config{bin_defines}},
182 @cnf_defines,
183 )
184 . '$(DEFINES)'
185 . "'extradefines'";
186 our $bin_asflags =
187 join(' ', $target{bin_asflags} || (),
188 @{$config{bin_asflags}},
189 @cnf_asflags, '$(ASFLAGS)');
190 our $bin_cppflags =
191 join('', $target{bin_cppflags} || (),
192 @{$config{bin_cppflags}},
193 @cnf_cppflags,
194 '/DEFINE=('.$bin_cppdefines.')',
195 '$(CPPFLAGS)');
196 my @bin_cflags = ( $target{bin_cflags} // () );
197 my @bin_cflags_no_inst = ( $target{no_inst_bin_cflags} // @bin_cflags );
198 my @bin_cflags_cont = ( @{$config{bin_cflags}},
199 @cnf_cflags, '$(CFLAGS)');
200 our $bin_cflags = join('', @bin_cflags, @bin_cflags_cont );
201 our $bin_cflags_no_inst = join('', @bin_cflags_no_inst, @bin_cflags_cont );
202 our $bin_ldflags =
203 join('', $target{bin_lflags} || (),
204 @{$config{bin_lflags}},
205 @cnf_ldflags, '$(LDFLAGS)');
206 our $bin_ex_libs = join('', @cnf_ex_libs, '$(EX_LIBS)');
207
208 # These are horrible hacks, but are needed because recursive inclusion of
209 # files in different directories does not work well with VMS C. We try to
210 # help by specifying extra relative directories. They must always be in Unix
211 # format, relative to the directory where the .c file is located. The logic
212 # is that any inclusion, merged with one of these relative directories, will
213 # find the requested inclusion file.
214 # In the regexps, it's advisable to always start the file name with .*?, as
215 # the C source to OBJ file translation adds stuff at the beginning of the,
216 # name, such as [.ssl]bio_ssl.c -> [.ssl]libssl-shlib-bio_ssl.OBJ
217 foreach (grep /\[\.crypto\.async\.arch\].*?\.o$/, keys %{$unified_info{sources}}) {
218 my $obj = platform->obj($_);
219 push @{$unified_info{includes_extra}->{$obj}}, qw(../);
220 }
221 foreach (grep /\[\.crypto\.ec\.curve448\].*?\.o$/, keys %{$unified_info{sources}}) {
222 my $obj = platform->obj($_);
223 push @{$unified_info{includes_extra}->{$obj}}, qw(./arch_32 ./arch64);
224 }
225 foreach (grep /\[\.crypto\.ec\.curve448.arch_(?:32|64)\].*?\.o$/, keys %{$unified_info{sources}}) {
226 my $obj = platform->obj($_);
227 push @{$unified_info{includes_extra}->{$obj}}, qw(../);
228 }
229 foreach (grep /\[\.ssl\].*?\.o$/, keys %{$unified_info{sources}}) {
230 my $obj = platform->obj($_);
231 # Most of the files in [.ssl] include "ssl_local.h" which includes things
232 # like "record/record.h". Adding "./" as an inclusion directory helps
233 # making this sort of header from these directories.
234 push @{$unified_info{includes_extra}->{$obj}}, qw(./);
235
236 # Additionally, an increasing amount of files in [.ssl] include
237 # "quic/quic_local.h", which in turn includes "../ssl_local.h". Adding
238 # "./quic" as an inclusion directory helps making this sort of header
239 # from these directories.
240 push @{$unified_info{includes_extra}->{$obj}}, qw(./quic);
241 }
242 foreach (grep /\[\.ssl\.(?:quic|record|statem|rio)\].*?\.o$/, keys %{$unified_info{sources}}) {
243 my $obj = platform->obj($_);
244 # Most of the files in [.ssl.record] and [.ssl.statem] include
245 # "../ssl_local.h", which includes things like "record/record.h".
246 # Adding "../" as an inclusion directory helps making this sort of header
247 # from these directories.
248 push @{$unified_info{includes_extra}->{$obj}}, qw(../);
249
250 }
251 foreach (grep /\[\.ssl\.record\.methods\].*?\.o$/, keys %{$unified_info{sources}}) {
252 my $obj = platform->obj($_);
253 # Most of the files in [.ssl.record.methods] include "../../ssl_local.h"
254 # which includes things like "record/record.h". Adding "../../" as an
255 # inclusion directory helps making this sort of header from these
256 # directories. But this gets worse; through a series of inclusions,
257 # all of them based on the relative directory of the object file, there's
258 # a need to deal with an inclusion of "../ssl_local.h" as well.
259 push @{$unified_info{includes_extra}->{$obj}}, qw(../../), qw(../);
260 }
261 foreach (grep /\[\.test\].*?\.o$/, keys %{$unified_info{sources}}) {
262 my $obj = platform->obj($_);
263 push @{$unified_info{includes_extra}->{$obj}}, qw(../ssl ./helpers);
264 # Some of the sources in [.test] also include headers like
265 # "../ssl/record/methods/recmethod_local.h", which in turn might include
266 # "../../ssl_local.h", so these object files need yet another hack.
267 # We could make this specific to just the object files that are affected
268 # directly, but that would end up with more whack-a-mole of this sort, so
269 # nah, we do it broadly.
270 push @{$unified_info{includes_extra}->{$obj}}, qw(../ssl/record/methods);
271 # Similarly, some include "../ssl/ssl_local.h", and somewhere down the
272 # line, "quic/quic_local.h" gets included, which includes "../ssl_local.h"
273 # The problem is fixed by adding ../ssl/quic too.
274 push @{$unified_info{includes_extra}->{$obj}}, qw(../ssl/quic);
275 }
276 foreach (grep /\[\.test\.helpers\].*?\.o$/, keys %{$unified_info{sources}}) {
277 my $obj = platform->obj($_);
278 push @{$unified_info{includes_extra}->{$obj}},
279 qw(../../ssl ../../ssl/quic);
280 }
281
282 # This makes sure things get built in the order they need
283 # to. You're welcome.
284 sub dependmagic {
285 my $target = shift;
286
287 return "$target : build_generated\n\t\pipe \$(MMS) \$(MMSQUALIFIERS) depend && \$(MMS) \$(MMSQUALIFIERS) _$target\n_$target";
288 }
289 "";
290 -}
291 PLATFORM={- $config{target} -}
292 OPTIONS={- $config{options} -}
293 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
294 SRCDIR={- $config{sourcedir} -}
295 BLDDIR={- $config{builddir} -}
296 FIPSKEY={- $config{FIPSKEY} -}
297
298 # Allow both V and VERBOSE to indicate verbosity. This only applies
299 # to testing.
300 VERBOSE=$(V)
301 VERBOSE_FAILURE=$(VF)
302
303 VERSION={- "$config{full_version}" -}
304 VERSION_NUMBER={- "$config{version}" -}
305 MAJOR={- $config{major} -}
306 MINOR={- $config{minor} -}
307 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
308 SHLIB_TARGET={- $target{shared_target} -}
309
310 LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @libs) -}
311 SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
312 MODULES={- join(", ", map { "-\n\t".$_.".EXE" }
313 # Drop all modules that are dependencies, they will
314 # be processed through their dependents
315 grep { my $x = $_;
316 !grep { grep { $_ eq $x } @$_ }
317 values %{$unified_info{depends}} }
318 @{$unified_info{modules}}) -}
319 FIPSMODULE={- # We do some extra checking here, as there should be only one
320 use File::Basename;
321 our @fipsmodules =
322 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
323 && $unified_info{attributes}->{modules}->{$_}->{fips} }
324 @{$unified_info{modules}};
325 die "More that one FIPS module" if scalar @fipsmodules > 1;
326 join(" ", map { platform->dso($_) } @fipsmodules) -}
327 FIPSMODULENAME={- die "More that one FIPS module" if scalar @fipsmodules > 1;
328 join(", ", map { basename(platform->dso($_)) } @fipsmodules) -}
329 PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -}
330 SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
331 {- output_off() if $disabled{makedepend}; "" -}
332 DEPS={- our @deps = map { platform->isobj($_) ? platform->dep($_) : $_ }
333 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
334 keys %{$unified_info{sources}};
335 join(", ", map { "-\n\t".$_ } @deps); -}
336 {- output_on() if $disabled{makedepend}; "" -}
337 GENERATED_MANDATORY={- join(", ",
338 map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
339 GENERATED_PODS={- # common0.tmpl provides @generated
340 join(", ",
341 map { my $x = $_;
342 (
343 grep {
344 $unified_info{attributes}->{depends}
345 ->{$x}->{$_}->{pod} // 0
346 }
347 keys %{$unified_info{attributes}->{depends}->{$x}}
348 ) ? "-\n\t".$x : ();
349 }
350 @generated) -}
351 GENERATED={- # common0.tmpl provides @generated
352 join(", ", map { platform->convertext($_) } @generated) -}
353
354 INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
355 INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
356 INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @install_engines) -}
357 INSTALL_MODULES={- join(", ", map { "-\n\t".$_.".EXE" } @install_modules) -}
358 INSTALL_FIPSMODULE={- join(", ", map { "-\n\t".$_.".EXE" } @install_fipsmodules) -}
359 INSTALL_FIPSMODULECONF=[.providers]fipsmodule.cnf
360 INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @install_programs) -}
361 BIN_SCRIPTS={- join(", ", @install_bin_scripts) -}
362 MISC_SCRIPTS={- join(", ", @install_misc_scripts) -}
363 HTMLDOCS1={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man1}}) -}
364 HTMLDOCS3={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man3}}) -}
365 HTMLDOCS5={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man5}}) -}
366 HTMLDOCS7={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man7}}) -}
367
368 APPS_OPENSSL="{- use File::Spec::Functions;
369 catfile("apps","openssl") -}"
370
371 # DESTDIR is for package builders so that they can configure for, say,
372 # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
373 # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
374 # MMS with /MACROS=(DESTDIR=STAGING:[USER]). The result will end up in
375 # STAGING:[USER.OPENSSL].
376 # Normally it is left empty.
377 DESTDIR=
378
379 # Do not edit this manually. Use Configure --prefix=DIR to change this!
380 INSTALLTOP={- our $installtop =
381 catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
382 $installtop -}
383 SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
384 # This is the standard central area to store certificates, private keys...
385 OPENSSLDIR={- catdir($config{openssldir}) or
386 $config{prefix} ? catdir($config{prefix},"COMMON")
387 : "SYS\$COMMON:[OPENSSL-COMMON]" -}
388 # The same, but for C
389 OPENSSLDIR_C={- platform->osslprefix() -}DATAROOT:[000000]
390 # Where installed ENGINE modules reside, for C
391 ENGINESDIR_C={- platform->osslprefix() -}ENGINES{- $sover_dirname.$target{pointer_size} -}:
392 # Where modules reside, for C
393 MODULESDIR_C={- platform->osslprefix() -}MODULES{- $target{pointer_size} -}:
394
395 ##### User defined commands and flags ################################
396
397 CC={- $config{CC} -}
398 CPP={- $config{CPP} -}
399 DEFINES={- our $defines = join('', map { ",$_" } @{$config{CPPDEFINES}}) -}
400 #INCLUDES={- our $includes = join(',', @{$config{CPPINCLUDES}}) -}
401 CPPFLAGS={- our $cppflags = join('', @{$config{CPPFLAGS}}) -}
402 CFLAGS={- join('', @{$config{CFLAGS}}) -}
403 LDFLAGS={- join('', @{$config{LFLAGS}}) -}
404 EX_LIBS={- join('', map { ",$_" } @{$config{LDLIBS}}) -}
405
406 PERL={- $config{PERL} -}
407
408 AS={- $config{AS} -}
409 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
410
411 ##### Special command flags ##########################################
412
413 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
414
415 PERLASM_SCHEME={- $target{perlasm_scheme} -}
416
417 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
418 CPPFLAGS_Q={- (my $c = $lib_cppflags.$cppflags) =~ s|"|""|g;
419 (my $d = $lib_cppdefines) =~ s|"|""|g;
420 my $i = join(',', @lib_cppincludes || (), '$(INCLUDES)');
421 my $x = $c;
422 $x .= "/INCLUDE=($i)" if $i;
423 $x .= "/DEFINE=($d)" if $d;
424 $x; -}
425
426 # .FIRST and .LAST are special targets with MMS and MMK.
427 NODEBUG=@
428 .FIRST :
429 {- join( "\n \$(NODEBUG) ", @{ $target{setup_commands} // [] },
430 '!' ) -}
431 $(NODEBUG) sourcetop = F$PARSE("$(SRCDIR)","[]A.;",,,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
432 $(NODEBUG) DEFINE ossl_sourceroot 'sourcetop'
433 $(NODEBUG) !
434 $(NODEBUG) staging_dir = "$(DESTDIR)"
435 $(NODEBUG) staging_instdir = ""
436 $(NODEBUG) staging_datadir = ""
437 $(NODEBUG) IF staging_dir .NES. "" THEN -
438 staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
439 $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
440 staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
441 $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
442 staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
443 $(NODEBUG) IF staging_dir .NES. "" THEN -
444 staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
445 $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
446 staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
447 $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
448 staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
449 $(NODEBUG) !
450 $(NODEBUG) ! Installation logical names
451 $(NODEBUG) !
452 $(NODEBUG) ! This also creates a few DCL variables that are used for
453 $(NODEBUG) ! the "install_msg" target.
454 $(NODEBUG) !
455 $(NODEBUG) installroot = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;"
456 $(NODEBUG) installtop = installroot + ".]"
457 $(NODEBUG) dataroot = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;"
458 $(NODEBUG) datatop = dataroot + ".]"
459 $(NODEBUG) DEFINE ossl_installroot 'installtop'
460 $(NODEBUG) DEFINE ossl_dataroot 'datatop'
461 $(NODEBUG) !
462 $(NODEBUG) ! Override disturbing system logicals. We can't deassign
463 $(NODEBUG) ! them, so we create it instead. This is an unfortunate
464 $(NODEBUG) ! necessity.
465 $(NODEBUG) !
466 $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
467 $(NODEBUG) openssl_inc2 = F$PARSE("sourcetop:[include.openssl]","A.;",,,"SYNTAX_ONLY") - "A.;"
468 $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
469 $(NODEBUG) !
470 $(NODEBUG) ! Figure out the architecture
471 $(NODEBUG) !
472 $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
473 $(NODEBUG) !
474 $(NODEBUG) ! Set up logical names for the libraries, so LINK and
475 $(NODEBUG) ! running programs can use them.
476 $(NODEBUG) !
477 $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_).".EXE" } @shlibs) || "!" -}
478
479 .LAST :
480 $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -}
481 $(NODEBUG) DEASSIGN openssl
482 $(NODEBUG) DEASSIGN ossl_dataroot
483 $(NODEBUG) DEASSIGN ossl_installroot
484 $(NODEBUG) DEASSIGN ossl_sourceroot
485 .DEFAULT :
486 @ ! MMS cannot handle no actions...
487
488 # The main targets ###################################################
489
490 {- dependmagic('build_sw'); -} : build_libs_nodep, build_modules_nodep, build_programs_nodep
491 {- dependmagic('build_libs'); -} : build_libs_nodep
492 {- dependmagic('build_modules'); -} : build_modules_nodep
493 {- dependmagic('build_programs'); -} : build_programs_nodep
494
495 build_generated_pods : $(GENERATED_PODS)
496 build_docs : build_html_docs
497 build_html_docs : $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
498
499 build_generated : $(GENERATED_MANDATORY)
500 build_libs_nodep : $(LIBS), $(SHLIBS)
501 build_modules_nodep : $(MODULES)
502 build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
503
504 # Kept around for backward compatibility
505 build_apps build_tests : build_programs
506
507 # Convenience target to prebuild all generated files, not just the mandatory
508 # ones
509 build_all_generated : $(GENERATED_MANDATORY) $(GENERATED) build_docs
510 @ ! {- output_off() if $disabled{makedepend}; "" -}
511 @ WRITE SYS$OUTPUT "Warning: consider configuring with no-makedepend, because if"
512 @ WRITE SYS$OUTPUT " target system doesn't have $(PERL),"
513 @ WRITE SYS$OUTPUT " then make will fail..."
514 @ ! {- output_on() if $disabled{makedepend}; "" -}
515
516 all : build_sw build_docs
517
518 test : tests
519 {- dependmagic('tests'); -} : build_programs_nodep, build_modules_nodep
520 $(MMS) $(MMSQUALIFIERS) run_tests
521 run_tests :
522 @ ! {- output_off() if $disabled{tests}; "" -}
523 DEFINE SRCTOP "$(SRCDIR)"
524 DEFINE BLDTOP "$(BLDDIR)"
525 DEFINE FIPSKEY "$(FIPSKEY)"
526 IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
527 $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
528 DEASSIGN BLDTOP
529 DEASSIGN SRCTOP
530 DEASSIGN FIPSKEY
531 @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
532 @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
533 @ ! {- output_on() if !$disabled{tests}; "" -}
534
535 list-tests :
536 @ ! {- output_off() if $disabled{tests}; "" -}
537 @ DEFINE SRCTOP "$(SRCDIR)"
538 @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
539 @ DEASSIGN SRCTOP
540 @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
541 @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
542 @ ! {- output_on() if !$disabled{tests}; "" -}
543
544 install : install_sw install_ssldirs install_docs {- $disabled{fips} ? "" : "install_fips" -} install_msg
545
546 install_msg :
547 @ WRITE SYS$OUTPUT ""
548 @ WRITE SYS$OUTPUT "######################################################################"
549 @ WRITE SYS$OUTPUT ""
550 @ IF "$(DESTDIR)" .EQS. "" THEN -
551 @{- sourcefile("VMS", "msg_install.com") -} "$(SYSTARTUP)" "{- $osslver -}"
552 @ IF "$(DESTDIR)" .NES. "" THEN -
553 @{- sourcefile("VMS", "msg_staging.com") -} -
554 "''installroot']" "''dataroot']" "$(INSTALLTOP)" "$(OPENSSLDIR)" -
555 "$(SYSTARTUP)" "{- $osslver -}"
556
557 check_install :
558 spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
559
560 uninstall : uninstall_docs uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -}
561
562 # Because VMS wants the generation number (or *) to delete files, we can't
563 # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(MODULES) directly.
564 libclean :
565 {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
566 {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
567
568 clean : libclean
569 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man1}}) || "@ !" -}
570 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man3}}) || "@ !" -}
571 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man5}}) || "@ !" -}
572 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man7}}) || "@ !" -}
573 {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
574 {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{modules}}) || "@ !" -}
575 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
576 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -}
577 {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
578 - DELETE [...]*.MAP;*
579 - DELETE [...]*.D;*
580 - DELETE [...]*.OBJ;*,*.LIS;*
581 - DELETE []CXX$DEMANGLER_DB.;*
582 - DELETE [.VMS]openssl_startup.com;*
583 - DELETE [.VMS]openssl_shutdown.com;*
584 - DELETE []vmsconfig.pm;*
585
586 distclean : clean
587 - DELETE [.include.openssl]configuration.h;*
588 - DELETE configdata.pm;*
589 - DELETE descrip.mms;*
590
591 depend : descrip.mms
592 @ ! {- output_off() if $disabled{makedepend}; "" -}
593 @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "{- $config{makedep_scheme} -}"
594 @ ! {- output_on() if $disabled{makedepend}; "" -}
595
596 # Install helper targets #############################################
597
598 install_sw : install_dev install_engines install_modules -
599 install_runtime install_startup install_ivp
600
601 uninstall_sw : uninstall_dev uninstall_modules uninstall_engines -
602 uninstall_runtime uninstall_startup uninstall_ivp
603
604 install_docs : install_html_docs
605
606 uninstall_docs : uninstall_html_docs
607
608 {- output_off() if $disabled{fips}; "" -}
609 install_fips : build_sw $(INSTALL_FIPSMODULECONF)
610 @ WRITE SYS$OUTPUT "*** Installing FIPS module"
611 - CREATE/DIR ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']
612 - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
613 COPY/PROT=W:RE $(INSTALL_FIPSMODULES) -
614 ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']$(FIPSMODULENAME)
615 @ WRITE SYS$OUTPUT "*** Installing FIPS module configuration"
616 COPY/PROT=W:RE $(INSTALL_FIPSMODULECONF) OSSL_DATAROOT:[000000]
617
618 uninstall_fips :
619 @ WRITE SYS$OUTPUT "*** Uninstalling FIPS module configuration"
620 DELETE OSSL_DATAROOT:[000000]fipsmodule.cnf;*
621 @ WRITE SYS$OUTPUT "*** Uninstalling FIPS module"
622 DELETE ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']$(FIPSMODULENAME);*
623 {- output_on() if $disabled{fips}; "" -}
624
625 install_ssldirs : check_INSTALLTOP
626 - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
627 IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
628 CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
629 IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
630 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
631 IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
632 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
633 COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
634 @ ! Install configuration file
635 COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
636 ossl_dataroot:[000000]openssl.cnf-dist
637 IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN -
638 COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
639 ossl_dataroot:[000000]openssl.cnf
640 @ ! Install CTLOG configuration file
641 COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
642 ossl_dataroot:[000000]ct_log_list.cnf-dist
643 IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN -
644 COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
645 ossl_dataroot:[000000]ct_log_list.cnf
646
647 install_dev : check_INSTALLTOP install_runtime_libs
648 @ WRITE SYS$OUTPUT "*** Installing development files"
649 @ ! Install header files
650 - CREATE/DIR ossl_installroot:[include.openssl]
651 COPY/PROT=W:R ossl_sourceroot:[include.openssl]*.h -
652 ossl_installroot:[include.openssl]
653 COPY/PROT=W:R [.include.openssl]*.h ossl_installroot:[include.openssl]
654 @ ! Install static (development) libraries
655 - CREATE/DIR ossl_installroot:[LIB.'arch']
656 {- join("\n ",
657 map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
658 @install_libs) -}
659
660 install_engines : check_INSTALLTOP install_runtime_libs build_modules
661 @ {- output_off() unless scalar @install_engines; "" -} !
662 @ WRITE SYS$OUTPUT "*** Installing engines"
663 - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
664 {- join("\n ",
665 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
666 @install_engines) -}
667 @ {- output_on() unless scalar @install_engines; "" -} !
668
669 install_modules : check_INSTALLTOP install_runtime_libs build_modules
670 @ {- output_off() unless scalar @install_modules; "" -} !
671 @ WRITE SYS$OUTPUT "*** Installing modules"
672 - CREATE/DIR ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']
673 {- join("\n ",
674 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[MODULES$target{pointer_size}.'arch']" }
675 @install_modules) -}
676 @ {- output_on() unless scalar @install_modules; "" -} !
677
678 install_runtime : install_programs
679
680 install_runtime_libs : check_INSTALLTOP build_libs
681 @ {- output_off() if $disabled{shared}; "" -} !
682 @ WRITE SYS$OUTPUT "*** Installing shareable images"
683 @ ! Install shared (runtime) libraries
684 - CREATE/DIR ossl_installroot:[LIB.'arch']
685 {- join("\n ",
686 map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
687 @install_shlibs) -}
688 @ {- output_on() if $disabled{shared}; "" -} !
689
690 install_programs : check_INSTALLTOP install_runtime_libs build_programs
691 @ {- output_off() if $disabled{apps}; "" -} !
692 @ ! Install the main program
693 - CREATE/DIR ossl_installroot:[EXE.'arch']
694 COPY/PROT=W:RE [.APPS]openssl.EXE -
695 ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
696 @ ! Install scripts
697 COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
698 @ ! {- output_on() if $disabled{apps}; "" -}
699
700 install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
701 [.VMS]openssl_utils.com, check_INSTALLTOP
702 - CREATE/DIR ossl_installroot:[SYS$STARTUP]
703 COPY/PROT=W:RE [.VMS]openssl_startup.com -
704 ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com
705 COPY/PROT=W:RE [.VMS]openssl_shutdown.com -
706 ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com
707 COPY/PROT=W:RE [.VMS]openssl_utils.com -
708 ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com
709
710 install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
711 - CREATE/DIR ossl_installroot:[SYSTEST]
712 COPY/PROT=W:RE [.VMS]openssl_ivp.com -
713 ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
714
715 [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
716 - CREATE/DIR [.VMS]
717 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
718 {- sourcefile("VMS", "openssl_startup.com.in") -} -
719 > [.VMS]openssl_startup.com
720
721 [.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -}
722 - CREATE/DIR [.VMS]
723 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
724 {- sourcefile("VMS", "openssl_utils.com.in") -} -
725 > [.VMS]openssl_utils.com
726
727 [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
728 - CREATE/DIR [.VMS]
729 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
730 {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
731 > [.VMS]openssl_shutdown.com
732
733 [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -}
734 - CREATE/DIR [.VMS]
735 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
736 {- sourcefile("VMS", "openssl_ivp.com.in") -} -
737 > [.VMS]openssl_ivp.com
738
739 vmsconfig.pm : configdata.pm
740 OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
741 WRITE CONFIG "package vmsconfig;"
742 WRITE CONFIG "use strict; use warnings;"
743 WRITE CONFIG "use Exporter;"
744 WRITE CONFIG "our @ISA = qw(Exporter);"
745 WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
746 WRITE CONFIG "our %config = ("
747 WRITE CONFIG " target => '","{- $config{target} -}","',"
748 WRITE CONFIG " version => '","{- $config{version} -}","',"
749 WRITE CONFIG " shlib_version => '","{- $config{shlib_version} -}","',"
750 WRITE CONFIG " shlib_major => '","{- $config{shlib_major} -}","',"
751 WRITE CONFIG " shlib_minor => '","{- $config{shlib_minor} -}","',"
752 WRITE CONFIG " INSTALLTOP => '$(INSTALLTOP)',"
753 WRITE CONFIG " OPENSSLDIR => '$(OPENSSLDIR)',"
754 WRITE CONFIG ");"
755 WRITE CONFIG "our %target = ("
756 WRITE CONFIG " pointer_size => '","{- $target{pointer_size} -}","',"
757 WRITE CONFIG ");"
758 WRITE CONFIG "our %disabled = ("
759 WRITE CONFIG " shared => '","{- $disabled{shared} -}","',"
760 WRITE CONFIG ");"
761 WRITE CONFIG "our %withargs = ();"
762 WRITE CONFIG "our %unified_info = ();"
763 WRITE CONFIG "1;"
764 CLOSE CONFIG
765
766 install_html_docs : check_INSTALLTOP build_html_docs
767 @ WRITE SYS$OUTPUT "*** Installing HTML docs"
768 - CREATE/DIR ossl_installroot:[HTML.MAN1]
769 - CREATE/DIR ossl_installroot:[HTML.MAN3]
770 - CREATE/DIR ossl_installroot:[HTML.MAN5]
771 - CREATE/DIR ossl_installroot:[HTML.MAN7]
772 {- join("\n ",
773 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN1]" }
774 @{$unified_info{htmldocs}->{man1}} ),
775 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN3]" }
776 @{$unified_info{htmldocs}->{man3}} ),
777 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN5]" }
778 @{$unified_info{htmldocs}->{man5}} ),
779 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN7]" }
780 @{$unified_info{htmldocs}->{man7}} )) -}
781
782 check_INSTALLTOP :
783 @ IF "$(INSTALLTOP)" .EQS. "" THEN -
784 WRITE SYS$ERROR "INSTALLTOP should not be empty"
785 @ IF "$(INSTALLTOP)" .EQS. "" THEN -
786 EXIT %x10000002
787
788 # Developer targets ##################################################
789
790 debug_logicals :
791 SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
792
793 # Building targets ###################################################
794
795 descrip.mms : configdata.pm {- join(" ", @{$config{build_file_templates}}) -}
796 perl configdata.pm
797 @ WRITE SYS$OUTPUT "*************************************************"
798 @ WRITE SYS$OUTPUT "*** ***"
799 @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***"
800 @ WRITE SYS$OUTPUT "*** ***"
801 @ WRITE SYS$OUTPUT "*************************************************"
802 @ PIPE ( EXIT %X10000000 )
803
804 configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_infos}}, @{$config{conf_files}}) -}
805 perl configdata.pm -r
806 @ WRITE SYS$OUTPUT "*************************************************"
807 @ WRITE SYS$OUTPUT "*** ***"
808 @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***"
809 @ WRITE SYS$OUTPUT "*** ***"
810 @ WRITE SYS$OUTPUT "*************************************************"
811 @ PIPE ( EXIT %X10000000 )
812
813 reconfigure reconf :
814 perl configdata.pm -r
815
816 {-
817 use File::Basename;
818 use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
819 use File::Spec::Unix;
820
821 # Helper function to convert dependencies in platform agnostic form to
822 # dependencies in platform form.
823 sub compute_platform_depends {
824 map { my $x = $_;
825
826 grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x)
827 or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x)
828 or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x)
829 or platform->convertext($x); } @_;
830 }
831
832 # Helper function to figure out dependencies on libraries
833 # It takes a list of library names and outputs a list of dependencies
834 sub compute_lib_depends {
835 # Depending on shared libraries:
836 # On Windows POSIX layers, we depend on {libname}.dll.a
837 # On Unix platforms, we depend on {shlibname}.so
838 return map {
839 { lib => platform->sharedlib($_) // platform->staticlib($_),
840 attrs => $unified_info{attributes}->{libraries}->{$_} }
841 } @_;
842 }
843
844 # Helper function to deal with inclusion directory specs.
845 # We're dealing with two issues:
846 # 1. A lot of include directory specs take up a lot of command line real
847 # estate, and the DCL command line is very limited (2KiB).
848 # 2. For optimal usage, include directory paths must be in Unix form,
849 # that's the only way the C compiler can merge multiple include paths
850 # in a sane way (we can stop worrying about 1.h including foo/2.h
851 # including ../3.h).
852 #
853 # To resolve 1, we need to create a file with include directory pragmas,
854 # and let the compiler use it with /FIRST_INCLUDE=.
855 # To resolve 2, we convert all include directory specs we get to Unix,
856 # with available File::Spec functions.
857 #
858 # We use CRC-24 from https://tools.ietf.org/html/rfc4880#section-6,
859 # reimplemented in Perl to get a workable and constant file name for each
860 # combination of include directory specs. It is assumed that the order of
861 # these directories don't matter.
862 #
863 # This function takes as input a list of include directories
864 # This function returns a list two things:
865 # 1. The file name to use with /FIRST_INCLUDE=
866 # 2. Text to insert into descrip.mms (may be the empty string)
867 sub crc24 {
868 my $input = shift;
869
870 my $init_value = 0x00B704CE;
871 my $poly_value = 0x01864CFB;
872
873 my $crc = $init_value;
874
875 foreach my $x (unpack ('C*', $input)) {
876 $crc ^= $x << 16;
877
878 for (my $i; $i < 8; $i++) {
879 $crc <<= 1;
880 if ($crc & 0x01000000) {
881 $crc ^= $poly_value;
882 }
883 }
884 }
885 $crc &= 0xFFFFFF;
886
887 return $crc;
888 }
889 my %includefile_cache;
890 sub make_includefile {
891 my %dirs = map {
892 my $udir = make_unix_path(rel2abs($_));
893
894 $udir => 1;
895 } @_;
896 my @dirs = sort keys %dirs;
897 my $filename = sprintf 'incdirs_%x.h', crc24(join(',', @dirs));
898
899 if ($includefile_cache{$filename}) {
900 return ($filename, "");
901 }
902
903 my $scripture = <<"EOF";
904 $filename :
905 open/write inc_output $filename
906 EOF
907 foreach (@dirs) {
908 $scripture .= <<"EOF";
909 write inc_output "#pragma include_directory ""$_"""
910 EOF
911 }
912 $scripture .= <<"EOF";
913 close inc_output
914 EOF
915 $includefile_cache{$filename} = $scripture;
916
917 return ($filename, $scripture);
918 }
919
920 # On VMS, (some) header file directories include the files
921 # __DECC_INCLUDE_EPILOGUE.H and __DECC_INCLUDE_PROLOGUE.H.
922 # When header files are generated, and the build directory
923 # isn't the same as the source directory, these files must
924 # be copied alongside the generated header file, or their
925 # effect will be lost.
926 # We use the same include file cache as make_includefile
927 # to check if the scripture to copy these files has already
928 # been generated.
929 sub make_decc_include_files {
930 my $outd = shift;
931 my $ind = shift;
932
933 # If the build directory and the source directory are the
934 # same, there's no need to copy the prologue and epilogue
935 # files.
936 return ('') if $outd eq $ind;
937
938 my $outprologue = catfile($outd, '__DECC_INCLUDE_PROLOGUE.H');
939 my $outepilogue = catfile($outd, '__DECC_INCLUDE_EPILOGUE.H');
940 my $inprologue = catfile($ind, '__DECC_INCLUDE_PROLOGUE.H');
941 my $inepilogue = catfile($ind, '__DECC_INCLUDE_EPILOGUE.H');
942 my @filenames = ();
943 my $scripture = '';
944
945 if ($includefile_cache{$outprologue}) {
946 push @filenames, $outprologue;
947 } elsif (-f $inprologue) {
948 my $local_scripture .= <<"EOF";
949 $outprologue : $inprologue
950 COPY $inprologue $outprologue
951 EOF
952 $includefile_cache{$outprologue} = $local_scripture;
953
954 push @filenames, $outprologue;
955 $scripture .= $local_scripture;
956 }
957 if ($includefile_cache{$outepilogue}) {
958 push @filenames, $outepilogue;
959 } elsif (-f $inepilogue) {
960 my $local_scripture .= <<"EOF";
961 $outepilogue : $inepilogue
962 COPY $inepilogue $outepilogue
963 EOF
964 $includefile_cache{$outepilogue} = $local_scripture;
965
966 push @filenames, $outepilogue;
967 $scripture .= $local_scripture;
968 }
969
970 return (@filenames, $scripture);
971 }
972
973 sub generatetarget {
974 my %args = @_;
975 my $deps = join(" ", compute_platform_depends(@{$args{deps}}));
976 return <<"EOF";
977 $args{target} : $deps
978 EOF
979 }
980
981 sub generatesrc {
982 my %args = @_;
983 my $gen0 = $args{generator}->[0];
984 my $gen_args = join('', map { " $_" }
985 @{$args{generator}}[1..$#{$args{generator}}]);
986 my $gen_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
987 my $deps = join(", -\n\t\t",
988 compute_platform_depends(@{$args{generator_deps}},
989 @{$args{deps}}));
990
991 if ($args{src} =~ /\.html$/) {
992 #
993 # HTML generator
994 #
995 my $title = basename($args{src}, ".html");
996 my $pod = $gen0;
997 my $mkpod2html = sourcefile('util', 'mkpod2html.pl');
998 my $srcdoc = sourcedir('doc');
999 return <<"EOF";
1000 $args{src} : $pod
1001 \$(PERL) $mkpod2html -i $pod -o \$\@ -t "$title" -r "$srcdoc"
1002 EOF
1003 } elsif ($args{src} =~ /\.(\d)$/) {
1004 #
1005 # Man-page generator, on VMS we simply ignore man-pages
1006 #
1007 return "";
1008 } elsif (platform->isdef($args{src})) {
1009 #
1010 # Linker script-ish generator
1011 #
1012 my $target = platform->def($args{src});
1013 my $mkdef = sourcefile('util', 'mkdef.pl');
1014 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
1015 my $ord_name =
1016 $args{generator}->[1] || basename($args{product}, '.EXE');
1017 my $case_insensitive =
1018 $target{$args{intent}.'_cflags'} =~ m|/NAMES=[^/]*AS_IS|i
1019 ? '' : ' --case-insensitive';
1020 return <<"EOF";
1021 $target : $gen0 $deps $mkdef
1022 \$(PERL) $mkdef$ord_ver --type $args{intent} --ordinals $gen0 --name $ord_name "--OS" "VMS"$case_insensitive > $target
1023 EOF
1024 } elsif (platform->isasm($args{src})
1025 || platform->iscppasm($args{src})) {
1026 #
1027 # Assembler generator
1028 #
1029 my $cppflags =
1030 { shlib => "$lib_cflags $lib_cppflags",
1031 lib => "$lib_cflags $lib_cppflags",
1032 dso => "$dso_cflags $dso_cppflags",
1033 bin => "$bin_cflags $bin_cppflags" } -> {$args{intent}};
1034 my $defs = join("", map { ",".$_ } @{$args{defs}});
1035 my $target = platform->isasm($args{src})
1036 ? platform->asm($args{src})
1037 : $args{src};
1038
1039 my $generator;
1040 if ($gen0 =~ /\.pl$/) {
1041 $generator = '$(PERL)'.$gen_incs.' '.$gen0.$gen_args
1042 .' '.$cppflags;
1043 } elsif ($gen0 =~ /\.S$/) {
1044 $generator = undef;
1045 } else {
1046 die "Generator type for $src unknown: $gen0.$gen_args\n";
1047 }
1048
1049 if (defined($generator)) {
1050 return <<"EOF";
1051 $target : $gen0 $deps
1052 \@ extradefines = "$defs"
1053 $generator \$\@
1054 \@ DELETE/SYMBOL/LOCAL extradefines
1055 EOF
1056 }
1057 return <<"EOF";
1058 $target : $gen0 $deps
1059 \@ extradefines = "$defs"
1060 PIPE \$(CPP) $cppflags $gen0 | -
1061 \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@
1062 \@ DELETE/SYMBOL/LOCAL extradefines
1063 EOF
1064 } elsif ($gen0 =~ m|^.*\.in$|) {
1065 #
1066 # "dofile" generator (file.in -> file)
1067 #
1068 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1069 "util", "dofile.pl")),
1070 rel2abs($config{builddir}));
1071 my @perlmodules = ();
1072 my %perlmoduleincs = ();
1073 my %perlmoduledeps = ();
1074 foreach my $x (('configdata.pm', @{$args{deps}})) {
1075 # Compute (i)nclusion directory, (m)odule name and (d)ependency
1076 my $i, $m, $d;
1077 if ($x =~ /\|/) {
1078 $i = $`;
1079 $d = $';
1080
1081 # Massage the module part to become a real perl module spec
1082 $m = $d;
1083 $m =~ s|\.pm$||;
1084 # Directory specs are :: in perl package names
1085 $m =~ s|/|::|g;
1086
1087 # Full file name of the dependency
1088 $d = catfile($i, $d) if $i;
1089 } elsif ($x =~ /\.pm$/) {
1090 $i = dirname($x);
1091 $m = basename($x, '.pm');
1092 $d = $x;
1093 } else {
1094 # All other dependencies are simply collected
1095 $d = $x;
1096 }
1097 push @perlmodules, '"-M'.$m.'"' if $m;
1098 $perlmoduledeps{$d} = 1;
1099 $perlmoduleincs{'"-I'.$i.'"'} = 1 if $i;
1100 }
1101
1102 my @decc_include_data
1103 = make_decc_include_files(dirname($args{src}), dirname($gen0));
1104 my $decc_include_scripture = pop @decc_include_data;
1105 # Because of the special treatment of dependencies, we need to
1106 # recompute $deps completely
1107 my $deps
1108 = join(" ", @decc_include_data,
1109 compute_platform_depends(@{$args{generator_deps}},
1110 sort keys %perlmoduledeps));
1111 my $perlmodules = join(' ', '', ( sort keys %perlmoduleincs ), @perlmodules);
1112
1113
1114 return <<"EOF";
1115 $args{src} : $gen0 $deps
1116 \$(PERL)$perlmodules $dofile "-o$target{build_file}" $gen0$gen_args > \$\@
1117 $decc_include_scripture
1118 EOF
1119 } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
1120 #
1121 # Generic generator using OpenSSL programs
1122 #
1123
1124 # Redo $gen0, to ensure that we have the proper extension
1125 $gen0 = platform->bin($gen0);
1126 return <<"EOF";
1127 $args{src} : $gen0 $deps
1128 PIPE MCR $gen0$gen_args > \$@
1129 EOF
1130 } else {
1131 #
1132 # Generic generator using Perl
1133 #
1134 return <<"EOF";
1135 $args{src} : $gen0 $deps
1136 \$(PERL)$gen_incs $gen0$gen_args > \$\@
1137 EOF
1138 }
1139 }
1140
1141 sub src2obj {
1142 my $asmext = platform->asmext();
1143 my %args = @_;
1144 my @srcs =
1145 map { my $x = $_;
1146 (platform->isasm($x) && grep { $x eq $_ } @generated)
1147 ? platform->asm($x) : $x }
1148 ( @{$args{srcs}} );
1149 my $obj = platform->obj($args{obj});
1150 my $dep = platform->dep($args{obj});
1151 my $deps = join(", -\n\t\t", @srcs, @{$args{deps}});
1152
1153 # Because VMS C isn't very good at combining a /INCLUDE path with
1154 # #includes having a relative directory (like '#include "../foo.h"),
1155 # the best choice is to move to the first source file's intended
1156 # directory before compiling, and make sure to write the object file
1157 # in the correct position (important when the object tree is other
1158 # than the source tree).
1159 my $forward = dirname($args{srcs}->[0]);
1160 my $backward = abs2rel(rel2abs("."), rel2abs($forward));
1161 my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
1162 my $objn = basename($obj);
1163 my $depd = abs2rel(rel2abs(dirname($dep)), rel2abs($forward));
1164 my $depn = basename($dep);
1165 my $srcs =
1166 join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs);
1167 my $incextra = join(',', map { "\"$_\"" }
1168 @{$unified_info{includes_extra}->{$obj}});
1169 $incextra = "/INCLUDE=($incextra)" if $incextra;
1170
1171 my $cflags;
1172 if ($args{attrs}->{noinst}) {
1173 $cflags .= { shlib => $lib_cflags_no_inst,
1174 lib => $lib_cflags_no_inst,
1175 dso => $dso_cflags_no_inst,
1176 bin => $bin_cflags_no_inst } -> {$args{intent}};
1177 } else {
1178 $cflags .= { shlib => $lib_cflags,
1179 lib => $lib_cflags,
1180 dso => $dso_cflags,
1181 bin => $bin_cflags } -> {$args{intent}};
1182 }
1183 $cflags .= { shlib => $lib_cppflags,
1184 lib => $lib_cppflags,
1185 dso => $dso_cppflags,
1186 bin => $bin_cppflags } -> {$args{intent}};
1187 $cflags .= $incextra;
1188 my $defs = join("", map { ",".$_ } @{$args{defs}});
1189 my $asflags = { shlib => $lib_asflags,
1190 lib => $lib_asflags,
1191 dso => $dso_asflags,
1192 bin => $bin_asflags } -> {$args{intent}};
1193
1194 if ($srcs[0] =~ /\Q${asmext}\E$/) {
1195 return <<"EOF";
1196 $obj : $deps
1197 SET DEFAULT $forward
1198 \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn} $srcs
1199 SET DEFAULT $backward
1200 - PURGE $obj
1201 EOF
1202 } elsif ($srcs[0] =~ /.S$/) {
1203 return <<"EOF";
1204 $obj : $deps
1205 SET DEFAULT $forward
1206 \@ $incs_on
1207 \@ extradefines = "$defs"
1208 PIPE \$(CPP) ${cflags} $srcs | -
1209 \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" -
1210 > ${objd}${objn}-asm
1211 \@ DELETE/SYMBOL/LOCAL extradefines
1212 \@ $incs_off
1213 SET DEFAULT $backward
1214 \$(AS) $asflags \$(ASOUTFLAG)$obj $obj-asm
1215 - PURGE $obj
1216 EOF
1217 }
1218
1219 my ($incdir_filename, $incdir_scripture) =
1220 make_includefile(@{ { shlib => [ @lib_cppincludes ],
1221 lib => [ @lib_cppincludes ],
1222 dso => [ @dso_cppincludes ],
1223 bin => [ @bin_cppincludes ] } -> {$args{intent}} },
1224 @{$args{incs}});
1225 $deps .= ", -\n\t\t$incdir_filename";
1226 $cflags =
1227 $target{cflag_incfirst}
1228 . '"'.make_unix_path(rel2abs($incdir_filename)).'"'
1229 . $cflags;
1230
1231 my $depbuild = $disabled{makedepend} ? ""
1232 : " /MMS=(FILE=${depd}${depn},TARGET=$obj)";
1233
1234 return <<"EOF";
1235 $obj : $deps
1236 SET DEFAULT $forward
1237 \@ $incs_on
1238 \@ extradefines = "$defs"
1239 \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn} /REPOSITORY=$backward $srcs
1240 \@ DELETE/SYMBOL/LOCAL extradefines
1241 \@ $incs_off
1242 SET DEFAULT $backward
1243 - PURGE $obj
1244 $incdir_scripture
1245 EOF
1246 }
1247 sub obj2shlib {
1248 my %args = @_;
1249 my $shlibname = platform->sharedname($args{lib});
1250 my $shlib = platform->sharedlib($args{lib});
1251 my @objs = map { platform->convertext($_) }
1252 grep { platform->isobj($_) }
1253 @{$args{objs}};
1254 my @defs = map { platform->convertext($_) }
1255 grep { platform->isdef($_) }
1256 @{$args{objs}};
1257 my @deps = compute_lib_depends(@{$args{deps}});
1258 die "More than one symbol vector" if scalar @defs > 1;
1259 my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
1260 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
1261 my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
1262 "VMS", "translatesyms.pl")),
1263 rel2abs($config{builddir}));
1264 # The "[]" hack is because in .OPT files, each line inherits the
1265 # previous line's file spec as default, so if no directory spec
1266 # is present in the current line and the previous line has one that
1267 # doesn't apply, you're in for a surprise.
1268 my $write_opt1 =
1269 join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1270 "WRITE OPT_FILE \"$x" } @objs).
1271 "\"";
1272 my $write_opt2 =
1273 join("\n\t", map { my $x = $_->{lib} =~ /\[/
1274 ? $_->{lib} : "[]".$_->{lib};
1275 $x =~ s|(\.EXE)|$1/SHARE|;
1276 $x =~ s|(\.OLB)|$1/LIB|;
1277 "WRITE OPT_FILE \"$x\"" } @deps)
1278 || "\@ !";
1279 return <<"EOF"
1280 $shlib : $deps
1281 \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
1282 OPEN/WRITE/SHARE=READ OPT_FILE $shlibname-components.OPT
1283 $write_opt1
1284 $write_opt2
1285 CLOSE OPT_FILE
1286 LINK ${lib_ldflags}/SHARE=\$\@ $defs[0]-translated/OPT,-
1287 $shlibname-components.OPT/OPT \$(LIB_EX_LIBS)
1288 DELETE $defs[0]-translated;*,$shlibname-components.OPT;*
1289 PURGE $shlibname.EXE,$shlibname.MAP
1290 EOF
1291 . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1292 SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1293 EOF
1294 );
1295 }
1296 sub obj2dso {
1297 my %args = @_;
1298 my $dsoname = platform->dsoname($args{module});
1299 my $dso = platform->dso($args{module});
1300 my @objs = map { platform->convertext($_) }
1301 grep { platform->isobj($_) }
1302 @{$args{objs}};
1303 my @defs = map { platform->convertext($_) }
1304 grep { platform->isdef($_) }
1305 @{$args{objs}};
1306 my @deps = compute_lib_depends(@{$args{deps}});
1307 my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
1308 die "More than one symbol vector" if scalar @defs > 1;
1309 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
1310 # The "[]" hack is because in .OPT files, each line inherits the
1311 # previous line's file spec as default, so if no directory spec
1312 # is present in the current line and the previous line has one that
1313 # doesn't apply, you're in for a surprise.
1314 # Furthermore, we collect all object files and static libraries in
1315 # an explicit cluster, to make it clear to the linker that these files
1316 # shall be processed before shareable images.
1317 # The shareable images are used with /SELECTIVE, to avoid warnings of
1318 # multiply defined symbols when the module object files override some
1319 # symbols that are present in the shareable image.
1320 my $write_opt1 =
1321 join(",-\"\n\t",
1322 "\@ WRITE OPT_FILE \"CLUSTER=_,,",
1323 (map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1324 "\@ WRITE OPT_FILE \"$x" } @objs),
1325 (map { my $x = ($_->{lib} =~ /\[/) ? $_->{lib} : "[]".$_->{lib};
1326 "\@ WRITE OPT_FILE \"$x/LIB" }
1327 grep { $_->{lib} =~ m|\.OLB$| }
1328 @deps))
1329 ."\"";
1330 my $write_opt2 =
1331 join("\n\t",
1332 (map { my $x = ($_->{lib} =~ /\[/) ? $_->{lib} : "[]".$_->{lib};
1333 "\@ WRITE OPT_FILE \"$x/SHARE/SELECTIVE\"" }
1334 grep { $_->{lib} =~ m|\.EXE$| }
1335 @deps))
1336 || "\@ !";
1337 return <<"EOF"
1338 $dso : $deps
1339 OPEN/WRITE/SHARE=READ OPT_FILE $dsoname-components.OPT
1340 $write_opt1
1341 $write_opt2
1342 CLOSE OPT_FILE
1343 LINK ${dso_ldflags}/SHARE=\$\@ $defs[0]/OPT,-
1344 $dsoname-components.OPT/OPT \$(DSO_EX_LIBS)
1345 - PURGE $dsoname.EXE,$dsoname.OPT,$dsoname.MAP
1346 EOF
1347 . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1348 SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1349 EOF
1350 );
1351 }
1352 sub obj2lib {
1353 my %args = @_;
1354 my $lib = platform->staticlib($args{lib});
1355 my @objs = map { platform->convertext($_) }
1356 grep { platform->isobj($_) }
1357 @{$args{objs}};
1358 my $objs = join(", -\n\t\t", @objs);
1359 my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib $_" } @objs));
1360 return <<"EOF";
1361 $lib : $objs
1362 LIBRARY/CREATE/OBJECT $lib
1363 $fill_lib
1364 - PURGE $lib
1365 EOF
1366 }
1367 sub obj2bin {
1368 my %args = @_;
1369 my $bin = platform->bin($args{bin});
1370 my $binname = platform->binname($args{bin});
1371 my @objs = map { platform->convertext($_) }
1372 grep { platform->isobj($_) }
1373 @{$args{objs}};
1374 my $objs = join(",", @objs);
1375 my @deps = compute_lib_depends(@{$args{deps}});
1376 my $deps = join(", -\n\t\t", @objs, map { $_->{lib} } @deps);
1377
1378 my $olb_count = scalar grep(m|\.OLB$|, map { $_->{lib} } @deps);
1379 my $analyse_objs = "@ !";
1380 if ($olb_count > 0) {
1381 my $analyse_quals =
1382 $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
1383 $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
1384 }
1385 # The "[]" hack is because in .OPT files, each line inherits the
1386 # previous line's file spec as default, so if no directory spec
1387 # is present in the current line and the previous line has one that
1388 # doesn't apply, you're in for a surprise.
1389 my $write_opt1 =
1390 "\@ WRITE OPT_FILE \"CASE_SENSITIVE=YES\"\n\t"
1391 .join(",-\"\n\t",
1392 "\@ WRITE OPT_FILE \"CLUSTER=_,,",
1393 (map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1394 "\@ WRITE OPT_FILE \"$x" } @objs),
1395 (map { my $x = ($_->{lib} =~ /\[/) ? $_->{lib} : "[]".$_->{lib};
1396 # Special hack to include the MAIN object module
1397 # explicitly, if it's known that there is one.
1398 # |incmain| is defined in the rule generation further
1399 # down, with the necessary /INCLUDE=main option unless
1400 # the program has been determined to have a main function
1401 # already.
1402 $_->{attrs}->{has_main}
1403 ? "\@ WRITE OPT_FILE \"$x/LIB''incmain'"
1404 : "\@ WRITE OPT_FILE \"$x/LIB" }
1405 grep { $_->{lib} =~ m|\.OLB$| }
1406 @deps))
1407 ."\"";
1408 my $write_opt2 =
1409 join("\n\t",
1410 (map { my $x = $_->{lib} =~ /\[/ ? $_->{lib} : "[]".$_->{lib};
1411 "\@ WRITE OPT_FILE \"$x/SHARE/SELECTIVE\"" }
1412 grep { $_->{lib} =~ m|\.EXE$| }
1413 @deps))
1414 || "\@ !";
1415 # The linking commands looks a bit complex, but it's for good reason.
1416 # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
1417 # bar.obj happens to have a symbol that also exists in libsomething.exe,
1418 # the linker will warn about it, loudly, and will then choose to pick
1419 # the first copy encountered (the one in bar.obj in this example).
1420 # On Unix and on Windows, the corresponding maneuver goes through
1421 # silently with the same effect.
1422 # With some test programs, made for checking the internals of OpenSSL,
1423 # we do this kind of linking deliberately, picking a few specific object
1424 # files from within [.crypto] or [.ssl] so we can reach symbols that are
1425 # otherwise unreachable (since the shareable images only exports the
1426 # symbols listed in [.util]*.num), and then with the shared libraries
1427 # themselves. So we need to silence the warning about multiply defined
1428 # symbols, to mimic the way linking work on Unix and Windows, and so
1429 # the build isn't interrupted (MMS stops when warnings are signaled,
1430 # by default), and so someone building doesn't have to worry where it
1431 # isn't necessary. If there are other warnings, however, we show them
1432 # and let it break the build.
1433 return <<"EOF"
1434 $bin : $deps
1435 $analyse_objs
1436 @ incmain = "/INCLUDE=main"
1437 @ IF .NOT. nomain THEN incmain = ""
1438 @ OPEN/WRITE/SHARE=READ OPT_FILE $binname.OPT
1439 $write_opt1
1440 $write_opt2
1441 @ CLOSE OPT_FILE
1442 TYPE $binname.OPT ! For debugging
1443 - pipe SPAWN/WAIT/NOLOG/OUT=$binname.LINKLOG -
1444 LINK ${bin_ldflags}/EXEC=\$\@ $binname.OPT/OPT \$(BIN_EX_LIBS) ; -
1445 link_status = \$status ; link_severity = link_status .AND. 7
1446 @ search_severity = 1
1447 -@ IF link_severity .EQ. 0 THEN -
1448 pipe SEARCH $binname.LINKLOG "%","-"/MATCH=AND | -
1449 SPAWN/WAIT/NOLOG/OUT=NLA0: -
1450 SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
1451 search_severity = \$severity
1452 @ ! search_severity is 3 when the last search didn't find any matching
1453 @ ! string: %SEARCH-I-NOMATCHES, no strings matched
1454 @ ! If that was the result, we pretend linking got through without
1455 @ ! fault or warning.
1456 @ IF search_severity .EQ. 3 THEN link_severity = 1
1457 @ ! At this point, if link_severity shows that there was a fault
1458 @ ! or warning, make sure to restore the linking status.
1459 -@ IF .NOT. link_severity THEN TYPE $binname.LINKLOG
1460 -@ DELETE $binname.LINKLOG;*
1461 @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
1462 - PURGE $bin,$binname.OPT
1463 EOF
1464 . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1465 SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1466 EOF
1467 );
1468 }
1469 sub in2script {
1470 my %args = @_;
1471 my $script = $args{script};
1472 return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
1473 my $sources = join(" ", @{$args{sources}});
1474 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1475 "util", "dofile.pl")),
1476 rel2abs($config{builddir}));
1477 return <<"EOF";
1478 $script : $sources configdata.pm
1479 \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
1480 "-o$target{build_file}" $sources > $script
1481 SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
1482 PURGE $script
1483 EOF
1484 }
1485 "" # Important! This becomes part of the template result.
1486 -}