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