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