Build cleanup: Remove the VMS hack from test/build.info
[openssl.git] / Configurations / descrip.mms.tmpl
1 ## descrip.mms to build OpenSSL on OpenVMS
2 ##
3 ## {- join("\n## ", @autowarntext) -}
4 {-
5   use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
6   use File::Basename;
7
8   (our $osslprefix_q = platform->osslprefix()) =~ s/\$/\\\$/;
9
10   our $sover_dirname = platform->shlib_version_as_filename();
11   our $osslver = sprintf "%02d%02d", split(/\./, $config{version});
12
13   our $sourcedir = $config{sourcedir};
14   our $builddir = $config{builddir};
15   sub sourcefile {
16       catfile($sourcedir, @_);
17   }
18   sub buildfile {
19       catfile($builddir, @_);
20   }
21   sub sourcedir {
22       catdir($sourcedir, @_);
23   }
24   sub builddir {
25       catdir($builddir, @_);
26   }
27   sub tree {
28       (my $x = shift) =~ s|\]$|...]|;
29       $x
30   }
31   sub move {
32       my $f = catdir(@_);
33       my $b = abs2rel(rel2abs("."),rel2abs($f));
34       $sourcedir = catdir($b,$sourcedir)
35           if !file_name_is_absolute($sourcedir);
36       $builddir = catdir($b,$builddir)
37           if !file_name_is_absolute($builddir);
38       "";
39   }
40
41   # Because we need to make two computations of these data,
42   # we store them in arrays for reuse
43   our @libs =
44       map { platform->staticname($_) }
45       @{$unified_info{libraries}};
46   our @shlibs =
47       map { platform->sharedname($_) // () }
48       @{$unified_info{libraries}};
49   our @install_libs =
50       map { platform->staticname($_) }
51       grep { !$unified_info{attributes}->{$_}->{noinst} }
52       @{$unified_info{libraries}};
53   our @install_shlibs =
54       map { platform->sharedname($_) // () }
55       grep { !$unified_info{attributes}->{$_}->{noinst} }
56       @{$unified_info{libraries}};
57   our @install_engines =
58       grep { !$unified_info{attributes}->{$_}->{noinst} }
59       @{$unified_info{engines}};
60   our @install_programs =
61       grep { !$unified_info{attributes}->{$_}->{noinst} }
62       @{$unified_info{programs}};
63   our @install_bin_scripts =
64       grep { !$unified_info{attributes}->{$_}->{noinst}
65              && !$unified_info{attributes}->{$_}->{misc} }
66       @{$unified_info{scripts}};
67   our @install_misc_scripts =
68       grep { !$unified_info{attributes}->{$_}->{noinst}
69              && $unified_info{attributes}->{$_}->{misc} }
70       @{$unified_info{scripts}};
71
72   # This is a horrible hack, but is needed because recursive inclusion of files
73   # in different directories does not work well with HP C.
74   my $sd = sourcedir("crypto", "async", "arch");
75   foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) {
76       my $obj = platform->obj($_);
77       $unified_info{before}->{$obj}
78           = qq(arch_include = F\$PARSE("$sd","A.;",,,"SYNTAX_ONLY") - "A.;"
79         define arch 'arch_include');
80       $unified_info{after}->{$obj}
81           = qq(deassign arch);
82   }
83   my $sd1 = sourcedir("ssl","record");
84   my $sd2 = sourcedir("ssl","statem");
85   my @ssl_locl_users = grep(/^\[\.(?:ssl\.(?:record|statem)|test)\].*\.o$/,
86                             keys %{$unified_info{sources}});
87   foreach (@ssl_locl_users) {
88       my $obj = platform->obj($_);
89       $unified_info{before}->{$obj}
90           = qq(record_include = F\$PARSE("$sd1","A.;",,,"SYNTAX_ONLY") - "A.;"
91         define record 'record_include'
92         statem_include = F\$PARSE("$sd2","A.;",,,"SYNTAX_ONLY") - "A.;"
93         define statem 'statem_include');
94       $unified_info{after}->{$obj}
95           = qq(deassign statem
96         deassign record);
97   }
98   # This makes sure things get built in the order they need
99   # to. You're welcome.
100   sub dependmagic {
101       my $target = shift;
102
103       return "$target : build_generated\n\t\pipe \$(MMS) \$(MMSQUALIFIERS) depend && \$(MMS) \$(MMSQUALIFIERS) _$target\n_$target";
104   }
105   #use Data::Dumper;
106   #print STDERR "DEBUG: before:\n", Dumper($unified_info{before});
107   #print STDERR "DEBUG: after:\n", Dumper($unified_info{after});
108   "";
109 -}
110 PLATFORM={- $config{target} -}
111 OPTIONS={- $config{options} -}
112 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
113 SRCDIR={- $config{sourcedir} -}
114 BLDDIR={- $config{builddir} -}
115
116 # Allow both V and VERBOSE to indicate verbosity.  This only applies
117 # to testing.
118 VERBOSE=$(V)
119
120 VERSION={- "$config{full_version}" -}
121 MAJOR={- $config{major} -}
122 MINOR={- $config{minor} -}
123 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
124 SHLIB_TARGET={- $target{shared_target} -}
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 { platform->isobj($_) ? platform->dep($_) : $_ }
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={- # common0.tmpl provides @generated
139              join(", ", map { platform->convertext($_) } @generated) -}
140
141 INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
142 INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
143 INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @install_engines) -}
144 INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @install_programs) -}
145 BIN_SCRIPTS={- join(", ", @install_bin_scripts) -}
146 MISC_SCRIPTS={- join(", ", @install_misc_scripts) -}
147
148 APPS_OPENSSL={- use File::Spec::Functions;
149                 catfile("apps","openssl") -}
150
151 # DESTDIR is for package builders so that they can configure for, say,
152 # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
153 # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
154 # MMS with /MACROS=(DESTDIR=STAGING:[USER]).  The result will end up in
155 # STAGING:[USER.OPENSSL].
156 # Normally it is left empty.
157 DESTDIR=
158
159 # Do not edit this manually. Use Configure --prefix=DIR to change this!
160 INSTALLTOP={- our $installtop =
161                   catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
162               $installtop -}
163 SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
164 # This is the standard central area to store certificates, private keys...
165 OPENSSLDIR={- catdir($config{openssldir}) or
166               $config{prefix} ? catdir($config{prefix},"COMMON")
167                               : "SYS\$COMMON:[OPENSSL-COMMON]" -}
168 # The same, but for C
169 OPENSSLDIR_C={- platform->osslprefix() -}DATAROOT:[000000]
170 # Where installed engines reside, for C
171 ENGINESDIR_C={- platform->osslprefix() -}ENGINES{- $sover_dirname.$target{pointer_size} -}:
172
173 ##### User defined commands and flags ################################
174
175 CC={- $config{CC} -}
176 CPP={- $config{CPP} -}
177 DEFINES={- our $defines1 = join('', map { ",$_" } @{$config{CPPDEFINES}}) -}
178 INCLUDES={- our $includes1 = join(',', @{$config{CPPINCLUDES}}) -}
179 CPPFLAGS={- our $cppflags1 = join('', @{$config{CPPFLAGS}}) -}
180 CFLAGS={- join('', @{$config{CFLAGS}}) -}
181 LDFLAGS={- join('', @{$config{LFLAGS}}) -}
182 EX_LIBS={- join('', map { ",$_" } @{$config{LDLIBS}}) -}
183
184 PERL={- $config{PERL} -}
185
186 AS={- $config{AS} -}
187 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
188
189 ##### Special command flags ##########################################
190
191 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
192
193 ##### Project flags ##################################################
194
195 # Variables starting with CNF_ are common variables for all product types
196
197 CNF_ASFLAGS={- join('', $target{asflags} || (),
198                         @{$config{asflags}}) -}
199 CNF_DEFINES={- our $defines2 = join('', (map { ",$_" } @{$target{defines}},
200                                                        @{$config{defines}}),
201                                         "'extradefines'") -}
202 CNF_INCLUDES={- our $includes2 = join(',', @{$target{includes}},
203                                            @{$config{includes}}) -}
204 CNF_CPPFLAGS={- our $cppflags2 = join('', $target{cppflags} || (),
205                                           @{$config{cppflags}}) -}
206 CNF_CFLAGS={- join('', $target{cflags} || (),
207                        @{$config{cflags}}) -}
208 CNF_CXXFLAGS={- join('', $target{cxxflags} || (),
209                          @{$config{cxxflags}}) -}
210 CNF_LDFLAGS={- join('', $target{lflags} || (),
211                         @{$config{lflags}}) -}
212 CNF_EX_LIBS={- join('', map{ ",$_" } @{$target{ex_libs}},
213                                      @{$config{ex_libs}}) -}
214
215 # Variables starting with LIB_ are used to build library object files
216 # and shared libraries.
217 # Variables starting with DSO_ are used to build DSOs and their object files.
218 # Variables starting with BIN_ are used to build programs and their object
219 # files.
220
221 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
222                          @{$config{lib_asflags}},
223                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
224 LIB_DEFINES={- our $lib_defines =
225                join('', (map { ",$_" } @{$target{lib_defines}},
226                                        @{$target{shared_defines}},
227                                        @{$config{lib_defines}},
228                                        @{$config{shared_defines}}));
229                join('', $lib_defines,
230                         (map { ",$_" } 'OPENSSLDIR="""$(OPENSSLDIR_C)"""',
231                                        'ENGINESDIR="""$(ENGINESDIR_C)"""'),
232                         '$(CNF_DEFINES)', '$(DEFINES)') -}
233 LIB_INCLUDES={- our $lib_includes =
234                 join(',', @{$target{lib_includes}},
235                           @{$target{shared_includes}},
236                           @{$config{lib_includes}},
237                           @{$config{shared_includes}}) -}
238 LIB_CPPFLAGS={- our $lib_cppflags =
239                 join('', $target{lib_cppflags} || (),
240                          $target{shared_cppflags} || (),
241                          @{$config{lib_cppflags}},
242                          @{$config{shared_cppflag}});
243                 join('', "'qual_includes'",
244                          '/DEFINE=(__dummy$(LIB_DEFINES))',
245                          $lib_cppflags,
246                          '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
247 LIB_CFLAGS={- join('', $target{lib_cflags} || (),
248                        $target{shared_cflag} || (),
249                        @{$config{lib_cflags}},
250                        @{$config{shared_cflag}},
251                        '$(CNF_CFLAGS)', '$(CFLAGS)') -}
252 LIB_LDFLAGS={- join('', $target{lib_lflags} || (),
253                         $target{shared_ldflag} || (),
254                         @{$config{lib_lflags}},
255                         @{$config{shared_ldflag}},
256                         '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
257 LIB_EX_LIBS=$(CNF_EX_LIBS)$(EX_LIBS)
258 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
259                          $target{module_asflags} || (),
260                          @{$config{dso_asflags}},
261                          @{$config{module_asflags}},
262                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
263 DSO_DEFINES={- join('', (map { ",$_" } @{$target{dso_defines}},
264                                        @{$target{module_defines}},
265                                        @{$config{dso_defines}},
266                                        @{$config{module_defines}}),
267                         '$(CNF_DEFINES)', '$(DEFINES)') -}
268 DSO_INCLUDES={- join(',', @{$target{dso_includes}},
269                           @{$target{module_includes}},
270                           @{$config{dso_includes}},
271                           @{$config{module_includes}}) -}
272 DSO_CPPFLAGS={- join('', "'qual_includes'",
273                          '/DEFINE=(__dummy$(DSO_DEFINES))',
274                          $target{dso_cppflags} || (),
275                          $target{module_cppflags} || (),
276                          @{$config{dso_cppflags}},
277                          @{$config{module_cppflags}},
278                          '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
279 DSO_CFLAGS={- join('', $target{dso_cflags} || (),
280                        $target{module_cflags} || (),
281                        @{$config{dso_cflags}},
282                        @{$config{module_cflags}},
283                        '$(CNF_CFLAGS)', '$(CFLAGS)') -}
284 DSO_LDFLAGS={- join('', $target{dso_lflags} || (),
285                         $target{module_ldflags} || (),
286                         @{$config{dso_lflags}},
287                         @{$config{module_ldflags}},
288                         '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
289 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
290 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
291                          @{$config{bin_asflags}},
292                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
293 BIN_DEFINES={- join('', (map { ",$_" } @{$target{bin_defines}},
294                                        @{$config{bin_defines}}),
295                         '$(CNF_DEFINES)', '$(DEFINES)') -}
296 BIN_INCLUDES={- join(',', @{$target{bin_includes}},
297                           @{$config{bin_includes}}) -}
298 BIN_CPPFLAGS={- join('', "'qual_includes'",
299                          '/DEFINE=(__dummy$(DSO_DEFINES))',
300                          $target{bin_cppflags} || (),
301                          @{$config{bin_cppflag}},
302                          '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
303 BIN_CFLAGS={- join('', $target{bin_cflags} || (),
304                        @{$config{bin_cflags}},
305                        '$(CNF_CFLAGS)', '$(CFLAGS)') -}
306 BIN_LDFLAGS={- join('', $target{bin_lflags} || (),
307                         @{$config{bin_lflags}} || (),
308                         '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
309 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
310 NO_INST_LIB_CFLAGS={- join('', $target{no_inst_lib_cflags}
311                                // $target{lib_cflags}
312                                // (),
313                                $target{shared_cflag} || (),
314                                @{$config{lib_cflags}},
315                                @{$config{shared_cflag}},
316                                '$(CNF_CFLAGS)', '$(CFLAGS)') -}
317 NO_INST_DSO_CFLAGS={- join('', $target{no_inst_dso_cflags}
318                                // $target{dso_cflags}
319                                // (),
320                                $target{no_inst_module_cflags}
321                                // $target{module_cflags}
322                                // (),
323                                @{$config{dso_cflags}},
324                                @{$config{module_cflags}},
325                                '$(CNF_CFLAGS)', '$(CFLAGS)') -}
326 NO_INST_BIN_CFLAGS={- join('', $target{no_inst_bin_cflags}
327                                // $target{bin_cflags}
328                                // (),
329                                @{$config{bin_cflags}},
330                                '$(CNF_CFLAGS)', '$(CFLAGS)') -}
331
332 PERLASM_SCHEME={- $target{perlasm_scheme} -}
333
334 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
335 CPPFLAGS_Q={- (my $c = $lib_cppflags.$cppflags2.$cppflags1) =~ s|"|""|g;
336               (my $d = $lib_defines.$defines2.$defines1) =~ s|"|""|g;
337               my $i = join(',', $lib_includes || (), $includes2 || (),
338                                 $includes1 || ());
339               my $x = $c;
340               $x .= "/INCLUDE=($i)" if $i;
341               $x .= "/DEFINE=($d)" if $d;
342               $x; -}
343
344 # .FIRST and .LAST are special targets with MMS and MMK.
345 # The defines in there are for C.  includes that look like
346 # this:
347 #
348 #    #include <openssl/foo.h>
349 #    #include "internal/bar.h"
350 #
351 # will use the logical names to find the files.  Expecting
352 # DECompHP C to find files in subdirectories of whatever was
353 # given with /INCLUDE is a fantasy, unfortunately.
354 NODEBUG=@
355 .FIRST :
356         $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
357         $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
358         $(NODEBUG) internal_inc1 = F$PARSE("[.crypto.include.internal]","A.;",,,"SYNTAX_ONLY") - "A.;"
359         $(NODEBUG) internal_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
360         $(NODEBUG) internal_inc3 = F$PARSE("{- catdir($config{sourcedir},"[.crypto.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
361         $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
362         $(NODEBUG) DEFINE internal 'internal_inc1','internal_inc2','internal_inc3'
363         $(NODEBUG) staging_dir = "$(DESTDIR)"
364         $(NODEBUG) staging_instdir = ""
365         $(NODEBUG) staging_datadir = ""
366         $(NODEBUG) IF staging_dir .NES. "" THEN -
367                 staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
368         $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
369                 staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
370         $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
371                 staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
372         $(NODEBUG) IF staging_dir .NES. "" THEN -
373                 staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
374         $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
375                 staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
376         $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
377                 staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
378         $(NODEBUG) !
379         $(NODEBUG) ! Installation logical names
380         $(NODEBUG) !
381         $(NODEBUG) installtop = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
382         $(NODEBUG) datatop = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
383         $(NODEBUG) DEFINE ossl_installroot 'installtop'
384         $(NODEBUG) DEFINE ossl_dataroot 'datatop'
385         $(NODEBUG) !
386         $(NODEBUG) ! Figure out the architecture
387         $(NODEBUG) !
388         $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
389         $(NODEBUG) !
390         $(NODEBUG) ! Set up logical names for the libraries, so LINK and
391         $(NODEBUG) ! running programs can use them.
392         $(NODEBUG) !
393         $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } @shlibs) || "!" -}
394
395 .LAST :
396         $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -}
397         $(NODEBUG) DEASSIGN ossl_dataroot
398         $(NODEBUG) DEASSIGN ossl_installroot
399         $(NODEBUG) DEASSIGN internal
400         $(NODEBUG) DEASSIGN openssl
401 .DEFAULT :
402         @ ! MMS cannot handle no actions...
403
404 # The main targets ###################################################
405
406 {- dependmagic('all'); -} : build_libs_nodep, build_engines_nodep, build_programs_nodep
407 {- dependmagic('build_libs'); -} : build_libs_nodep
408 {- dependmagic('build_engines'); -} : build_engines_nodep
409 {- dependmagic('build_programs'); -} : build_programs_nodep
410
411 build_generated : $(GENERATED_MANDATORY)
412 build_libs_nodep : $(LIBS), $(SHLIBS)
413 build_engines_nodep : $(ENGINES)
414 build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
415
416 # Kept around for backward compatibility
417 build_apps build_tests : build_programs
418
419 # Convenience target to prebuild all generated files, not just the mandatory
420 # ones
421 build_all_generated : $(GENERATED_MANDATORY) $(GENERATED)
422         @ ! {- output_off() if $disabled{makedepend}; "" -}
423         @ WRITE SYS$OUTPUT "Warning: consider configuring with no-makedepend, because if"
424         @ WRITE SYS$OUTPUT "         target system doesn't have $(PERL),"
425         @ WRITE SYS$OUTPUT "         then make will fail..."
426         @ ! {- output_on() if $disabled{makedepend}; "" -}
427
428 test : tests
429 {- dependmagic('tests'); -} : build_programs_nodep, build_engines_nodep
430         @ ! {- output_off() if $disabled{tests}; "" -}
431         SET DEFAULT [.test]{- move("test") -}
432         CREATE/DIR [.test-runs]
433         DEFINE SRCTOP {- sourcedir() -}
434         DEFINE BLDTOP {- builddir() -}
435         DEFINE RESULT_D {- builddir(qw(test test-runs)) -}
436         DEFINE OPENSSL_ENGINES {- builddir("engines") -}
437         DEFINE OPENSSL_DEBUG_MEMORY "on"
438         IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
439         $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
440         DEASSIGN OPENSSL_DEBUG_MEMORY
441         DEASSIGN OPENSSL_ENGINES
442         DEASSIGN BLDTOP
443         DEASSIGN SRCTOP
444         SET DEFAULT [-]{- move("..") -}
445         @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
446         @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
447         @ ! {- output_on() if !$disabled{tests}; "" -}
448
449 list-tests :
450         @ ! {- output_off() if $disabled{tests}; "" -}
451         @ DEFINE SRCTOP {- sourcedir() -}
452         @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
453         @ DEASSIGN SRCTOP
454         @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
455         @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
456         @ ! {- output_on() if !$disabled{tests}; "" -}
457
458 install : install_sw install_ssldirs install_docs
459         @ WRITE SYS$OUTPUT ""
460         @ WRITE SYS$OUTPUT "######################################################################"
461         @ WRITE SYS$OUTPUT ""
462         @ IF "$(DESTDIR)" .EQS. "" THEN -
463              PIPE ( WRITE SYS$OUTPUT "Installation complete" ; -
464                     WRITE SYS$OUTPUT "" ; -
465                     WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
466                     WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
467                     WRITE SYS$OUTPUT "" )
468         @ IF "$(DESTDIR)" .NES. "" THEN -
469              PIPE ( WRITE SYS$OUTPUT "Staging installation complete" ; -
470                     WRITE SYS$OUTPUT "" ; -
471                     WRITE SYS$OUTPUT "Finish or package in such a way that the contents of the directory tree" ; -
472                     WRITE SYS$OUTPUT staging_instdir ; -
473                     WRITE SYS$OUTPUT "ends up in $(INSTALLTOP)," ; -
474                     WRITE SYS$OUTPUT "and that the contents of the contents of the directory tree" ; -
475                     WRITE SYS$OUTPUT staging_datadir ; -
476                     WRITE SYS$OUTPUT "ends up in $(OPENSSLDIR)" ; -
477                     WRITE SYS$OUTPUT "" ; -
478                     WRITE SYS$OUTPUT "When in its final destination," ; -
479                     WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
480                     WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
481                     WRITE SYS$OUTPUT "" )
482
483 check_install :
484         spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
485
486 uninstall : uninstall_docs uninstall_sw
487
488 # Because VMS wants the generation number (or *) to delete files, we can't
489 # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(ENGINES)directly.
490 libclean :
491         {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
492         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
493
494 clean : libclean
495         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
496         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{engines}}) || "@ !" -}
497         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
498         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -}
499         {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
500         - DELETE [...]*.MAP;*
501         - DELETE [...]*.D;*
502         - DELETE [...]*.OBJ;*,*.LIS;*
503         - DELETE []CXX$DEMANGLER_DB.;*
504         - DELETE [.VMS]openssl_startup.com;*
505         - DELETE [.VMS]openssl_shutdown.com;*
506         - DELETE []vmsconfig.pm;*
507
508 distclean : clean
509         - DELETE configdata.pm;*
510         - DELETE descrip.mms;*
511
512 depend : descrip.mms
513 descrip.mms : FORCE
514         @ ! {- output_off() if $disabled{makedepend}; "" -}
515         @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "VMS C"
516         @ ! {- output_on() if $disabled{makedepend}; "" -}
517
518 # Install helper targets #############################################
519
520 install_sw : install_dev install_engines install_runtime -
521              install_startup install_ivp
522
523 uninstall_sw : uninstall_dev uninstall_engines uninstall_runtime -
524                uninstall_startup uninstall_ivp
525
526 install_docs : install_html_docs
527
528 uninstall_docs : uninstall_html_docs
529
530 install_ssldirs : check_INSTALLTOP
531         - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
532         IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
533                 CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
534         IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
535                 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
536         IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
537                 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
538         COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
539         @ ! Install configuration file
540         COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
541                 ossl_dataroot:[000000]openssl.cnf-dist
542         IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN -
543                 COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
544                         ossl_dataroot:[000000]openssl.cnf
545         @ ! Install CTLOG configuration file
546         COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
547                 ossl_dataroot:[000000]ct_log_list.cnf-dist
548         IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN -
549                 COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
550                         ossl_dataroot:[000000]ct_log_list.cnf
551
552 install_dev : check_INSTALLTOP install_runtime_libs
553         @ WRITE SYS$OUTPUT "*** Installing development files"
554         @ ! Install header files
555         - CREATE/DIR ossl_installroot:[include.openssl]
556         COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
557         @ ! Install static (development) libraries
558         - CREATE/DIR ossl_installroot:[LIB.'arch']
559         {- join("\n        ",
560                 map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
561                 @install_libs) -}
562
563 install_engines : check_INSTALLTOP install_runtime_libs build_engines
564         @ {- output_off() unless scalar @{$unified_info{engines}}; "" -} !
565         @ WRITE SYS$OUTPUT "*** Installing engines"
566         - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
567         {- join("\n        ",
568                 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
569                 @install_engines) -}
570         @ {- output_on() unless scalar @{$unified_info{engines}}; "" -} !
571
572 install_runtime : install_programs
573
574 install_runtime_libs : check_INSTALLTOP build_libs
575         @ {- output_off() if $disabled{shared}; "" -} !
576         @ WRITE SYS$OUTPUT "*** Installing shareable images"
577         @ ! Install shared (runtime) libraries
578         - CREATE/DIR ossl_installroot:[LIB.'arch']
579         {- join("\n        ",
580                 map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
581                 @install_shlibs) -}
582         @ {- output_on() if $disabled{shared}; "" -} !
583
584 install_programs : check_INSTALLTOP install_runtime_libs build_programs
585         @ {- output_off() if $disabled{apps}; "" -} !
586         @ ! Install the main program
587         - CREATE/DIR ossl_installroot:[EXE.'arch']
588         COPY/PROT=W:RE [.APPS]openssl.EXE -
589                 ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
590         @ ! Install scripts
591         COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
592         @ ! {- output_on() if $disabled{apps}; "" -}
593
594 install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
595                  [.VMS]openssl_utils.com, check_INSTALLTOP
596         - CREATE/DIR ossl_installroot:[SYS$STARTUP]
597         COPY/PROT=W:RE [.VMS]openssl_startup.com -
598                 ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com
599         COPY/PROT=W:RE [.VMS]openssl_shutdown.com -
600                 ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com
601         COPY/PROT=W:RE [.VMS]openssl_utils.com -
602                 ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com
603
604 install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
605         - CREATE/DIR ossl_installroot:[SYSTEST]
606         COPY/PROT=W:RE [.VMS]openssl_ivp.com -
607                 ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
608
609 [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
610         - CREATE/DIR [.VMS]
611         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
612                 {- sourcefile("VMS", "openssl_startup.com.in") -} -
613                 > [.VMS]openssl_startup.com
614
615 [.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -}
616         - CREATE/DIR [.VMS]
617         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
618                 {- sourcefile("VMS", "openssl_utils.com.in") -} -
619                 > [.VMS]openssl_utils.com
620
621 [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
622         - CREATE/DIR [.VMS]
623         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
624                 {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
625                 > [.VMS]openssl_shutdown.com
626
627 [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -}
628         - CREATE/DIR [.VMS]
629         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
630                 {- sourcefile("VMS", "openssl_ivp.com.in") -} -
631                 > [.VMS]openssl_ivp.com
632
633 vmsconfig.pm : configdata.pm
634         OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
635         WRITE CONFIG "package vmsconfig;"
636         WRITE CONFIG "use strict; use warnings;"
637         WRITE CONFIG "use Exporter;"
638         WRITE CONFIG "our @ISA = qw(Exporter);"
639         WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
640         WRITE CONFIG "our %config = ("
641         WRITE CONFIG "  target => '","{- $config{target} -}","',"
642         WRITE CONFIG "  version => '","{- $config{version} -}","',"
643         WRITE CONFIG "  shlib_version => '","{- $config{shlib_version} -}","',"
644         WRITE CONFIG "  shlib_major => '","{- $config{shlib_major} -}","',"
645         WRITE CONFIG "  shlib_minor => '","{- $config{shlib_minor} -}","',"
646         WRITE CONFIG "  no_shared => '","{- $disabled{shared} -}","',"
647         WRITE CONFIG "  INSTALLTOP => '$(INSTALLTOP)',"
648         WRITE CONFIG "  OPENSSLDIR => '$(OPENSSLDIR)',"
649         WRITE CONFIG "  pointer_size => '","{- $target{pointer_size} -}","',"
650         WRITE CONFIG ");"
651         WRITE CONFIG "our %target = ();"
652         WRITE CONFIG "our %disabled = ();"
653         WRITE CONFIG "our %withargs = ();"
654         WRITE CONFIG "our %unified_info = ();"
655         WRITE CONFIG "1;"
656         CLOSE CONFIG
657
658 install_html_docs : check_INSTALLTOP
659         sourcedir = F$PARSE("{- $sourcedir -}A.;","[]") - "]A.;" + ".DOC]"
660         $(PERL) {- sourcefile("util", "process_docs.pl") -} -
661                 --sourcedir='sourcedir' --destdir=ossl_installroot:[HTML] -
662                 --type=html
663
664 check_INSTALLTOP :
665         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
666                 WRITE SYS$ERROR "INSTALLTOP should not be empty"
667         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
668                 EXIT %x10000002
669
670 # Helper targets #####################################################
671
672 # Developer targets ##################################################
673
674 debug_logicals :
675         SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
676
677 # Building targets ###################################################
678
679 configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
680         perl configdata.pm -r
681         @ WRITE SYS$OUTPUT "*************************************************"
682         @ WRITE SYS$OUTPUT "***                                           ***"
683         @ WRITE SYS$OUTPUT "***   Please run the same mms command again   ***"
684         @ WRITE SYS$OUTPUT "***                                           ***"
685         @ WRITE SYS$OUTPUT "*************************************************"
686         @ PIPE ( EXIT %X10000000 )
687
688 reconfigure reconf :
689         perl configdata.pm -r
690
691 {-
692   use File::Basename;
693   use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
694
695   # Helper function to figure out dependencies on libraries
696   # It takes a list of library names and outputs a list of dependencies
697   sub compute_lib_depends {
698       # Depending on shared libraries:
699       # On Windows POSIX layers, we depend on {libname}.dll.a
700       # On Unix platforms, we depend on {shlibname}.so
701       return map {
702           { lib   => platform->sharedlib($_) // platform->staticlib($_),
703             attrs => $unified_info{attributes}->{$_} }
704       } @_;
705   }
706
707   # Helper function to deal with inclusion directory specs.
708   # We have to deal with two things:
709   # 1. comma separation and no possibility of trailing comma
710   # 2. no inclusion directories given at all
711   # 3. long compiler command lines
712   # To resolve 1, we need to iterate through the sources of inclusion
713   # directories, and only add a comma when needed.
714   # To resolve 2, we need to have a variable that will hold the whole
715   # inclusion qualifier, or be the empty string if there are no inclusion
716   # directories.  That's the symbol 'qual_includes' that's used in CPPFLAGS
717   # To resolve 3, we creata a logical name TMP_INCLUDES: to hold the list
718   # of inclusion directories.
719   #
720   # This function returns a list of two lists, one being the collection of
721   # commands to execute before the compiler is called, and the other being
722   # the collection of commands to execute after.  It takes as arguments the
723   # collection of strings to include as directory specs.
724   sub includes {
725       my @stuff = ( @_ );
726       my @before = (
727           'qual_includes :=',
728       );
729       my @after = (
730           'DELETE/SYMBOL/LOCAL qual_includes',
731       );
732
733       if (scalar @stuff > 0) {
734           push @before, 'tmp_includes := '.shift(@stuff);
735           while (@stuff) {
736               push @before, 'tmp_add := '.shift(@stuff);
737               push @before, 'IF tmp_includes .NES. "" .AND. tmp_add .NES. "" THEN tmp_includes = tmp_includes + ","';
738               push @before, 'tmp_includes = tmp_includes + tmp_add';
739           }
740           push @before, "IF tmp_includes .NES. \"\" THEN DEFINE tmp_includes 'tmp_includes'";
741           push @before, 'IF tmp_includes .NES. "" THEN qual_includes := /INCLUDE=(tmp_includes:)';
742           push @before, 'DELETE/SYMBOL/LOCAL tmp_includes';
743           push @before, 'DELETE/SYMBOL/LOCAL tmp_add';
744           push @after, 'DEASSIGN tmp_includes:'
745       }
746       return ([ @before ], [ @after ]);
747   }
748
749   sub generatesrc {
750       my %args = @_;
751       my $generator = join(" ", @{$args{generator}});
752       my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
753       my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
754
755       if (platform->isdef($args{src})) {
756           my $target = platform->def($args{src});
757           my $mkdef = sourcefile('util', 'mkdef.pl');
758           my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
759           my $ord_name =
760               $args{generator}->[1] || basename($args{product}, '.EXE');
761           my $case_insensitive =
762               $target{$args{intent}.'_cflags'} =~ m|/NAMES=[^/]*AS_IS|i
763               ? '' : ' --case-insensitive';
764           return <<"EOF";
765 $target : $args{generator}->[0] $deps $mkdef
766         \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name "--OS" "VMS"$case_insensitive > $target
767 EOF
768       } elsif (!platform->isasm($args{src})) {
769           my $target = $args{src};
770           if ($args{generator}->[0] =~ m|^.*\.in$|) {
771               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
772                                                    "util", "dofile.pl")),
773                                    rel2abs($config{builddir}));
774               return <<"EOF";
775 $target : $args{generator}->[0] $deps
776         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\
777             "-o$target{build_file}" $generator > \$\@
778 EOF
779           } else {
780               return <<"EOF";
781 $target : $args{generator}->[0] $deps
782         \$(PERL)$generator_incs $generator > \$\@
783 EOF
784           }
785       } else {
786           my $target = platform->asm($args{src});
787           if ($args{generator}->[0] =~ /\.pl$/) {
788               $generator = '$(PERL)'.$generator_incs.' '.$generator;
789           } elsif ($args{generator}->[0] =~ /\.S$/) {
790               $generator = undef;
791           } else {
792               die "Generator type for $src unknown: $generator\n";
793           }
794
795           my $cppflags = {
796               shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
797               lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
798               dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
799               bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
800           } -> {$args{intent}};
801           my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
802                                      lib => '$(LIB_INCLUDES)',
803                                      dso => '$(DSO_INCLUDES)',
804                                      bin => '$(BIN_INCLUDES)' } -> {$args{intent}},
805                                    '$(CNF_INCLUDES)',
806                                    '$(INCLUDES)',
807                                    @{$args{incs}});
808           my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
809           my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
810           my $defs = join("", map { ",".$_ } @{$args{defs}});
811           if (defined($generator)) {
812               # If the target is named foo.S in build.info, we want to
813               # end up generating foo.s in two steps.
814               if ($args{src} =~ /\.S$/) {
815                    return <<"EOF";
816 $target : $args{generator}->[0] $deps
817         $generator \$\@-S
818         \@ $incs_on
819         \@ extradefines = "$defs"
820         PIPE \$(CPP) $cppflags \$\@-S | -
821              \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@-i
822         \@ DELETE/SYMBOL/LOCAL extradefines
823         \@ $incs_off
824         RENAME \$\@-i \$\@
825         DELETE \$\@-S;
826 EOF
827               }
828               # Otherwise....
829               return <<"EOF";
830 $target : $args{generator}->[0] $deps
831         $generator \$\@
832 EOF
833           }
834           return <<"EOF";
835 $target : $args{generator}->[0] $deps
836         \@ $incs_on
837         \@ extradefines = "$defs"
838         SHOW SYMBOL qual_includes
839         PIPE \$(CPP) $cppflags $args{generator}->[0] | -
840         \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@
841         \@ DELETE/SYMBOL/LOCAL extradefines
842         \@ $incs_off
843 EOF
844       }
845   }
846
847   sub src2obj {
848       my %args = @_;
849       my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x } ( @{$args{srcs}} );
850       my $obj = platform->obj($args{obj});
851       my $deps = join(", -\n\t\t", @srcs, @{$args{deps}});
852
853       # Because VMS C isn't very good at combining a /INCLUDE path with
854       # #includes having a relative directory (like '#include "../foo.h"),
855       # the best choice is to move to the first source file's intended
856       # directory before compiling, and make sure to write the object file
857       # in the correct position (important when the object tree is other
858       # than the source tree).
859       my $forward = dirname($args{srcs}->[0]);
860       my $backward = abs2rel(rel2abs("."), rel2abs($forward));
861       my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
862       my $objn = basename($obj, platform->objext());
863       my $srcs =
864           join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs);
865       my $before = $unified_info{before}->{$obj} || "\@ !";
866       my $after = $unified_info{after}->{$obj} || "\@ !";
867
868       if ($srcs[0] =~ /\.asm$/) {
869           my $asflags = { shlib => ' $(LIB_ASFLAGS)',
870                           lib => ' $(LIB_ASFLAGS)',
871                           dso => ' $(DSO_ASFLAGS)',
872                           bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
873           return <<"EOF";
874 $obj : $deps
875         ${before}
876         SET DEFAULT $forward
877         \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn}.OBJ $srcs
878         SET DEFAULT $backward
879 EOF
880       }
881
882       my $cflags;
883       if ($args{attrs}->{noinst}) {
884           $cflags = { shlib => '$(NO_INST_LIB_CFLAGS)',
885                       lib => '$(NO_INST_LIB_CFLAGS)',
886                       dso => '$(NO_INST_DSO_CFLAGS)',
887                       bin => '$(NO_INST_BIN_CFLAGS)' } -> {$args{intent}};
888       } else {
889           $cflags = { shlib => '$(LIB_CFLAGS)',
890                       lib => '$(LIB_CFLAGS)',
891                       dso => '$(DSO_CFLAGS)',
892                       bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
893       }
894       $cflags .= { shlib => '$(LIB_CPPFLAGS)',
895                    lib => '$(LIB_CPPFLAGS)',
896                    dso => '$(DSO_CPPFLAGS)',
897                    bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
898       my $defs = join("", map { ",".$_ } @{$args{defs}});
899       my $asflags = { shlib => ' $(LIB_ASFLAGS)',
900                       lib => ' $(LIB_ASFLAGS)',
901                       dso => ' $(DSO_ASFLAGS)',
902                       bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
903
904       my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
905                                  lib => '$(LIB_INCLUDES)',
906                                  dso => '$(DSO_INCLUDES)',
907                                  bin => '$(BIN_INCLUDES)' } -> {$args{intent}},
908                                '$(INCLUDES)',
909                                map {
910                                    file_name_is_absolute($_)
911                                    ? $_ : catdir($backward,$_)
912                                } @{$args{incs}});
913       my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
914       my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
915
916       if ($srcs[0] =~ /\.asm$/) {
917           return <<"EOF";
918 $obj.OBJ : $deps
919         ${before}
920         SET DEFAULT $forward
921         \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn}.OBJ $srcs
922         SET DEFAULT $backward
923         ${after}
924         - PURGE $obj.OBJ
925 EOF
926       } elsif ($srcs[0] =~ /.S$/) {
927          return <<"EOF";
928 $obj.OBJ : $deps
929         ${before}
930         SET DEFAULT $forward
931         \@ $incs_on
932         \@ extradefines = "$defs"
933         PIPE \$(CPP) ${cflags} $srcs | -
934              \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" -
935              > ${objd}${objn}.asm
936         \@ DELETE/SYMBOL/LOCAL extradefines
937         \@ $incs_off
938         SET DEFAULT $backward
939         ${after}
940         \$(AS) $asflags \$(ASOUTFLAG)$obj.OBJ $obj.asm
941         - PURGE $obj.OBJ
942 EOF
943       }
944
945       my $depbuild = $disabled{makedepend} ? ""
946           : " /MMS=(FILE=${objd}${objn}.D,TARGET=$obj)";
947
948       return <<"EOF";
949 $obj : $deps
950         ${before}
951         SET DEFAULT $forward
952         \@ $incs_on
953         \@ extradefines = "$defs"
954         \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
955         \@ DELETE/SYMBOL/LOCAL extradefines
956         \@ $incs_off
957         SET DEFAULT $backward
958         ${after}
959         - PURGE $obj
960 EOF
961   }
962   sub obj2shlib {
963       my %args = @_;
964       my $shlibname = platform->sharedname($args{lib});
965       my $shlib = platform->sharedlib($args{lib});
966       my @objs = map { platform->convertext($_) }
967                  grep { platform->isobj($_) }
968                  @{$args{objs}};
969       my @defs = map { platform->convertext($_) }
970                  grep { platform->isdef($_) }
971                  @{$args{objs}};
972       my @deps = compute_lib_depends(@{$args{deps}});
973       die "More than one symbol vector" if scalar @defs > 1;
974       my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
975       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
976       my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
977                                                      "VMS", "translatesyms.pl")),
978                                      rel2abs($config{builddir}));
979       # The "[]" hack is because in .OPT files, each line inherits the
980       # previous line's file spec as default, so if no directory spec
981       # is present in the current line and the previous line has one that
982       # doesn't apply, you're in for a surprise.
983       my $write_opt1 =
984           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
985                                  "WRITE OPT_FILE \"$x" } @objs).
986           "\"";
987       my $write_opt2 =
988           join("\n\t", map { my $x = $_->{lib} =~ /\[/
989                                  ? $_->{lib} : "[]".$_->{lib};
990                              $x =~ s|(\.EXE)|$1/SHARE|;
991                              $x =~ s|(\.OLB)|$1/LIB|;
992                              "WRITE OPT_FILE \"$x\"" } @deps)
993           || "\@ !";
994       return <<"EOF"
995 $shlib : $deps
996         \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
997         OPEN/WRITE/SHARE=READ OPT_FILE $shlibname-components.OPT
998         $write_opt1
999         $write_opt2
1000         CLOSE OPT_FILE
1001         LINK \$(LIB_LDFLAGS)/SHARE=\$\@ $defs[0]-translated/OPT,-
1002                 $shlibname-components.OPT/OPT \$(LIB_EX_LIBS)
1003         DELETE $defs[0]-translated;*,$shlibname-components.OPT;*
1004         PURGE $shlibname.EXE,$shlibname.MAP
1005 EOF
1006         . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1007         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1008 EOF
1009         );
1010   }
1011   sub obj2dso {
1012       my %args = @_;
1013       my $dsoname = platform->dsoname($args{lib});
1014       my $dso = platform->dso($args{lib});
1015       my @objs = map { platform->convertext($_) }
1016                  grep { platform->isobj($_) }
1017                  @{$args{objs}};
1018       my @defs = map { platform->convertext($_) }
1019                  grep { platform->isdef($_) }
1020                  @{$args{objs}};
1021       my @deps = compute_lib_depends(@{$args{deps}});
1022       my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
1023       die "More than one symbol vector" if scalar @defs > 1;
1024       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
1025       # The "[]" hack is because in .OPT files, each line inherits the
1026       # previous line's file spec as default, so if no directory spec
1027       # is present in the current line and the previous line has one that
1028       # doesn't apply, you're in for a surprise.
1029       my $write_opt1 =
1030           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1031                                  "WRITE OPT_FILE \"$x" } @objs).
1032           "\"";
1033       my $write_opt2 =
1034           join("\n\t", map { my $x = $_->{lib} =~ /\[/
1035                                  ? $_->{lib} : "[]".$_->{lib};
1036                              $x =~ s|(\.EXE)|$1/SHARE|;
1037                              $x =~ s|(\.OLB)|$1/LIB|;
1038                              "WRITE OPT_FILE \"$x\"" } @deps)
1039           || "\@ !";
1040       return <<"EOF"
1041 $dso : $deps
1042         OPEN/WRITE/SHARE=READ OPT_FILE $dsoname-components.OPT
1043         $write_opt1
1044         $write_opt2
1045         CLOSE OPT_FILE
1046         LINK \$(DSO_LDFLAGS)/SHARE=\$\@ $defs[0]/OPT,-
1047                 $dsoname-components.OPT/OPT \$(DSO_EX_LIBS)
1048         - PURGE $dsoname.EXE,$dsoname.OPT,$dsoname.MAP
1049 EOF
1050         . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1051         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1052 EOF
1053         );
1054   }
1055   sub obj2lib {
1056       my %args = @_;
1057       my $lib = platform->staticlib($args{lib});
1058       my @objs = map { platform->convertext($_) }
1059                  grep { platform->isobj($_) }
1060                  @{$args{objs}};
1061       my $objs = join(", -\n\t\t", @objs);
1062       my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib $_" } @objs));
1063       return <<"EOF";
1064 $lib : $objs
1065         LIBRARY/CREATE/OBJECT $lib
1066         $fill_lib
1067         - PURGE $lib
1068 EOF
1069   }
1070   sub obj2bin {
1071       my %args = @_;
1072       my $bin = platform->bin($args{bin});
1073       my $binname = platform->binname($args{bin});
1074       my @objs = map { platform->convertext($_) }
1075                  grep { platform->isobj($_) }
1076                  @{$args{objs}};
1077       my $objs = join(",", @objs);
1078       my @deps = compute_lib_depends(@{$args{deps}});
1079       my $deps = join(", -\n\t\t", @objs, map { $_->{lib} } @deps);
1080
1081       my $olb_count = scalar grep(m|\.OLB$|, map { $_->{lib} } @deps);
1082       my $analyse_objs = "@ !";
1083       if ($olb_count > 0) {
1084           my $analyse_quals =
1085               $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
1086           $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
1087       }
1088       # The "[]" hack is because in .OPT files, each line inherits the
1089       # previous line's file spec as default, so if no directory spec
1090       # is present in the current line and the previous line has one that
1091       # doesn't apply, you're in for a surprise.
1092       my $write_opt1 =
1093           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1094                                  "\@ WRITE OPT_FILE \"$x" } @objs).
1095           "\"";
1096       my $write_opt2 =
1097           join("\n\t", "WRITE OPT_FILE \"CASE_SENSITIVE=YES\"",
1098                        map { my @lines = ();
1099                              use Data::Dumper;
1100                              print STDERR "DEBUG: ",Dumper($_);
1101                              my $x = $_->{lib} =~ /\[/
1102                                  ? $_->{lib} : "[]".$_->{lib};
1103                              print STDERR "DEBUG: ",Dumper($x);
1104                              if ($x =~ m|\.EXE$|) {
1105                                  push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\"";
1106                              } elsif ($x =~ m|\.OLB$|) {
1107                                  # Special hack to include the MAIN object
1108                                  # module explicitly.  This will only be done
1109                                  # if there isn't a 'main' in the program's
1110                                  # object modules already.
1111                                  my $main = $_->{attrs}->{has_main}
1112                                      ? '/INCLUDE=main' : '';
1113                                  push @lines, 
1114                                      "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB$main\"",
1115                                      "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\""
1116                              }
1117                              @lines
1118                            } @deps)
1119           || "\@ !";
1120       # The linking commands looks a bit complex, but it's for good reason.
1121       # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
1122       # bar.obj happens to have a symbol that also exists in libsomething.exe,
1123       # the linker will warn about it, loudly, and will then choose to pick
1124       # the first copy encountered (the one in bar.obj in this example).
1125       # On Unix and on Windows, the corresponding maneuvre goes through
1126       # silently with the same effect.
1127       # With some test programs, made for checking the internals of OpenSSL,
1128       # we do this kind of linking deliberately, picking a few specific object
1129       # files from within [.crypto] or [.ssl] so we can reach symbols that are
1130       # otherwise unreachable (since the shareable images only exports the
1131       # symbols listed in [.util]*.num), and then with the shared libraries
1132       # themselves.  So we need to silence the warning about multiply defined
1133       # symbols, to mimic the way linking work on Unix and Windows, and so
1134       # the build isn't interrupted (MMS stops when warnings are signaled,
1135       # by default), and so someone building doesn't have to worry where it
1136       # isn't necessary.  If there are other warnings, however, we show them
1137       # and let it break the build.
1138       return <<"EOF"
1139 $bin : $deps
1140         $analyse_objs
1141         @ OPEN/WRITE/SHARE=READ OPT_FILE $binname.OPT
1142         $write_opt1
1143         $write_opt2
1144         @ CLOSE OPT_FILE
1145         TYPE $binname.OPT ! For debugging
1146         - pipe SPAWN/WAIT/NOLOG/OUT=$binname.LINKLOG -
1147                     LINK \$(BIN_LDFLAGS)/EXEC=\$\@ $binname.OPT/OPT \$(BIN_EX_LIBS) ; -
1148                link_status = \$status ; link_severity = link_status .AND. 7
1149         @ search_severity = 1
1150         -@ IF link_severity .EQ. 0 THEN -
1151                 pipe SEARCH $binname.LINKLOG "%","-"/MATCH=AND | -
1152                      SPAWN/WAIT/NOLOG/OUT=NLA0: -
1153                           SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
1154                      search_severity = \$severity
1155         @ ! search_severity is 3 when the last search didn't find any matching
1156         @ ! string: %SEARCH-I-NOMATCHES, no strings matched
1157         @ ! If that was the result, we pretend linking got through without
1158         @ ! fault or warning.
1159         @ IF search_severity .EQ. 3 THEN link_severity = 1
1160         @ ! At this point, if link_severity shows that there was a fault
1161         @ ! or warning, make sure to restore the linking status.
1162         -@ IF .NOT. link_severity THEN TYPE $binname.LINKLOG
1163         -@ DELETE $binname.LINKLOG;*
1164         @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
1165         - PURGE $bin,$binname.OPT
1166 EOF
1167       . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1168         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1169 EOF
1170         );
1171   }
1172   sub in2script {
1173       my %args = @_;
1174       my $script = $args{script};
1175       return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
1176       my $sources = join(" ", @{$args{sources}});
1177       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1178                                            "util", "dofile.pl")),
1179                            rel2abs($config{builddir}));
1180       return <<"EOF";
1181 $script : $sources
1182         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
1183             "-o$target{build_file}" $sources > $script
1184         SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
1185         PURGE $script
1186 EOF
1187   }
1188   ""    # Important!  This becomes part of the template result.
1189 -}