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