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