Fix some minor code nits
[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
7   # Our prefix, claimed when speaking with the VSI folks Tuesday
8   # January 26th 2016
9   our $osslprefix = 'OSSL$';
10   (our $osslprefix_q = $osslprefix) =~ s/\$/\\\$/;
11
12   our $sover_dirname = sprintf "%02d%02d", split(/\./, $config{shlib_version_number});
13   our $osslver = sprintf "%02d%02d", split(/\./, $config{version});
14
15   our $sourcedir = $config{sourcedir};
16   our $builddir = $config{builddir};
17   sub sourcefile {
18       catfile($sourcedir, @_);
19   }
20   sub buildfile {
21       catfile($builddir, @_);
22   }
23   sub sourcedir {
24       catdir($sourcedir, @_);
25   }
26   sub builddir {
27       catdir($builddir, @_);
28   }
29   sub tree {
30       (my $x = shift) =~ s|\]$|...]|;
31       $x
32   }
33   sub move {
34       my $f = catdir(@_);
35       my $b = abs2rel(rel2abs("."),rel2abs($f));
36       $sourcedir = catdir($b,$sourcedir)
37           if !file_name_is_absolute($sourcedir);
38       $builddir = catdir($b,$builddir)
39           if !file_name_is_absolute($builddir);
40       "";
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 { (my $x = $_) =~ s/\.a$//; $x }
47       @{$unified_info{libraries}};
48   our @shlibs =
49       map { $unified_info{sharednames}->{$_} || () }
50       grep(!/\.a$/, @{$unified_info{libraries}});
51   our @install_libs =
52       map { (my $x = $_) =~ s/\.a$//; $x }
53       @{$unified_info{install}->{libraries}};
54   our @install_shlibs =
55       map { $unified_info{sharednames}->{$_} || () }
56       grep(!/\.a$/, @{$unified_info{install}->{libraries}});
57   our @generated = ( ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
58                        grep { defined $unified_info{generate}->{$_} }
59                        map { @{$unified_info{sources}->{$_}} }
60                        grep { /\.o$/ } keys %{$unified_info{sources}} ),
61                      ( grep { /\.h$/ } keys %{$unified_info{generate}} ) );
62
63   # This is a horrible hack, but is needed because recursive inclusion of files
64   # in different directories does not work well with HP C.
65   my $sd = sourcedir("crypto", "async", "arch");
66   foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) {
67       (my $x = $_) =~ s|\.o$|.OBJ|;
68       $unified_info{before}->{$x}
69           = qq(arch_include = F\$PARSE("$sd","A.;",,,"SYNTAX_ONLY") - "A.;"
70         define arch 'arch_include');
71       $unified_info{after}->{$x}
72           = qq(deassign arch);
73   }
74   my $sd1 = sourcedir("ssl","record");
75   my $sd2 = sourcedir("ssl","statem");
76   my @ssl_locl_users = grep(/^\[\.(?:ssl\.(?:record|statem)|test)\].*\.o$/,
77                             keys %{$unified_info{sources}});
78   foreach (@ssl_locl_users) {
79       (my $x = $_) =~ s|\.o$|.OBJ|;
80       $unified_info{before}->{$x}
81           = qq(record_include = F\$PARSE("$sd1","A.;",,,"SYNTAX_ONLY") - "A.;"
82         define record 'record_include'
83         statem_include = F\$PARSE("$sd2","A.;",,,"SYNTAX_ONLY") - "A.;"
84         define statem 'statem_include');
85       $unified_info{after}->{$x}
86           = qq(deassign statem
87         deassign record);
88   }
89   # This makes sure things get built in the order they need
90   # to. You're welcome.
91   sub dependmagic {
92       my $target = shift;
93
94       return "$target : build_generated\n\t\pipe \$(MMS) \$(MMSQUALIFIERS) depend && \$(MMS) \$(MMSQUALIFIERS) _$target\n_$target";
95   }
96   #use Data::Dumper;
97   #print STDERR "DEBUG: before:\n", Dumper($unified_info{before});
98   #print STDERR "DEBUG: after:\n", Dumper($unified_info{after});
99   "";
100 -}
101 PLATFORM={- $config{target} -}
102 OPTIONS={- $config{options} -}
103 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
104 SRCDIR={- $config{sourcedir} -}
105 BLDDIR={- $config{builddir} -}
106
107 # Allow both V and VERBOSE to indicate verbosity.  This only applies
108 # to testing.
109 VERBOSE=$(V)
110
111 VERSION={- $config{version} -}
112 MAJOR={- $config{major} -}
113 MINOR={- $config{minor} -}
114 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
115 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
116 SHLIB_MAJOR={- $config{shlib_major} -}
117 SHLIB_MINOR={- $config{shlib_minor} -}
118 SHLIB_TARGET={- $target{shared_target} -}
119
120 EXE_EXT=.EXE
121 LIB_EXT=.OLB
122 SHLIB_EXT=.EXE
123 OBJ_EXT=.OBJ
124 DEP_EXT=.D
125
126 LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @libs) -}
127 SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
128 ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{engines}}) -}
129 PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -}
130 SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
131 {- output_off() if $disabled{makedepend}; "" -}
132 DEPS={- our @deps = map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
133                     grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
134                     keys %{$unified_info{sources}};
135         join(", ", map { "-\n\t".$_ } @deps); -}
136 {- output_on() if $disabled{makedepend}; "" -}
137 GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
138 GENERATED={- join(", ", map { "-\n\t".$_ } @generated) -}
139
140 INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
141 INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
142 INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{engines}}) -}
143 INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{programs}}) -}
144 {- output_off() if $disabled{apps}; "" -}
145 BIN_SCRIPTS=[.tools]c_rehash.pl
146 MISC_SCRIPTS=[.apps]CA.pl, [.apps]tsget.pl
147 {- output_on() if $disabled{apps}; "" -}
148
149 APPS_OPENSSL={- use File::Spec::Functions;
150                 catfile("apps","openssl") -}
151
152 # DESTDIR is for package builders so that they can configure for, say,
153 # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
154 # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
155 # MMS with /MACROS=(DESTDIR=STAGING:[USER]).  The result will end up in
156 # STAGING:[USER.OPENSSL].
157 # Normally it is left empty.
158 DESTDIR=
159
160 # Do not edit this manually. Use Configure --prefix=DIR to change this!
161 INSTALLTOP={- our $installtop =
162                   catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
163               $installtop -}
164 SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
165 # This is the standard central area to store certificates, private keys...
166 OPENSSLDIR={- catdir($config{openssldir}) or
167               $config{prefix} ? catdir($config{prefix},"COMMON")
168                               : "SYS\$COMMON:[OPENSSL-COMMON]" -}
169 # The same, but for C
170 OPENSSLDIR_C={- $osslprefix -}DATAROOT:[000000]
171 # Where installed engines reside, for C
172 ENGINESDIR_C={- $osslprefix -}ENGINES{- $sover_dirname.$target{pointer_size} -}:
173
174 CC= {- $config{cc} -}
175 DEFINES={- our $defines = join(",",
176                                '__dummy', # To make comma processing easier
177                                @{$config{defines}}) -}
178 CPPFLAGS={- our $cppflags = join('', @{$config{cppflags}}) -}
179 CPPFLAGS_Q={- $cppflags =~ s|"|""|g; $defines =~ s|"|""|g;
180               $cppflags."/DEFINE($defines)" -}
181 CFLAGS={- join('', @{$config{cflags}}) -}
182 LDFLAGS= {- join('', @{$config{lflags}}) -}
183 EX_LIBS= {- join('', map { ','.$_ } @{$config{ex_libs}}) -}
184 LIB_DEFINES={- join("",
185                     (map { ",$_" }
186                      @{$target{shared_defines}},
187                      'OPENSSLDIR="""$(OPENSSLDIR_C)"""',
188                      'ENGINESDIR="""$(ENGINESDIR_C)"""')) -}
189 LIB_CFLAGS={- $target{lib_cflags} // "" -}
190 DSO_CFLAGS={- $target{dso_cflags} // "" -}
191 BIN_CFLAGS={- $target{bin_cflags} // "" -}
192 NO_INST_LIB_CFLAGS={- $target{no_inst_lib_cflags} // '$(LIB_CFLAGS)' -}
193 NO_INST_DSO_CFLAGS={- $target{no_inst_dso_cflags} // '$(DSO_CFLAGS)' -}
194 NO_INST_BIN_CFLAGS={- $target{no_inst_bin_cflags} // '$(BIN_CFLAGS)' -}
195
196 PERL={- $config{perl} -}
197
198 # We let the C compiler driver to take care of .s files. This is done in
199 # order to be excused from maintaining a separate set of architecture
200 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
201 # gcc, then the driver will automatically translate it to -xarch=v8plus
202 # and pass it down to assembler.
203 AS={- $config{as} -}
204 ASFLAGS={- join('', @{$config{asflags}}) -}
205
206 # .FIRST and .LAST are special targets with MMS and MMK.
207 # The defines in there are for C.  includes that look like
208 # this:
209 #
210 #    #include <openssl/foo.h>
211 #    #include "internal/bar.h"
212 #
213 # will use the logical names to find the files.  Expecting
214 # DECompHP C to find files in subdirectories of whatever was
215 # given with /INCLUDE is a fantasy, unfortunately.
216 NODEBUG=@
217 .FIRST :
218         $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
219         $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
220         $(NODEBUG) internal_inc1 = F$PARSE("[.crypto.include.internal]","A.;",,,"SYNTAX_ONLY") - "A.;"
221         $(NODEBUG) internal_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
222         $(NODEBUG) internal_inc3 = F$PARSE("{- catdir($config{sourcedir},"[.crypto.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
223         $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
224         $(NODEBUG) DEFINE internal 'internal_inc1','internal_inc2','internal_inc3'
225         $(NODEBUG) staging_dir = "$(DESTDIR)"
226         $(NODEBUG) staging_instdir = ""
227         $(NODEBUG) staging_datadir = ""
228         $(NODEBUG) IF staging_dir .NES. "" THEN -
229                 staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
230         $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
231                 staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
232         $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
233                 staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
234         $(NODEBUG) IF staging_dir .NES. "" THEN -
235                 staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
236         $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
237                 staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
238         $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
239                 staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
240         $(NODEBUG) !
241         $(NODEBUG) ! Installation logical names
242         $(NODEBUG) !
243         $(NODEBUG) installtop = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
244         $(NODEBUG) datatop = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
245         $(NODEBUG) DEFINE ossl_installroot 'installtop'
246         $(NODEBUG) DEFINE ossl_dataroot 'datatop'
247         $(NODEBUG) !
248         $(NODEBUG) ! Figure out the architecture
249         $(NODEBUG) !
250         $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
251         $(NODEBUG) !
252         $(NODEBUG) ! Set up logical names for the libraries, so LINK and
253         $(NODEBUG) ! running programs can use them.
254         $(NODEBUG) !
255         $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } @shlibs) || "!" -}
256
257 .LAST :
258         $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -}
259         $(NODEBUG) DEASSIGN ossl_dataroot
260         $(NODEBUG) DEASSIGN ossl_installroot
261         $(NODEBUG) DEASSIGN internal
262         $(NODEBUG) DEASSIGN openssl
263 .DEFAULT :
264         @ ! MMS cannot handle no actions...
265
266 # The main targets ###################################################
267
268 {- dependmagic('all'); -} : build_libs_nodep, build_engines_nodep, build_programs_nodep
269 {- dependmagic('build_libs'); -} : build_libs_nodep
270 {- dependmagic('build_engines'); -} : build_engines_nodep
271 {- dependmagic('build_programs'); -} : build_programs_nodep
272
273 build_generated : $(GENERATED_MANDATORY)
274 build_libs_nodep : $(LIBS), $(SHLIBS)
275 build_engines_nodep : $(ENGINES)
276 build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
277
278 # Kept around for backward compatibility
279 build_apps build_tests : build_programs
280
281 # Convenience target to prebuild all generated files, not just the mandatory
282 # ones
283 build_all_generated : $(GENERATED_MANDATORY) $(GENERATED)
284
285 test : tests
286 {- dependmagic('tests'); -} : build_programs_nodep, build_engines_nodep
287         @ ! {- output_off() if $disabled{tests}; "" -}
288         SET DEFAULT [.test]{- move("test") -}
289         CREATE/DIR [.test-runs]
290         DEFINE SRCTOP {- sourcedir() -}
291         DEFINE BLDTOP {- builddir() -}
292         DEFINE RESULT_D {- builddir(qw(test test-runs)) -}
293         DEFINE OPENSSL_ENGINES {- builddir("engines") -}
294         DEFINE OPENSSL_DEBUG_MEMORY "on"
295         IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
296         $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
297         DEASSIGN OPENSSL_DEBUG_MEMORY
298         DEASSIGN OPENSSL_ENGINES
299         DEASSIGN BLDTOP
300         DEASSIGN SRCTOP
301         SET DEFAULT [-]{- move("..") -}
302         @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
303         @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
304         @ ! {- output_on() if !$disabled{tests}; "" -}
305
306 list-tests :
307         @ ! {- output_off() if $disabled{tests}; "" -}
308         @ DEFINE SRCTOP {- sourcedir() -}
309         @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
310         @ DEASSIGN SRCTOP
311         @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
312         @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
313         @ ! {- output_on() if !$disabled{tests}; "" -}
314
315 install : install_sw install_ssldirs install_docs
316         @ WRITE SYS$OUTPUT ""
317         @ WRITE SYS$OUTPUT "######################################################################"
318         @ WRITE SYS$OUTPUT ""
319         @ IF "$(DESTDIR)" .EQS. "" THEN -
320              PIPE ( WRITE SYS$OUTPUT "Installation complete" ; -
321                     WRITE SYS$OUTPUT "" ; -
322                     WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
323                     WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
324                     WRITE SYS$OUTPUT "" )
325         @ IF "$(DESTDIR)" .NES. "" THEN -
326              PIPE ( WRITE SYS$OUTPUT "Staging installation complete" ; -
327                     WRITE SYS$OUTPUT "" ; -
328                     WRITE SYS$OUTPUT "Finish or package in such a way that the contents of the directory tree" ; -
329                     WRITE SYS$OUTPUT staging_instdir ; -
330                     WRITE SYS$OUTPUT "ends up in $(INSTALLTOP)," ; -
331                     WRITE SYS$OUTPUT "and that the contents of the contents of the directory tree" ; -
332                     WRITE SYS$OUTPUT staging_datadir ; -
333                     WRITE SYS$OUTPUT "ends up in $(OPENSSLDIR)" ; -
334                     WRITE SYS$OUTPUT "" ; -
335                     WRITE SYS$OUTPUT "When in its final destination," ; -
336                     WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
337                     WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
338                     WRITE SYS$OUTPUT "" )
339
340 check_install :
341         spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
342
343 uninstall : uninstall_docs uninstall_sw
344
345 # Because VMS wants the generation number (or *) to delete files, we can't
346 # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(ENGINES)directly.
347 libclean :
348         {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
349         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
350
351 clean : libclean
352         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
353         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{engines}}) || "@ !" -}
354         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
355         {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
356         - DELETE [...]*.MAP;*
357         - DELETE [...]*.D;*
358         - DELETE [...]*.OBJ;*,*.LIS;*
359         - DELETE []CXX$DEMANGLER_DB.;*
360         - DELETE [.VMS]openssl_startup.com;*
361         - DELETE [.VMS]openssl_shutdown.com;*
362         - DELETE []vmsconfig.pm;*
363
364 distclean : clean
365         - DELETE configdata.pm;*
366         - DELETE descrip.mms;*
367
368 depend : descrip.mms
369 descrip.mms : FORCE
370         @ ! {- output_off() if $disabled{makedepend}; "" -}
371         @ $(PERL) -pe "if (/^# DO NOT DELETE.*/) { exit(0); }" -
372                 < descrip.mms > descrip.mms-new
373         @ OPEN/APPEND DESCRIP descrip.mms-new
374         @ WRITE DESCRIP "# DO NOT DELETE THIS LINE -- make depend depends on it."
375         {- join("\n\t", map { "\@ IF F\$SEARCH(\"$_\") .NES. \"\" THEN TYPE $_ /OUTPUT=DESCRIP:" } @deps); -}
376         @ CLOSE DESCRIP
377         @ PIPE ( $(PERL) -e "use File::Compare qw/compare_text/; my $x = compare_text(""descrip.mms"",""descrip.mms-new""); exit(0x10000000 + ($x == 0));" || -
378                  RENAME descrip.mms-new descrip.mms )
379         @ IF F$SEARCH("descrip.mms-new") .NES. "" THEN DELETE descrip.mms-new;*
380         -@ SPAWN/OUTPUT=NLA0: PURGE/NOLOG descrip.mms
381         @ ! {- output_on() if $disabled{makedepend}; "" -}
382
383 # Install helper targets #############################################
384
385 install_sw : all install_shared _install_dev_ns -
386              install_engines _install_runtime_ns -
387              install_startup install_ivp
388
389 uninstall_sw : uninstall_shared _uninstall_dev_ns -
390                uninstall_engines _uninstall_runtime_ns -
391                uninstall_startup uninstall_ivp
392
393 install_docs : install_html_docs
394
395 uninstall_docs : uninstall_html_docs
396
397 install_ssldirs : check_INSTALLTOP
398         - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
399         IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
400                 CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
401         IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
402                 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
403         IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
404                 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
405         COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
406         @ ! Install configuration file
407         COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
408                 ossl_dataroot:[000000]openssl.cnf-dist
409         IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN -
410                 COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
411                         ossl_dataroot:[000000]openssl.cnf
412         @ ! Install CTLOG configuration file
413         COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
414                 ossl_dataroot:[000000]ct_log_list.cnf-dist
415         IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN -
416                 COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
417                         ossl_dataroot:[000000]ct_log_list.cnf
418
419 install_shared : check_INSTALLTOP
420         @ {- output_off() if $disabled{shared}; "" -} !
421         @ WRITE SYS$OUTPUT "*** Installing shareable images"
422         @ ! Install shared (runtime) libraries
423         - CREATE/DIR ossl_installroot:[LIB.'arch']
424         {- join("\n        ",
425                 map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
426                 @install_shlibs) -}
427         @ {- output_on() if $disabled{shared}; "" -} !
428
429 _install_dev_ns : check_INSTALLTOP
430         @ WRITE SYS$OUTPUT "*** Installing development files"
431         @ ! Install header files
432         - CREATE/DIR ossl_installroot:[include.openssl]
433         COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
434         @ ! Install static (development) libraries
435         - CREATE/DIR ossl_installroot:[LIB.'arch']
436         {- join("\n        ",
437                 map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
438                 @install_libs) -}
439
440 install_dev : install_shared _install_dev_ns
441
442 _install_runtime_ns : check_INSTALLTOP
443         @ ! Install the main program
444         - CREATE/DIR ossl_installroot:[EXE.'arch']
445         COPY/PROT=W:RE [.APPS]openssl.EXE -
446                 ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
447         @ ! Install scripts
448         COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
449         @ ! {- output_on() if $disabled{apps}; "" -}
450
451 install_runtime : install_shared _install_runtime_ns
452
453 install_engines : check_INSTALLTOP
454         @ {- output_off() unless scalar @{$unified_info{engines}}; "" -} !
455         @ WRITE SYS$OUTPUT "*** Installing engines"
456         - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
457         {- join("\n        ",
458                 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
459                 @{$unified_info{install}->{engines}}) -}
460         @ {- output_on() unless scalar @{$unified_info{engines}}; "" -} !
461
462 install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
463                  [.VMS]openssl_utils.com, check_INSTALLTOP
464         - CREATE/DIR ossl_installroot:[SYS$STARTUP]
465         COPY/PROT=W:RE [.VMS]openssl_startup.com -
466                 ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com
467         COPY/PROT=W:RE [.VMS]openssl_shutdown.com -
468                 ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com
469         COPY/PROT=W:RE [.VMS]openssl_utils.com -
470                 ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com
471
472 install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
473         - CREATE/DIR ossl_installroot:[SYSTEST]
474         COPY/PROT=W:RE [.VMS]openssl_ivp.com -
475                 ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
476
477 [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
478         - CREATE/DIR [.VMS]
479         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
480                 {- sourcefile("VMS", "openssl_startup.com.in") -} -
481                 > [.VMS]openssl_startup.com
482
483 [.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -}
484         - CREATE/DIR [.VMS]
485         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
486                 {- sourcefile("VMS", "openssl_utils.com.in") -} -
487                 > [.VMS]openssl_utils.com
488
489 [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
490         - CREATE/DIR [.VMS]
491         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
492                 {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
493                 > [.VMS]openssl_shutdown.com
494
495 [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -}
496         - CREATE/DIR [.VMS]
497         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
498                 {- sourcefile("VMS", "openssl_ivp.com.in") -} -
499                 > [.VMS]openssl_ivp.com
500
501 vmsconfig.pm : configdata.pm
502         OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
503         WRITE CONFIG "package vmsconfig;"
504         WRITE CONFIG "use strict; use warnings;"
505         WRITE CONFIG "use Exporter;"
506         WRITE CONFIG "our @ISA = qw(Exporter);"
507         WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
508         WRITE CONFIG "our %config = ("
509         WRITE CONFIG "  target => '","{- $config{target} -}","',"
510         WRITE CONFIG "  version => '","{- $config{version} -}","',"
511         WRITE CONFIG "  shlib_version_number => '","{- $config{shlib_version_number} -}","',"
512         WRITE CONFIG "  shlib_major => '","{- $config{shlib_major} -}","',"
513         WRITE CONFIG "  shlib_minor => '","{- $config{shlib_minor} -}","',"
514         WRITE CONFIG "  no_shared => '","{- $disabled{shared} -}","',"
515         WRITE CONFIG "  INSTALLTOP => '$(INSTALLTOP)',"
516         WRITE CONFIG "  OPENSSLDIR => '$(OPENSSLDIR)',"
517         WRITE CONFIG "  pointer_size => '","{- $target{pointer_size} -}","',"
518         WRITE CONFIG ");"
519         WRITE CONFIG "our %target = ();"
520         WRITE CONFIG "our %disabled = ();"
521         WRITE CONFIG "our %withargs = ();"
522         WRITE CONFIG "our %unified_info = ();"
523         WRITE CONFIG "1;"
524         CLOSE CONFIG
525
526 install_html_docs : check_INSTALLTOP
527         sourcedir = F$PARSE("{- $sourcedir -}A.;","[]") - "]A.;" + ".DOC]"
528         $(PERL) {- sourcefile("util", "process_docs.pl") -} -
529                 --sourcedir='sourcedir' --destdir=ossl_installroot:[HTML] -
530                 --type=html
531
532 check_INSTALLTOP :
533         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
534                 WRITE SYS$ERROR "INSTALLTOP should not be empty"
535         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
536                 EXIT %x10000002
537
538 # Helper targets #####################################################
539
540 # Developer targets ##################################################
541
542 debug_logicals :
543         SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
544
545 # Building targets ###################################################
546
547 configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
548         perl configdata.pm -r -v
549         @ WRITE SYS$OUTPUT "*************************************************"
550         @ WRITE SYS$OUTPUT "***                                           ***"
551         @ WRITE SYS$OUTPUT "***   Please run the same mms command again   ***"
552         @ WRITE SYS$OUTPUT "***                                           ***"
553         @ WRITE SYS$OUTPUT "*************************************************"
554         @ PIPE ( EXIT %X10000000 )
555
556 reconfigure reconf:
557         perl configdata.pm -r -v
558
559 {-
560   use File::Basename;
561   use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
562
563   # Helper function to figure out dependencies on libraries
564   # It takes a list of library names and outputs a list of dependencies
565   sub compute_lib_depends {
566       if ($disabled{shared}) {
567           return map { $_ =~ /\.a$/ ? $`.".OLB" : $_.".OLB" } @_;
568       }
569       return map { $_ =~ /\.a$/
570                    ? $`.".OLB"
571                    : $unified_info{sharednames}->{$_}.".EXE" } @_;
572   }
573
574   sub generatesrc {
575       my %args = @_;
576       my $generator = join(" ", @{$args{generator}});
577       my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
578       my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
579
580       if ($args{src} !~ /\.[sS]$/) {
581           if ($args{generator}->[0] =~ m|^.*\.in$|) {
582               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
583                                                    "util", "dofile.pl")),
584                                    rel2abs($config{builddir}));
585               return <<"EOF";
586 $args{src} : $args{generator}->[0] $deps
587         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\
588             "-o$target{build_file}" $generator > \$@
589 EOF
590           } else {
591               return <<"EOF";
592 $args{src} : $args{generator}->[0] $deps
593         \$(PERL)$generator_incs $generator > \$@
594 EOF
595           }
596       } else {
597           die "No method to generate assembler source present.\n";
598       }
599   }
600
601   sub src2obj {
602       my %args = @_;
603       (my $obj = $args{obj}) =~ s|\.o$||;
604       my $deps = join(", -\n\t\t", @{$args{srcs}}, @{$args{deps}});
605
606       # Because VMS C isn't very good at combining a /INCLUDE path with
607       # #includes having a relative directory (like '#include "../foo.h"),
608       # the best choice is to move to the first source file's intended
609       # directory before compiling, and make sure to write the object file
610       # in the correct position (important when the object tree is other
611       # than the source tree).
612       my $forward = dirname($args{srcs}->[0]);
613       my $backward = abs2rel(rel2abs("."), rel2abs($forward));
614       my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
615       my $objn = basename($obj);
616       my $srcs =
617           join(", ",
618                map { abs2rel(rel2abs($_), rel2abs($forward)) } @{$args{srcs}});
619       my $cflags = '$(CFLAGS)';
620       if ($args{installed}) {
621           $cflags .= { lib => '$(LIB_CFLAGS)',
622                        dso => '$(DSO_CFLAGS)',
623                        bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
624       } else {
625           $cflags .= { lib => '$(NO_INST_LIB_CFLAGS)',
626                        dso => '$(NO_INST_DSO_CFLAGS)',
627                        bin => '$(NO_INST_BIN_CFLAGS)' } -> {$args{intent}};
628       }
629       $cflags .= '$(CPPFLAGS)';
630       $cflags .= { lib => '$(LIB_CPPFLAGS)',
631                    dso => '$(DSO_CPPFLAGS)',
632                    bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
633       my $defines = '$(DEFINES)';
634       $defines .= { lib => '$(LIB_DEFINES)',
635                     dso => '$(DSO_DEFINES)',
636                     bin => '$(BIN_DEFINES)' } -> {$args{intent}};
637       $cflags .= '/DEFINE=('.$defines.')';
638       
639       my $incs_on = "\@ !";
640       my $incs_off = "\@ !";
641       my $incs = "";
642       my @incs = ();
643       push @incs, @{$args{incs}} if @{$args{incs}};
644       unless ($disabled{zlib}) {
645           # GNV$ZLIB_INCLUDE is the standard logical name for later zlib
646           # incarnations.
647           push @incs, ($withargs{zlib_include} || 'GNV$ZLIB_INCLUDE:');
648       }
649       if (@incs) {
650           $incs_on =
651               "DEFINE tmp_includes "
652               .join(",-\n\t\t\t", map {
653                                       file_name_is_absolute($_)
654                                       ? $_ : catdir($backward,$_)
655                                   } @incs);
656           $incs_off = "DEASSIGN tmp_includes";
657           $incs = " /INCLUDE=(tmp_includes:)";
658       }
659       my $before = $unified_info{before}->{$obj.".OBJ"} || "\@ !";
660       my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !";
661       my $depbuild = $disabled{makedepend} ? ""
662           : " /MMS=(FILE=${objd}${objn}.tmp-D,TARGET=$obj.OBJ)";
663
664       return <<"EOF"
665 $obj.OBJ : $deps
666         ${before}
667         SET DEFAULT $forward
668         $incs_on
669         \$(CC) ${cflags}${incs}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
670         $incs_off
671         SET DEFAULT $backward
672         ${after}
673         - PURGE $obj.OBJ
674 EOF
675       . ($disabled{makedepend} ? "" : <<"EOF"
676         \@ PIPE ( \$(PERL) -e "use File::Compare qw/compare_text/; my \$x = compare_text(""$obj.D"",""$obj.tmp-D""); exit(0x10000000 + (\$x == 0));" || -
677                  RENAME $obj.tmp-D $obj.d )
678         \@ IF F\$SEARCH("$obj.tmp-D") .NES. "" THEN DELETE $obj.tmp-D;*
679 EOF
680         );
681   }
682   sub libobj2shlib {
683       my %args = @_;
684       my $lib = $args{lib};
685       my $shlib = $args{shlib};
686       my $libd = dirname($lib);
687       my $libn = basename($lib);
688       my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x }
689                  grep { $_ =~ m|\.o$| }
690                  @{$args{objs}};
691       my @defs = grep { $_ =~ /\.opt$/ } @{$args{objs}};
692       my @deps = compute_lib_depends(@{$args{deps}});
693       die "More than one symbol vector" if scalar @defs > 1;
694       my $deps = join(", -\n\t\t", @defs, @deps);
695       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
696       my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
697                                                      "VMS", "translatesyms.pl")),
698                                      rel2abs($config{builddir}));
699       # The "[]" hack is because in .OPT files, each line inherits the
700       # previous line's file spec as default, so if no directory spec
701       # is present in the current line and the previous line has one that
702       # doesn't apply, you're in for a surprise.
703       my $write_opt1 =
704           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
705                                  "WRITE OPT_FILE \"$x" } @objs).
706           "\"";
707       my $write_opt2 =
708           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
709                              $x =~ s|(\.EXE)|$1/SHARE|;
710                              $x =~ s|(\.OLB)|$1/LIB|;
711                              "WRITE OPT_FILE \"$x\"" } @deps)
712           || "\@ !";
713       return <<"EOF"
714 $shlib.EXE : $lib.OLB $deps
715         \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
716         OPEN/WRITE/SHARE=READ OPT_FILE $lib-components.OPT
717         $write_opt1
718         $write_opt2
719         CLOSE OPT_FILE
720         LINK \$(LDFLAGS)/SHARE=\$\@ $defs[0]-translated/OPT,-
721                 $lib-components.OPT/OPT \$(EX_LIBS)
722         DELETE $defs[0]-translated;*,$lib-components.OPT;*
723         PURGE $shlib.EXE,$shlib.MAP
724 EOF
725         . ($config{target} =~ m|alpha| ? "" : <<"EOF"
726         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
727 EOF
728         );
729   }
730   sub obj2dso {
731       my %args = @_;
732       my $lib = $args{lib};
733       my $libd = dirname($lib);
734       my $libn = basename($lib);
735       (my $libn_nolib = $libn) =~ s/^lib//;
736       my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
737       my @deps = compute_lib_depends(@{$args{deps}});
738       my $deps = join(", -\n\t\t", @objs, @deps);
739       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
740       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
741                                                "VMS", "engine.opt")),
742                                rel2abs($config{builddir}));
743       # The "[]" hack is because in .OPT files, each line inherits the
744       # previous line's file spec as default, so if no directory spec
745       # is present in the current line and the previous line has one that
746       # doesn't apply, you're in for a surprise.
747       my $write_opt1 =
748           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
749                                  "WRITE OPT_FILE \"$x" } @objs).
750           "\"";
751       my $write_opt2 =
752           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
753                              $x =~ s|(\.EXE)|$1/SHARE|;
754                              $x =~ s|(\.OLB)|$1/LIB|;
755                              "WRITE OPT_FILE \"$x\"" } @deps)
756           || "\@ !";
757       return <<"EOF"
758 $lib.EXE : $deps
759         OPEN/WRITE/SHARE=READ OPT_FILE $lib.OPT
760         TYPE $engine_opt /OUTPUT=OPT_FILE:
761         $write_opt1
762         $write_opt2
763         CLOSE OPT_FILE
764         LINK \$(LDFLAGS)/SHARE=\$\@ $lib.OPT/OPT \$(EX_LIBS)
765         - PURGE $lib.EXE,$lib.OPT,$lib.MAP
766 EOF
767         . ($config{target} =~ m|alpha| ? "" : <<"EOF"
768         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
769 EOF
770         );
771   }
772   sub obj2lib {
773       my %args = @_;
774       (my $lib = $args{lib}) =~ s/\.a$//;
775       my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
776       my $objs = join(", -\n\t\t", @objs);
777       my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_" }
778                                    @objs));
779       return <<"EOF";
780 $lib.OLB : $objs
781         LIBRARY/CREATE/OBJECT $lib.OLB
782         $fill_lib
783         - PURGE $lib.OLB
784 EOF
785   }
786   sub obj2bin {
787       my %args = @_;
788       my $bin = $args{bin};
789       my $bind = dirname($bin);
790       my $binn = basename($bin);
791       my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
792       my $objs = join(",", @objs);
793       my @deps = compute_lib_depends(@{$args{deps}});
794       my $deps = join(", -\n\t\t", @objs, @deps);
795
796       my $olb_count = scalar grep(m|\.OLB$|, @deps);
797       my $analyse_objs = "@ !";
798       if ($olb_count > 0) {
799           my $analyse_quals =
800               $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
801           $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
802       }
803       # The "[]" hack is because in .OPT files, each line inherits the
804       # previous line's file spec as default, so if no directory spec
805       # is present in the current line and the previous line has one that
806       # doesn't apply, you're in for a surprise.
807       my $write_opt1 =
808           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
809                                  "\@ WRITE OPT_FILE \"$x" } @objs).
810           "\"";
811       my $write_opt2 =
812           join("\n\t", map { my @lines = ();
813                              my $x = $_ =~ /\[/ ? $_ : "[]".$_;
814                              if ($x =~ m|\.EXE$|) {
815                                  push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\"";
816                              } elsif ($x =~ m|\.OLB$|) {
817                                  (my $l = $x) =~ s/\W/_/g;
818                                  push @lines, 
819                                      "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB\$(INCLUDE_MAIN_$l)\"",
820                                      "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\""
821                              }
822                              @lines
823                            } @deps)
824           || "\@ !";
825       # The linking commands looks a bit complex, but it's for good reason.
826       # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
827       # bar.obj happens to have a symbol that also exists in libsomething.exe,
828       # the linker will warn about it, loudly, and will then choose to pick
829       # the first copy encountered (the one in bar.obj in this example).
830       # On Unix and on Windows, the corresponding maneuvre goes through
831       # silently with the same effect.
832       # With some test programs, made for checking the internals of OpenSSL,
833       # we do this kind of linking deliberately, picking a few specific object
834       # files from within [.crypto] or [.ssl] so we can reach symbols that are
835       # otherwise unreachable (since the shareable images only exports the
836       # symbols listed in [.util]*.num), and then with the shared libraries
837       # themselves.  So we need to silence the warning about multiply defined
838       # symbols, to mimic the way linking work on Unix and Windows, and so
839       # the build isn't interrupted (MMS stops when warnings are signaled,
840       # by default), and so someone building doesn't have to worry where it
841       # isn't necessary.  If there are other warnings, however, we show them
842       # and let it break the build.
843       return <<"EOF"
844 $bin.EXE : $deps
845         $analyse_objs
846         @ OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
847         $write_opt1
848         $write_opt2
849         @ CLOSE OPT_FILE
850         TYPE $bin.opt ! For debugging
851         - pipe SPAWN/WAIT/NOLOG/OUT=$bin.LINKLOG -
852                     LINK \$(LDFLAGS)/EXEC=\$\@ $bin.OPT/OPT \$(EX_LIBS) ; -
853                link_status = \$status ; link_severity = link_status .AND. 7
854         @ search_severity = 1
855         -@ IF link_severity .EQ. 0 THEN -
856                 pipe SEARCH $bin.LINKLOG "%","-"/MATCH=AND | -
857                      SPAWN/WAIT/NOLOG/OUT=NLA0: -
858                           SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
859                      search_severity = \$severity
860         @ ! search_severity is 3 when the last search didn't find any matching
861         @ ! string: %SEARCH-I-NOMATCHES, no strings matched
862         @ ! If that was the result, we pretend linking got through without
863         @ ! fault or warning.
864         @ IF search_severity .EQ. 3 THEN link_severity = 1
865         @ ! At this point, if link_severity shows that there was a fault
866         @ ! or warning, make sure to restore the linking status.
867         -@ IF .NOT. link_severity THEN TYPE $bin.LINKLOG
868         -@ DELETE $bin.LINKLOG;*
869         @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
870         - PURGE $bin.EXE,$bin.OPT
871 EOF
872       . ($config{target} =~ m|alpha| ? "" : <<"EOF"
873         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
874 EOF
875         );
876   }
877   sub in2script {
878       my %args = @_;
879       my $script = $args{script};
880       return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
881       my $sources = join(" ", @{$args{sources}});
882       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
883                                            "util", "dofile.pl")),
884                            rel2abs($config{builddir}));
885       return <<"EOF";
886 $script : $sources
887         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
888             "-o$target{build_file}" $sources > $script
889         SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
890         PURGE $script
891 EOF
892   }
893   ""    # Important!  This becomes part of the template result.
894 -}