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