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