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