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