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