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