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