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