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