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