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