[PROV][KEYMGMT][EC] Import/export of priv_key as padded const time BN
[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) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
355         $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
356         $(NODEBUG) internal_inc1 = F$PARSE("[.crypto.include.internal]","A.;",,,"SYNTAX_ONLY") - "A.;"
357         $(NODEBUG) internal_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
358         $(NODEBUG) internal_inc3 = F$PARSE("{- catdir($config{sourcedir},"[.crypto.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
359         $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
360         $(NODEBUG) DEFINE internal 'internal_inc1','internal_inc2','internal_inc3'
361         $(NODEBUG) staging_dir = "$(DESTDIR)"
362         $(NODEBUG) staging_instdir = ""
363         $(NODEBUG) staging_datadir = ""
364         $(NODEBUG) IF staging_dir .NES. "" THEN -
365                 staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
366         $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
367                 staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
368         $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
369                 staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
370         $(NODEBUG) IF staging_dir .NES. "" THEN -
371                 staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
372         $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
373                 staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
374         $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
375                 staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
376         $(NODEBUG) !
377         $(NODEBUG) ! Installation logical names
378         $(NODEBUG) !
379         $(NODEBUG) installtop = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
380         $(NODEBUG) datatop = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
381         $(NODEBUG) DEFINE ossl_installroot 'installtop'
382         $(NODEBUG) DEFINE ossl_dataroot 'datatop'
383         $(NODEBUG) !
384         $(NODEBUG) ! Figure out the architecture
385         $(NODEBUG) !
386         $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
387         $(NODEBUG) !
388         $(NODEBUG) ! Set up logical names for the libraries, so LINK and
389         $(NODEBUG) ! running programs can use them.
390         $(NODEBUG) !
391         $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } @shlibs) || "!" -}
392
393 .LAST :
394         $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -}
395         $(NODEBUG) DEASSIGN ossl_dataroot
396         $(NODEBUG) DEASSIGN ossl_installroot
397         $(NODEBUG) DEASSIGN internal
398         $(NODEBUG) DEASSIGN openssl
399 .DEFAULT :
400         @ ! MMS cannot handle no actions...
401
402 # The main targets ###################################################
403
404 {- dependmagic('build_sw'); -} : build_libs_nodep, build_modules_nodep, build_programs_nodep
405 {- dependmagic('build_libs'); -} : build_libs_nodep
406 {- dependmagic('build_modules'); -} : build_modules_nodep
407 {- dependmagic('build_programs'); -} : build_programs_nodep
408
409 build_generated : $(GENERATED_MANDATORY)
410 build_libs_nodep : $(LIBS), $(SHLIBS)
411 build_modules_nodep : $(MODULES)
412 build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
413
414 build_docs: build_html_docs
415 build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
416
417 # Kept around for backward compatibility
418 build_apps build_tests : build_programs
419
420 # Convenience target to prebuild all generated files, not just the mandatory
421 # ones
422 build_all_generated : $(GENERATED_MANDATORY) $(GENERATED) build_docs
423         @ ! {- output_off() if $disabled{makedepend}; "" -}
424         @ WRITE SYS$OUTPUT "Warning: consider configuring with no-makedepend, because if"
425         @ WRITE SYS$OUTPUT "         target system doesn't have $(PERL),"
426         @ WRITE SYS$OUTPUT "         then make will fail..."
427         @ ! {- output_on() if $disabled{makedepend}; "" -}
428
429 all : build_sw build_docs
430
431 test : tests
432 {- dependmagic('tests'); -} : build_programs_nodep, build_modules_nodep
433         @ ! {- output_off() if $disabled{tests}; "" -}
434         DEFINE SRCTOP {- sourcedir() -}
435         DEFINE BLDTOP {- builddir() -}
436         DEFINE OPENSSL_ENGINES {- builddir("engines") -}
437         DEFINE OPENSSL_MODULES {- builddir("providers") -}
438         IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
439         $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
440         DEASSIGN OPENSSL_MODULES
441         DEASSIGN OPENSSL_ENGINES
442         DEASSIGN BLDTOP
443         DEASSIGN SRCTOP
444         @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
445         @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
446         @ ! {- output_on() if !$disabled{tests}; "" -}
447
448 list-tests :
449         @ ! {- output_off() if $disabled{tests}; "" -}
450         @ DEFINE SRCTOP {- sourcedir() -}
451         @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
452         @ DEASSIGN SRCTOP
453         @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
454         @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
455         @ ! {- output_on() if !$disabled{tests}; "" -}
456
457 install : install_sw install_ssldirs install_docs install_final
458
459 install_final :
460         @ WRITE SYS$OUTPUT ""
461         @ WRITE SYS$OUTPUT "######################################################################"
462         @ WRITE SYS$OUTPUT ""
463         @ IF "$(DESTDIR)" .EQS. "" THEN -
464              PIPE ( WRITE SYS$OUTPUT "Installation complete" ; -
465                     WRITE SYS$OUTPUT "" ; -
466                     WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
467                     WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
468                     WRITE SYS$OUTPUT "" )
469         @ IF "$(DESTDIR)" .NES. "" THEN -
470              PIPE ( WRITE SYS$OUTPUT "Staging installation complete" ; -
471                     WRITE SYS$OUTPUT "" ; -
472                     WRITE SYS$OUTPUT "Finish or package in such a way that the contents of the directory tree" ; -
473                     WRITE SYS$OUTPUT staging_instdir ; -
474                     WRITE SYS$OUTPUT "ends up in $(INSTALLTOP)," ; -
475                     WRITE SYS$OUTPUT "and that the contents of the contents of the directory tree" ; -
476                     WRITE SYS$OUTPUT staging_datadir ; -
477                     WRITE SYS$OUTPUT "ends up in $(OPENSSLDIR)" ; -
478                     WRITE SYS$OUTPUT "" ; -
479                     WRITE SYS$OUTPUT "When in its final destination," ; -
480                     WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
481                     WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
482                     WRITE SYS$OUTPUT "" )
483
484 check_install :
485         spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
486
487 uninstall : uninstall_docs uninstall_sw
488
489 # Because VMS wants the generation number (or *) to delete files, we can't
490 # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(MODULES) directly.
491 libclean :
492         {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
493         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
494
495 clean : libclean
496         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man1}}) || "@ !" -}
497         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man3}}) || "@ !" -}
498         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man5}}) || "@ !" -}
499         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man7}}) || "@ !" -}
500         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
501         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{modules}}) || "@ !" -}
502         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
503         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -}
504         {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
505         - DELETE [...]*.MAP;*
506         - DELETE [...]*.D;*
507         - DELETE [...]*.OBJ;*,*.LIS;*
508         - DELETE []CXX$DEMANGLER_DB.;*
509         - DELETE [.VMS]openssl_startup.com;*
510         - DELETE [.VMS]openssl_shutdown.com;*
511         - DELETE []vmsconfig.pm;*
512
513 distclean : clean
514         - DELETE configdata.pm;*
515         - DELETE descrip.mms;*
516
517 depend : descrip.mms
518 descrip.mms : FORCE
519         @ ! {- output_off() if $disabled{makedepend}; "" -}
520         @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "VMS C"
521         @ ! {- output_on() if $disabled{makedepend}; "" -}
522
523 # Install helper targets #############################################
524
525 install_sw : install_dev install_engines install_runtime -
526              install_startup install_ivp
527
528 uninstall_sw : uninstall_dev uninstall_engines uninstall_runtime -
529                uninstall_startup uninstall_ivp
530
531 install_docs : install_html_docs
532
533 uninstall_docs : uninstall_html_docs
534
535 install_ssldirs : check_INSTALLTOP
536         - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
537         IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
538                 CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
539         IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
540                 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
541         IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
542                 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
543         COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
544         @ ! Install configuration file
545         COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
546                 ossl_dataroot:[000000]openssl.cnf-dist
547         IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN -
548                 COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
549                         ossl_dataroot:[000000]openssl.cnf
550         @ ! Install CTLOG configuration file
551         COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
552                 ossl_dataroot:[000000]ct_log_list.cnf-dist
553         IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN -
554                 COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
555                         ossl_dataroot:[000000]ct_log_list.cnf
556
557 install_dev : check_INSTALLTOP install_runtime_libs
558         @ WRITE SYS$OUTPUT "*** Installing development files"
559         @ ! Install header files
560         - CREATE/DIR ossl_installroot:[include.openssl]
561         COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
562         @ ! Install static (development) libraries
563         - CREATE/DIR ossl_installroot:[LIB.'arch']
564         {- join("\n        ",
565                 map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
566                 @install_libs) -}
567
568 install_engines : check_INSTALLTOP install_runtime_libs build_modules
569         @ {- output_off() unless scalar @install_engines; "" -} !
570         @ WRITE SYS$OUTPUT "*** Installing ENGINE modules"
571         - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
572         {- join("\n        ",
573                 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
574                 @install_engines) -}
575         @ {- output_on() unless scalar @install_engines; "" -} !
576
577 install_runtime : install_programs
578
579 install_runtime_libs : check_INSTALLTOP build_libs
580         @ {- output_off() if $disabled{shared}; "" -} !
581         @ WRITE SYS$OUTPUT "*** Installing shareable images"
582         @ ! Install shared (runtime) libraries
583         - CREATE/DIR ossl_installroot:[LIB.'arch']
584         {- join("\n        ",
585                 map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
586                 @install_shlibs) -}
587         @ {- output_on() if $disabled{shared}; "" -} !
588
589 install_programs : check_INSTALLTOP install_runtime_libs build_programs
590         @ {- output_off() if $disabled{apps}; "" -} !
591         @ ! Install the main program
592         - CREATE/DIR ossl_installroot:[EXE.'arch']
593         COPY/PROT=W:RE [.APPS]openssl.EXE -
594                 ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
595         @ ! Install scripts
596         COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
597         @ ! {- output_on() if $disabled{apps}; "" -}
598
599 install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
600                  [.VMS]openssl_utils.com, check_INSTALLTOP
601         - CREATE/DIR ossl_installroot:[SYS$STARTUP]
602         COPY/PROT=W:RE [.VMS]openssl_startup.com -
603                 ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com
604         COPY/PROT=W:RE [.VMS]openssl_shutdown.com -
605                 ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com
606         COPY/PROT=W:RE [.VMS]openssl_utils.com -
607                 ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com
608
609 install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
610         - CREATE/DIR ossl_installroot:[SYSTEST]
611         COPY/PROT=W:RE [.VMS]openssl_ivp.com -
612                 ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
613
614 [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
615         - CREATE/DIR [.VMS]
616         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
617                 {- sourcefile("VMS", "openssl_startup.com.in") -} -
618                 > [.VMS]openssl_startup.com
619
620 [.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -}
621         - CREATE/DIR [.VMS]
622         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
623                 {- sourcefile("VMS", "openssl_utils.com.in") -} -
624                 > [.VMS]openssl_utils.com
625
626 [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
627         - CREATE/DIR [.VMS]
628         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
629                 {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
630                 > [.VMS]openssl_shutdown.com
631
632 [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -}
633         - CREATE/DIR [.VMS]
634         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
635                 {- sourcefile("VMS", "openssl_ivp.com.in") -} -
636                 > [.VMS]openssl_ivp.com
637
638 vmsconfig.pm : configdata.pm
639         OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
640         WRITE CONFIG "package vmsconfig;"
641         WRITE CONFIG "use strict; use warnings;"
642         WRITE CONFIG "use Exporter;"
643         WRITE CONFIG "our @ISA = qw(Exporter);"
644         WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
645         WRITE CONFIG "our %config = ("
646         WRITE CONFIG "  target => '","{- $config{target} -}","',"
647         WRITE CONFIG "  version => '","{- $config{version} -}","',"
648         WRITE CONFIG "  shlib_version => '","{- $config{shlib_version} -}","',"
649         WRITE CONFIG "  shlib_major => '","{- $config{shlib_major} -}","',"
650         WRITE CONFIG "  shlib_minor => '","{- $config{shlib_minor} -}","',"
651         WRITE CONFIG "  no_shared => '","{- $disabled{shared} -}","',"
652         WRITE CONFIG "  INSTALLTOP => '$(INSTALLTOP)',"
653         WRITE CONFIG "  OPENSSLDIR => '$(OPENSSLDIR)',"
654         WRITE CONFIG "  pointer_size => '","{- $target{pointer_size} -}","',"
655         WRITE CONFIG ");"
656         WRITE CONFIG "our %target = ();"
657         WRITE CONFIG "our %disabled = ();"
658         WRITE CONFIG "our %withargs = ();"
659         WRITE CONFIG "our %unified_info = ();"
660         WRITE CONFIG "1;"
661         CLOSE CONFIG
662
663 install_html_docs : check_INSTALLTOP build_html_docs
664         @ WRITE SYS$OUTPUT "*** Installing HTML docs"
665         - CREATE/DIR ossl_installroot:[HTML.MAN1]
666         - CREATE/DIR ossl_installroot:[HTML.MAN3]
667         - CREATE/DIR ossl_installroot:[HTML.MAN5]
668         - CREATE/DIR ossl_installroot:[HTML.MAN7]
669         {- join("\n        ",
670                 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN1]" }
671                   @{$unified_info{htmldocs}->{man1}} ),
672                 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN3]" }
673                   @{$unified_info{htmldocs}->{man3}} ),
674                 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN5]" }
675                   @{$unified_info{htmldocs}->{man5}} ),
676                 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN7]" }
677                   @{$unified_info{htmldocs}->{man7}} )) -}
678
679 check_INSTALLTOP :
680         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
681                 WRITE SYS$ERROR "INSTALLTOP should not be empty"
682         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
683                 EXIT %x10000002
684
685 # Helper targets #####################################################
686
687 # Developer targets ##################################################
688
689 debug_logicals :
690         SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
691
692 # Building targets ###################################################
693
694 configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
695         perl configdata.pm -r
696         @ WRITE SYS$OUTPUT "*************************************************"
697         @ WRITE SYS$OUTPUT "***                                           ***"
698         @ WRITE SYS$OUTPUT "***   Please run the same mms command again   ***"
699         @ WRITE SYS$OUTPUT "***                                           ***"
700         @ WRITE SYS$OUTPUT "*************************************************"
701         @ PIPE ( EXIT %X10000000 )
702
703 reconfigure reconf :
704         perl configdata.pm -r
705
706 {-
707   use File::Basename;
708   use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
709
710   # Helper function to figure out dependencies on libraries
711   # It takes a list of library names and outputs a list of dependencies
712   sub compute_lib_depends {
713       # Depending on shared libraries:
714       # On Windows POSIX layers, we depend on {libname}.dll.a
715       # On Unix platforms, we depend on {shlibname}.so
716       return map {
717           { lib   => platform->sharedlib($_) // platform->staticlib($_),
718             attrs => $unified_info{attributes}->{libraries}->{$_} }
719       } @_;
720   }
721
722   # Helper function to deal with inclusion directory specs.
723   # We have to deal with two things:
724   # 1. comma separation and no possibility of trailing comma
725   # 2. no inclusion directories given at all
726   # 3. long compiler command lines
727   # To resolve 1, we need to iterate through the sources of inclusion
728   # directories, and only add a comma when needed.
729   # To resolve 2, we need to have a variable that will hold the whole
730   # inclusion qualifier, or be the empty string if there are no inclusion
731   # directories.  That's the symbol 'qual_includes' that's used in CPPFLAGS
732   # To resolve 3, we creata a logical name TMP_INCLUDES: to hold the list
733   # of inclusion directories.
734   #
735   # This function returns a list of two lists, one being the collection of
736   # commands to execute before the compiler is called, and the other being
737   # the collection of commands to execute after.  It takes as arguments the
738   # collection of strings to include as directory specs.
739   sub includes {
740       my @stuff = ( @_ );
741       my @before = (
742           'qual_includes :=',
743       );
744       my @after = (
745           'DELETE/SYMBOL/LOCAL qual_includes',
746       );
747
748       if (scalar @stuff > 0) {
749           push @before, 'tmp_includes := '.shift(@stuff);
750           while (@stuff) {
751               push @before, 'tmp_add := '.shift(@stuff);
752               push @before, 'IF tmp_includes .NES. "" .AND. tmp_add .NES. "" THEN tmp_includes = tmp_includes + ","';
753               push @before, 'tmp_includes = tmp_includes + tmp_add';
754           }
755           push @before, "IF tmp_includes .NES. \"\" THEN DEFINE tmp_includes 'tmp_includes'";
756           push @before, 'IF tmp_includes .NES. "" THEN qual_includes := /INCLUDE=(tmp_includes:)';
757           push @before, 'DELETE/SYMBOL/LOCAL tmp_includes';
758           push @before, 'DELETE/SYMBOL/LOCAL tmp_add';
759           push @after, 'DEASSIGN tmp_includes:'
760       }
761       return ([ @before ], [ @after ]);
762   }
763
764   sub generatesrc {
765       my %args = @_;
766       my $generator = join(" ", @{$args{generator}});
767       my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
768       my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
769
770       if ($args{src} =~ /\.html$/) {
771           my $title = basename($args{src}, ".html");
772           my $pod = $args{generator}->[0];
773           return <<"EOF";
774 $args{src}: $pod
775         pipe pod2html "--podroot=\$(SRCDIR)/doc" --htmldir=.. -
776                        --podpath=man1:man3:man5:man7 "--infile=$pod" -
777                       "--title=$title" -
778         | \$(PERL) -pe "s|href=""http://man\\.he\\.net/(man\d/[^""]+)(?:\\.html)?""|href=""../\$1.html|g;" -
779         > \$\@
780 EOF
781       } elsif (platform->isdef($args{src})) {
782           my $target = platform->def($args{src});
783           my $mkdef = sourcefile('util', 'mkdef.pl');
784           my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
785           my $ord_name =
786               $args{generator}->[1] || basename($args{product}, '.EXE');
787           my $case_insensitive =
788               $target{$args{intent}.'_cflags'} =~ m|/NAMES=[^/]*AS_IS|i
789               ? '' : ' --case-insensitive';
790           return <<"EOF";
791 $target : $args{generator}->[0] $deps $mkdef
792         \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name "--OS" "VMS"$case_insensitive > $target
793 EOF
794       } elsif (!platform->isasm($args{src})) {
795           my $target = $args{src};
796           if ($args{generator}->[0] =~ m|^.*\.in$|) {
797               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
798                                                    "util", "dofile.pl")),
799                                    rel2abs($config{builddir}));
800               my @modules = ( 'configdata.pm',
801                               grep { $_ =~ m|\.pm$| } @{$args{deps}} );
802               my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
803               @modules = map { '"-M'.basename($_, '.pm').'"' } @modules;
804               my $modules = join(' ', '', sort keys %moduleincs, @modules);
805               return <<"EOF";
806 $target : $args{generator}->[0] $deps
807         \$(PERL)$modules $dofile "-o$target{build_file}" $generator > \$\@
808 EOF
809           } else {
810               return <<"EOF";
811 $target : $args{generator}->[0] $deps
812         \$(PERL)$generator_incs $generator > \$\@
813 EOF
814           }
815       } else {
816           my $cppflags = {
817               shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
818               lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
819               dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
820               bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
821           } -> {$args{intent}};
822           my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
823                                      lib => '$(LIB_INCLUDES)',
824                                      dso => '$(DSO_INCLUDES)',
825                                      bin => '$(BIN_INCLUDES)' } -> {$args{intent}},
826                                    '$(CNF_INCLUDES)',
827                                    '$(INCLUDES)',
828                                    @{$args{incs}});
829           my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
830           my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
831           my $defs = join("", map { ",".$_ } @{$args{defs}});
832           my $target = platform->asm($args{src});
833
834           if ($args{generator}->[0] =~ /\.pl$/) {
835               $generator = '$(PERL)'.$generator_incs.' '.$generator
836                   .' '.$cppflags;
837           } elsif ($args{generator}->[0] =~ /\.S$/) {
838               $generator = undef;
839           } else {
840               die "Generator type for $src unknown: $generator\n";
841           }
842
843           if (defined($generator)) {
844               # If the target is named foo.S in build.info, we want to
845               # end up generating foo.s in two steps.
846               if ($args{src} =~ /\.S$/) {
847                    return <<"EOF";
848 $target : $args{generator}->[0] $deps
849         $generator \$\@-S
850         \@ $incs_on
851         \@ extradefines = "$defs"
852         PIPE \$(CPP) $cppflags \$\@-S | -
853              \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@-i
854         \@ DELETE/SYMBOL/LOCAL extradefines
855         \@ $incs_off
856         RENAME \$\@-i \$\@
857         DELETE \$\@-S;
858 EOF
859               }
860               # Otherwise....
861               return <<"EOF";
862 $target : $args{generator}->[0] $deps
863         \@ $incs_on
864         \@ extradefines = "$defs"
865         $generator \$\@
866         \@ DELETE/SYMBOL/LOCAL extradefines
867         \@ $incs_off
868 EOF
869           }
870           return <<"EOF";
871 $target : $args{generator}->[0] $deps
872         \@ $incs_on
873         \@ extradefines = "$defs"
874         SHOW SYMBOL qual_includes
875         PIPE \$(CPP) $cppflags $args{generator}->[0] | -
876         \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@
877         \@ DELETE/SYMBOL/LOCAL extradefines
878         \@ $incs_off
879 EOF
880       }
881   }
882
883   sub src2obj {
884       my $asmext = platform->asmext();
885       my %args = @_;
886       my @srcs =
887           map { my $x = $_;
888                 (platform->isasm($x) && grep { $x eq $_ } @generated)
889                 ? platform->asm($x) : $x }
890           ( @{$args{srcs}} );
891       my $obj = platform->obj($args{obj});
892       my $dep = platform->dep($args{obj});
893       my $deps = join(", -\n\t\t", @srcs, @{$args{deps}});
894
895       # Because VMS C isn't very good at combining a /INCLUDE path with
896       # #includes having a relative directory (like '#include "../foo.h"),
897       # the best choice is to move to the first source file's intended
898       # directory before compiling, and make sure to write the object file
899       # in the correct position (important when the object tree is other
900       # than the source tree).
901       my $forward = dirname($args{srcs}->[0]);
902       my $backward = abs2rel(rel2abs("."), rel2abs($forward));
903       my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
904       my $objn = basename($obj);
905       my $depd = abs2rel(rel2abs(dirname($dep)), rel2abs($forward));
906       my $depn = basename($dep);
907       my $srcs =
908           join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs);
909       my $before = $unified_info{before}->{$obj} || "\@ !";
910       my $after = $unified_info{after}->{$obj} || "\@ !";
911
912       my $cflags;
913       if ($args{attrs}->{noinst}) {
914           $cflags = { shlib => '$(NO_INST_LIB_CFLAGS)',
915                       lib => '$(NO_INST_LIB_CFLAGS)',
916                       dso => '$(NO_INST_DSO_CFLAGS)',
917                       bin => '$(NO_INST_BIN_CFLAGS)' } -> {$args{intent}};
918       } else {
919           $cflags = { shlib => '$(LIB_CFLAGS)',
920                       lib => '$(LIB_CFLAGS)',
921                       dso => '$(DSO_CFLAGS)',
922                       bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
923       }
924       $cflags .= { shlib => '$(LIB_CPPFLAGS)',
925                    lib => '$(LIB_CPPFLAGS)',
926                    dso => '$(DSO_CPPFLAGS)',
927                    bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
928       my $defs = join("", map { ",".$_ } @{$args{defs}});
929       my $asflags = { shlib => ' $(LIB_ASFLAGS)',
930                       lib => ' $(LIB_ASFLAGS)',
931                       dso => ' $(DSO_ASFLAGS)',
932                       bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
933
934       my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
935                                  lib => '$(LIB_INCLUDES)',
936                                  dso => '$(DSO_INCLUDES)',
937                                  bin => '$(BIN_INCLUDES)' } -> {$args{intent}},
938                                '$(INCLUDES)',
939                                map {
940                                    file_name_is_absolute($_)
941                                    ? $_ : catdir($backward,$_)
942                                } @{$args{incs}});
943       my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
944       my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
945
946       if ($srcs[0] =~ /\Q${asmext}\E$/) {
947           return <<"EOF";
948 $obj : $deps
949         ${before}
950         SET DEFAULT $forward
951         \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn} $srcs
952         SET DEFAULT $backward
953         ${after}
954         - PURGE $obj
955 EOF
956       } elsif ($srcs[0] =~ /.S$/) {
957          return <<"EOF";
958 $obj : $deps
959         ${before}
960         SET DEFAULT $forward
961         \@ $incs_on
962         \@ extradefines = "$defs"
963         PIPE \$(CPP) ${cflags} $srcs | -
964              \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" -
965              > ${objd}${objn}-asm
966         \@ DELETE/SYMBOL/LOCAL extradefines
967         \@ $incs_off
968         SET DEFAULT $backward
969         ${after}
970         \$(AS) $asflags \$(ASOUTFLAG)$obj $obj-asm
971         - PURGE $obj
972 EOF
973       }
974
975       my $depbuild = $disabled{makedepend} ? ""
976           : " /MMS=(FILE=${depd}${depn},TARGET=$obj)";
977
978       return <<"EOF";
979 $obj : $deps
980         ${before}
981         SET DEFAULT $forward
982         \@ $incs_on
983         \@ extradefines = "$defs"
984         \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn} /REPOSITORY=$backward $srcs
985         \@ DELETE/SYMBOL/LOCAL extradefines
986         \@ $incs_off
987         SET DEFAULT $backward
988         ${after}
989         - PURGE $obj
990 EOF
991   }
992   sub obj2shlib {
993       my %args = @_;
994       my $shlibname = platform->sharedname($args{lib});
995       my $shlib = platform->sharedlib($args{lib});
996       my @objs = map { platform->convertext($_) }
997                  grep { platform->isobj($_) }
998                  @{$args{objs}};
999       my @defs = map { platform->convertext($_) }
1000                  grep { platform->isdef($_) }
1001                  @{$args{objs}};
1002       my @deps = compute_lib_depends(@{$args{deps}});
1003       die "More than one symbol vector" if scalar @defs > 1;
1004       my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
1005       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
1006       my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
1007                                                      "VMS", "translatesyms.pl")),
1008                                      rel2abs($config{builddir}));
1009       # The "[]" hack is because in .OPT files, each line inherits the
1010       # previous line's file spec as default, so if no directory spec
1011       # is present in the current line and the previous line has one that
1012       # doesn't apply, you're in for a surprise.
1013       my $write_opt1 =
1014           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1015                                  "WRITE OPT_FILE \"$x" } @objs).
1016           "\"";
1017       my $write_opt2 =
1018           join("\n\t", map { my $x = $_->{lib} =~ /\[/
1019                                  ? $_->{lib} : "[]".$_->{lib};
1020                              $x =~ s|(\.EXE)|$1/SHARE|;
1021                              $x =~ s|(\.OLB)|$1/LIB|;
1022                              "WRITE OPT_FILE \"$x\"" } @deps)
1023           || "\@ !";
1024       return <<"EOF"
1025 $shlib : $deps
1026         \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
1027         OPEN/WRITE/SHARE=READ OPT_FILE $shlibname-components.OPT
1028         $write_opt1
1029         $write_opt2
1030         CLOSE OPT_FILE
1031         LINK \$(LIB_LDFLAGS)/SHARE=\$\@ $defs[0]-translated/OPT,-
1032                 $shlibname-components.OPT/OPT \$(LIB_EX_LIBS)
1033         DELETE $defs[0]-translated;*,$shlibname-components.OPT;*
1034         PURGE $shlibname.EXE,$shlibname.MAP
1035 EOF
1036         . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1037         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1038 EOF
1039         );
1040   }
1041   sub obj2dso {
1042       my %args = @_;
1043       my $dsoname = platform->dsoname($args{module});
1044       my $dso = platform->dso($args{module});
1045       my @objs = map { platform->convertext($_) }
1046                  grep { platform->isobj($_) }
1047                  @{$args{objs}};
1048       my @defs = map { platform->convertext($_) }
1049                  grep { platform->isdef($_) }
1050                  @{$args{objs}};
1051       my @deps = compute_lib_depends(@{$args{deps}});
1052       my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
1053       die "More than one symbol vector" if scalar @defs > 1;
1054       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
1055       # The "[]" hack is because in .OPT files, each line inherits the
1056       # previous line's file spec as default, so if no directory spec
1057       # is present in the current line and the previous line has one that
1058       # doesn't apply, you're in for a surprise.
1059       my $write_opt1 =
1060           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1061                                  "WRITE OPT_FILE \"$x" } @objs).
1062           "\"";
1063       my $write_opt2 =
1064           join("\n\t", map { my $x = $_->{lib} =~ /\[/
1065                                  ? $_->{lib} : "[]".$_->{lib};
1066                              $x =~ s|(\.EXE)|$1/SHARE|;
1067                              $x =~ s|(\.OLB)|$1/LIB|;
1068                              "WRITE OPT_FILE \"$x\"" } @deps)
1069           || "\@ !";
1070       return <<"EOF"
1071 $dso : $deps
1072         OPEN/WRITE/SHARE=READ OPT_FILE $dsoname-components.OPT
1073         $write_opt1
1074         $write_opt2
1075         CLOSE OPT_FILE
1076         LINK \$(DSO_LDFLAGS)/SHARE=\$\@ $defs[0]/OPT,-
1077                 $dsoname-components.OPT/OPT \$(DSO_EX_LIBS)
1078         - PURGE $dsoname.EXE,$dsoname.OPT,$dsoname.MAP
1079 EOF
1080         . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1081         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1082 EOF
1083         );
1084   }
1085   sub obj2lib {
1086       my %args = @_;
1087       my $lib = platform->staticlib($args{lib});
1088       my @objs = map { platform->convertext($_) }
1089                  grep { platform->isobj($_) }
1090                  @{$args{objs}};
1091       my $objs = join(", -\n\t\t", @objs);
1092       my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib $_" } @objs));
1093       return <<"EOF";
1094 $lib : $objs
1095         LIBRARY/CREATE/OBJECT $lib
1096         $fill_lib
1097         - PURGE $lib
1098 EOF
1099   }
1100   sub obj2bin {
1101       my %args = @_;
1102       my $bin = platform->bin($args{bin});
1103       my $binname = platform->binname($args{bin});
1104       my @objs = map { platform->convertext($_) }
1105                  grep { platform->isobj($_) }
1106                  @{$args{objs}};
1107       my $objs = join(",", @objs);
1108       my @deps = compute_lib_depends(@{$args{deps}});
1109       my $deps = join(", -\n\t\t", @objs, map { $_->{lib} } @deps);
1110
1111       my $olb_count = scalar grep(m|\.OLB$|, map { $_->{lib} } @deps);
1112       my $analyse_objs = "@ !";
1113       if ($olb_count > 0) {
1114           my $analyse_quals =
1115               $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
1116           $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
1117       }
1118       # The "[]" hack is because in .OPT files, each line inherits the
1119       # previous line's file spec as default, so if no directory spec
1120       # is present in the current line and the previous line has one that
1121       # doesn't apply, you're in for a surprise.
1122       my $write_opt1 =
1123           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1124                                  "\@ WRITE OPT_FILE \"$x" } @objs).
1125           "\"";
1126       my $write_opt2 =
1127           join("\n\t", "WRITE OPT_FILE \"CASE_SENSITIVE=YES\"",
1128                        map { my @lines = ();
1129                              use Data::Dumper;
1130                              my $x = $_->{lib} =~ /\[/
1131                                  ? $_->{lib} : "[]".$_->{lib};
1132                              if ($x =~ m|\.EXE$|) {
1133                                  push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\"";
1134                              } elsif ($x =~ m|\.OLB$|) {
1135                                  # Special hack to include the MAIN object
1136                                  # module explicitly.  This will only be done
1137                                  # if there isn't a 'main' in the program's
1138                                  # object modules already.
1139                                  my $main = $_->{attrs}->{has_main}
1140                                      ? '/INCLUDE=main' : '';
1141                                  push @lines,
1142                                      "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB$main\"",
1143                                      "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\""
1144                              }
1145                              @lines
1146                            } @deps)
1147           || "\@ !";
1148       # The linking commands looks a bit complex, but it's for good reason.
1149       # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
1150       # bar.obj happens to have a symbol that also exists in libsomething.exe,
1151       # the linker will warn about it, loudly, and will then choose to pick
1152       # the first copy encountered (the one in bar.obj in this example).
1153       # On Unix and on Windows, the corresponding maneuvre goes through
1154       # silently with the same effect.
1155       # With some test programs, made for checking the internals of OpenSSL,
1156       # we do this kind of linking deliberately, picking a few specific object
1157       # files from within [.crypto] or [.ssl] so we can reach symbols that are
1158       # otherwise unreachable (since the shareable images only exports the
1159       # symbols listed in [.util]*.num), and then with the shared libraries
1160       # themselves.  So we need to silence the warning about multiply defined
1161       # symbols, to mimic the way linking work on Unix and Windows, and so
1162       # the build isn't interrupted (MMS stops when warnings are signaled,
1163       # by default), and so someone building doesn't have to worry where it
1164       # isn't necessary.  If there are other warnings, however, we show them
1165       # and let it break the build.
1166       return <<"EOF"
1167 $bin : $deps
1168         $analyse_objs
1169         @ OPEN/WRITE/SHARE=READ OPT_FILE $binname.OPT
1170         $write_opt1
1171         $write_opt2
1172         @ CLOSE OPT_FILE
1173         TYPE $binname.OPT ! For debugging
1174         - pipe SPAWN/WAIT/NOLOG/OUT=$binname.LINKLOG -
1175                     LINK \$(BIN_LDFLAGS)/EXEC=\$\@ $binname.OPT/OPT \$(BIN_EX_LIBS) ; -
1176                link_status = \$status ; link_severity = link_status .AND. 7
1177         @ search_severity = 1
1178         -@ IF link_severity .EQ. 0 THEN -
1179                 pipe SEARCH $binname.LINKLOG "%","-"/MATCH=AND | -
1180                      SPAWN/WAIT/NOLOG/OUT=NLA0: -
1181                           SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
1182                      search_severity = \$severity
1183         @ ! search_severity is 3 when the last search didn't find any matching
1184         @ ! string: %SEARCH-I-NOMATCHES, no strings matched
1185         @ ! If that was the result, we pretend linking got through without
1186         @ ! fault or warning.
1187         @ IF search_severity .EQ. 3 THEN link_severity = 1
1188         @ ! At this point, if link_severity shows that there was a fault
1189         @ ! or warning, make sure to restore the linking status.
1190         -@ IF .NOT. link_severity THEN TYPE $binname.LINKLOG
1191         -@ DELETE $binname.LINKLOG;*
1192         @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
1193         - PURGE $bin,$binname.OPT
1194 EOF
1195       . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1196         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1197 EOF
1198         );
1199   }
1200   sub in2script {
1201       my %args = @_;
1202       my $script = $args{script};
1203       return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
1204       my $sources = join(" ", @{$args{sources}});
1205       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1206                                            "util", "dofile.pl")),
1207                            rel2abs($config{builddir}));
1208       return <<"EOF";
1209 $script : $sources
1210         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
1211             "-o$target{build_file}" $sources > $script
1212         SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
1213         PURGE $script
1214 EOF
1215   }
1216   ""    # Important!  This becomes part of the template result.
1217 -}