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