VMS libtestutil: look for lower case "main"
[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 prefix, claimed when speaking with the VSI folks Tuesday
9   # January 26th 2016
10   our $osslprefix = 'OSSL$';
11   (our $osslprefix_q = $osslprefix) =~ s/\$/\\\$/;
12
13   our $sover_dirname = sprintf "%02d%02d", split(/\./, $config{shlib_version_number});
14   our $osslver = sprintf "%02d%02d", split(/\./, $config{version});
15
16   our $sourcedir = $config{sourcedir};
17   our $builddir = $config{builddir};
18   sub sourcefile {
19       catfile($sourcedir, @_);
20   }
21   sub buildfile {
22       catfile($builddir, @_);
23   }
24   sub sourcedir {
25       catdir($sourcedir, @_);
26   }
27   sub builddir {
28       catdir($builddir, @_);
29   }
30   sub tree {
31       (my $x = shift) =~ s|\]$|...]|;
32       $x
33   }
34   sub move {
35       my $f = catdir(@_);
36       my $b = abs2rel(rel2abs("."),rel2abs($f));
37       $sourcedir = catdir($b,$sourcedir)
38           if !file_name_is_absolute($sourcedir);
39       $builddir = catdir($b,$builddir)
40           if !file_name_is_absolute($builddir);
41       "";
42   }
43
44   # Because we need to make two computations of these data,
45   # we store them in arrays for reuse
46   our @libs =
47       map { (my $x = $_) =~ s/\.a$//; $x }
48       @{$unified_info{libraries}};
49   our @shlibs =
50       map { $unified_info{sharednames}->{$_} || () }
51       grep(!/\.a$/, @{$unified_info{libraries}});
52   our @install_libs =
53       map { (my $x = $_) =~ s/\.a$//; $x }
54       @{$unified_info{install}->{libraries}};
55   our @install_shlibs =
56       map { $unified_info{sharednames}->{$_} || () }
57       grep(!/\.a$/, @{$unified_info{install}->{libraries}});
58
59   # This is a horrible hack, but is needed because recursive inclusion of files
60   # in different directories does not work well with HP C.
61   my $sd = sourcedir("crypto", "async", "arch");
62   foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) {
63       (my $x = $_) =~ s|\.o$|.OBJ|;
64       $unified_info{before}->{$x}
65           = qq(arch_include = F\$PARSE("$sd","A.;",,,"SYNTAX_ONLY") - "A.;"
66         define arch 'arch_include');
67       $unified_info{after}->{$x}
68           = qq(deassign arch);
69   }
70   my $sd1 = sourcedir("ssl","record");
71   my $sd2 = sourcedir("ssl","statem");
72   my @ssl_locl_users = grep(/^\[\.(?:ssl\.(?:record|statem)|test)\].*\.o$/,
73                             keys %{$unified_info{sources}});
74   foreach (@ssl_locl_users) {
75       (my $x = $_) =~ s|\.o$|.OBJ|;
76       $unified_info{before}->{$x}
77           = qq(record_include = F\$PARSE("$sd1","A.;",,,"SYNTAX_ONLY") - "A.;"
78         define record 'record_include'
79         statem_include = F\$PARSE("$sd2","A.;",,,"SYNTAX_ONLY") - "A.;"
80         define statem 'statem_include');
81       $unified_info{after}->{$x}
82           = qq(deassign statem
83         deassign record);
84   }
85   # This makes sure things get built in the order they need
86   # to. You're welcome.
87   sub dependmagic {
88       my $target = shift;
89
90       return "$target : build_generated\n\t\pipe \$(MMS) \$(MMSQUALIFIERS) depend && \$(MMS) \$(MMSQUALIFIERS) _$target\n_$target";
91   }
92   #use Data::Dumper;
93   #print STDERR "DEBUG: before:\n", Dumper($unified_info{before});
94   #print STDERR "DEBUG: after:\n", Dumper($unified_info{after});
95   "";
96 -}
97 PLATFORM={- $config{target} -}
98 OPTIONS={- $config{options} -}
99 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
100 SRCDIR={- $config{sourcedir} -}
101 BLDDIR={- $config{builddir} -}
102
103 # Allow both V and VERBOSE to indicate verbosity.  This only applies
104 # to testing.
105 VERBOSE=$(V)
106
107 VERSION={- $config{version} -}
108 MAJOR={- $config{major} -}
109 MINOR={- $config{minor} -}
110 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
111 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
112 SHLIB_MAJOR={- $config{shlib_major} -}
113 SHLIB_MINOR={- $config{shlib_minor} -}
114 SHLIB_TARGET={- $target{shared_target} -}
115
116 EXE_EXT=.EXE
117 LIB_EXT=.OLB
118 SHLIB_EXT=.EXE
119 OBJ_EXT=.OBJ
120 DEP_EXT=.D
121
122 LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @libs) -}
123 SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
124 ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{engines}}) -}
125 PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -}
126 SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
127 {- output_off() if $disabled{makedepend}; "" -}
128 DEPS={- our @deps = map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
129                     grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
130                     keys %{$unified_info{sources}};
131         join(", ", map { "-\n\t".$_ } @deps); -}
132 {- output_on() if $disabled{makedepend}; "" -}
133 GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
134 GENERATED={- # common0.tmpl provides @generated
135              join(", ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; "-\n\t".$x }
136                         @generated) -}
137
138 INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
139 INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
140 INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{engines}}) -}
141 INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{programs}}) -}
142 {- output_off() if $disabled{apps}; "" -}
143 BIN_SCRIPTS=[.tools]c_rehash.pl
144 MISC_SCRIPTS=[.apps]CA.pl, [.apps]tsget.pl
145 {- output_on() if $disabled{apps}; "" -}
146
147 APPS_OPENSSL={- use File::Spec::Functions;
148                 catfile("apps","openssl") -}
149
150 # DESTDIR is for package builders so that they can configure for, say,
151 # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
152 # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
153 # MMS with /MACROS=(DESTDIR=STAGING:[USER]).  The result will end up in
154 # STAGING:[USER.OPENSSL].
155 # Normally it is left empty.
156 DESTDIR=
157
158 # Do not edit this manually. Use Configure --prefix=DIR to change this!
159 INSTALLTOP={- our $installtop =
160                   catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
161               $installtop -}
162 SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
163 # This is the standard central area to store certificates, private keys...
164 OPENSSLDIR={- catdir($config{openssldir}) or
165               $config{prefix} ? catdir($config{prefix},"COMMON")
166                               : "SYS\$COMMON:[OPENSSL-COMMON]" -}
167 # The same, but for C
168 OPENSSLDIR_C={- $osslprefix -}DATAROOT:[000000]
169 # Where installed engines reside, for C
170 ENGINESDIR_C={- $osslprefix -}ENGINES{- $sover_dirname.$target{pointer_size} -}:
171
172 ##### User defined commands and flags ################################
173
174 CC={- $config{CC} -}
175 CPP={- $config{CPP} -}
176 DEFINES={- our $defines1 = join('', map { ",$_" } @{$config{CPPDEFINES}}) -}
177 INCLUDES={- our $includes1 = join(',', @{$config{CPPINCLUDES}}) -}
178 CPPFLAGS={- our $cppflags1 = join('', @{$config{CPPFLAGS}}) -}
179 CFLAGS={- join('', @{$config{CFLAGS}}) -}
180 LDFLAGS={- join('', @{$config{LFLAGS}}) -}
181 EX_LIBS={- join('', map { ",$_" } @{$config{LDLIBS}}) -}
182
183 PERL={- $config{PERL} -}
184
185 AS={- $config{AS} -}
186 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
187
188 ##### Special command flags ##########################################
189
190 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
191
192 ##### Project flags ##################################################
193
194 # Variables starting with CNF_ are common variables for all product types
195
196 CNF_ASFLAGS={- join('', $target{asflags} || (),
197                         @{$config{asflags}}) -}
198 CNF_DEFINES={- our $defines2 = join('', map { ",$_" } @{$target{defines}},
199                                                       @{$config{defines}}) -}
200 CNF_INCLUDES={- our $includes2 = join(',', @{$target{includes}},
201                                            @{$config{includes}}) -}
202 CNF_CPPFLAGS={- our $cppflags2 = join('', $target{cppflags} || (),
203                                           @{$config{cppflags}}) -}
204 CNF_CFLAGS={- join('', $target{cflags} || (),
205                        @{$config{cflags}}) -}
206 CNF_CXXFLAGS={- join('', $target{cxxflags} || (),
207                          @{$config{cxxflags}}) -}
208 CNF_LDFLAGS={- join('', $target{lflags} || (),
209                         @{$config{lflags}}) -}
210 CNF_EX_LIBS={- join('', map{ ",$_" } @{$target{ex_libs}},
211                                      @{$config{ex_libs}}) -}
212
213 # Variables starting with LIB_ are used to build library object files
214 # and shared libraries.
215 # Variables starting with DSO_ are used to build DSOs and their object files.
216 # Variables starting with BIN_ are used to build programs and their object
217 # files.
218
219 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
220                          @{$config{lib_asflags}},
221                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
222 LIB_DEFINES={- our $lib_defines =
223                join('', (map { ",$_" } @{$target{lib_defines}},
224                                        @{$target{shared_defines}},
225                                        @{$config{lib_defines}},
226                                        @{$config{shared_defines}}));
227                join('', $lib_defines,
228                         (map { ",$_" } 'OPENSSLDIR="""$(OPENSSLDIR_C)"""',
229                                        'ENGINESDIR="""$(ENGINESDIR_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('all'); -} : build_libs_nodep, build_engines_nodep, build_programs_nodep
405 {- dependmagic('build_libs'); -} : build_libs_nodep
406 {- dependmagic('build_engines'); -} : build_engines_nodep
407 {- dependmagic('build_programs'); -} : build_programs_nodep
408
409 build_generated : $(GENERATED_MANDATORY)
410 build_libs_nodep : $(LIBS), $(SHLIBS)
411 build_engines_nodep : $(ENGINES)
412 build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
413
414 # Kept around for backward compatibility
415 build_apps build_tests : build_programs
416
417 # Convenience target to prebuild all generated files, not just the mandatory
418 # ones
419 build_all_generated : $(GENERATED_MANDATORY) $(GENERATED)
420         @ ! {- output_off() if $disabled{makedepend}; "" -}
421         @ WRITE SYS$OUTPUT "Warning: consider configuring with no-makedepend, because if"
422         @ WRITE SYS$OUTPUT "         target system doesn't have $(PERL),"
423         @ WRITE SYS$OUTPUT "         then make will fail..."
424         @ ! {- output_on() if $disabled{makedepend}; "" -}
425
426 test : tests
427 {- dependmagic('tests'); -} : build_programs_nodep, build_engines_nodep
428         @ ! {- output_off() if $disabled{tests}; "" -}
429         SET DEFAULT [.test]{- move("test") -}
430         CREATE/DIR [.test-runs]
431         DEFINE SRCTOP {- sourcedir() -}
432         DEFINE BLDTOP {- builddir() -}
433         DEFINE RESULT_D {- builddir(qw(test test-runs)) -}
434         DEFINE OPENSSL_ENGINES {- builddir("engines") -}
435         DEFINE OPENSSL_DEBUG_MEMORY "on"
436         IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
437         $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
438         DEASSIGN OPENSSL_DEBUG_MEMORY
439         DEASSIGN OPENSSL_ENGINES
440         DEASSIGN BLDTOP
441         DEASSIGN SRCTOP
442         SET DEFAULT [-]{- move("..") -}
443         @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
444         @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
445         @ ! {- output_on() if !$disabled{tests}; "" -}
446
447 list-tests :
448         @ ! {- output_off() if $disabled{tests}; "" -}
449         @ DEFINE SRCTOP {- sourcedir() -}
450         @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
451         @ DEASSIGN SRCTOP
452         @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
453         @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
454         @ ! {- output_on() if !$disabled{tests}; "" -}
455
456 install : install_sw install_ssldirs install_docs
457         @ WRITE SYS$OUTPUT ""
458         @ WRITE SYS$OUTPUT "######################################################################"
459         @ WRITE SYS$OUTPUT ""
460         @ IF "$(DESTDIR)" .EQS. "" THEN -
461              PIPE ( WRITE SYS$OUTPUT "Installation complete" ; -
462                     WRITE SYS$OUTPUT "" ; -
463                     WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
464                     WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
465                     WRITE SYS$OUTPUT "" )
466         @ IF "$(DESTDIR)" .NES. "" THEN -
467              PIPE ( WRITE SYS$OUTPUT "Staging installation complete" ; -
468                     WRITE SYS$OUTPUT "" ; -
469                     WRITE SYS$OUTPUT "Finish or package in such a way that the contents of the directory tree" ; -
470                     WRITE SYS$OUTPUT staging_instdir ; -
471                     WRITE SYS$OUTPUT "ends up in $(INSTALLTOP)," ; -
472                     WRITE SYS$OUTPUT "and that the contents of the contents of the directory tree" ; -
473                     WRITE SYS$OUTPUT staging_datadir ; -
474                     WRITE SYS$OUTPUT "ends up in $(OPENSSLDIR)" ; -
475                     WRITE SYS$OUTPUT "" ; -
476                     WRITE SYS$OUTPUT "When in its final destination," ; -
477                     WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
478                     WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
479                     WRITE SYS$OUTPUT "" )
480
481 check_install :
482         spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
483
484 uninstall : uninstall_docs uninstall_sw
485
486 # Because VMS wants the generation number (or *) to delete files, we can't
487 # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(ENGINES)directly.
488 libclean :
489         {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
490         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
491
492 clean : libclean
493         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
494         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{engines}}) || "@ !" -}
495         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
496         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -}
497         {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
498         - DELETE [...]*.MAP;*
499         - DELETE [...]*.D;*
500         - DELETE [...]*.OBJ;*,*.LIS;*
501         - DELETE []CXX$DEMANGLER_DB.;*
502         - DELETE [.VMS]openssl_startup.com;*
503         - DELETE [.VMS]openssl_shutdown.com;*
504         - DELETE []vmsconfig.pm;*
505
506 distclean : clean
507         - DELETE configdata.pm;*
508         - DELETE descrip.mms;*
509
510 depend : descrip.mms
511 descrip.mms : FORCE
512         @ ! {- output_off() if $disabled{makedepend}; "" -}
513         @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "VMS C"
514         @ ! {- output_on() if $disabled{makedepend}; "" -}
515
516 # Install helper targets #############################################
517
518 install_sw : all install_shared _install_dev_ns -
519              install_engines _install_runtime_ns -
520              install_startup install_ivp
521
522 uninstall_sw : uninstall_shared _uninstall_dev_ns -
523                uninstall_engines _uninstall_runtime_ns -
524                uninstall_startup uninstall_ivp
525
526 install_docs : install_html_docs
527
528 uninstall_docs : uninstall_html_docs
529
530 install_ssldirs : check_INSTALLTOP
531         - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
532         IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
533                 CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
534         IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
535                 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
536         IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
537                 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
538         COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
539         @ ! Install configuration file
540         COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
541                 ossl_dataroot:[000000]openssl.cnf-dist
542         IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN -
543                 COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
544                         ossl_dataroot:[000000]openssl.cnf
545         @ ! Install CTLOG configuration file
546         COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
547                 ossl_dataroot:[000000]ct_log_list.cnf-dist
548         IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN -
549                 COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
550                         ossl_dataroot:[000000]ct_log_list.cnf
551
552 install_shared : check_INSTALLTOP
553         @ {- output_off() if $disabled{shared}; "" -} !
554         @ WRITE SYS$OUTPUT "*** Installing shareable images"
555         @ ! Install shared (runtime) libraries
556         - CREATE/DIR ossl_installroot:[LIB.'arch']
557         {- join("\n        ",
558                 map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
559                 @install_shlibs) -}
560         @ {- output_on() if $disabled{shared}; "" -} !
561
562 _install_dev_ns : check_INSTALLTOP
563         @ WRITE SYS$OUTPUT "*** Installing development files"
564         @ ! Install header files
565         - CREATE/DIR ossl_installroot:[include.openssl]
566         COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
567         @ ! Install static (development) libraries
568         - CREATE/DIR ossl_installroot:[LIB.'arch']
569         {- join("\n        ",
570                 map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
571                 @install_libs) -}
572
573 install_dev : install_shared _install_dev_ns
574
575 _install_runtime_ns : check_INSTALLTOP
576         @ ! Install the main program
577         - CREATE/DIR ossl_installroot:[EXE.'arch']
578         COPY/PROT=W:RE [.APPS]openssl.EXE -
579                 ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
580         @ ! Install scripts
581         COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
582         @ ! {- output_on() if $disabled{apps}; "" -}
583
584 install_runtime : install_shared _install_runtime_ns
585
586 install_engines : check_INSTALLTOP
587         @ {- output_off() unless scalar @{$unified_info{engines}}; "" -} !
588         @ WRITE SYS$OUTPUT "*** Installing engines"
589         - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
590         {- join("\n        ",
591                 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
592                 @{$unified_info{install}->{engines}}) -}
593         @ {- output_on() unless scalar @{$unified_info{engines}}; "" -} !
594
595 install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
596                  [.VMS]openssl_utils.com, check_INSTALLTOP
597         - CREATE/DIR ossl_installroot:[SYS$STARTUP]
598         COPY/PROT=W:RE [.VMS]openssl_startup.com -
599                 ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com
600         COPY/PROT=W:RE [.VMS]openssl_shutdown.com -
601                 ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com
602         COPY/PROT=W:RE [.VMS]openssl_utils.com -
603                 ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com
604
605 install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
606         - CREATE/DIR ossl_installroot:[SYSTEST]
607         COPY/PROT=W:RE [.VMS]openssl_ivp.com -
608                 ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
609
610 [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
611         - CREATE/DIR [.VMS]
612         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
613                 {- sourcefile("VMS", "openssl_startup.com.in") -} -
614                 > [.VMS]openssl_startup.com
615
616 [.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -}
617         - CREATE/DIR [.VMS]
618         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
619                 {- sourcefile("VMS", "openssl_utils.com.in") -} -
620                 > [.VMS]openssl_utils.com
621
622 [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
623         - CREATE/DIR [.VMS]
624         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
625                 {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
626                 > [.VMS]openssl_shutdown.com
627
628 [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -}
629         - CREATE/DIR [.VMS]
630         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
631                 {- sourcefile("VMS", "openssl_ivp.com.in") -} -
632                 > [.VMS]openssl_ivp.com
633
634 vmsconfig.pm : configdata.pm
635         OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
636         WRITE CONFIG "package vmsconfig;"
637         WRITE CONFIG "use strict; use warnings;"
638         WRITE CONFIG "use Exporter;"
639         WRITE CONFIG "our @ISA = qw(Exporter);"
640         WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
641         WRITE CONFIG "our %config = ("
642         WRITE CONFIG "  target => '","{- $config{target} -}","',"
643         WRITE CONFIG "  version => '","{- $config{version} -}","',"
644         WRITE CONFIG "  shlib_version_number => '","{- $config{shlib_version_number} -}","',"
645         WRITE CONFIG "  shlib_major => '","{- $config{shlib_major} -}","',"
646         WRITE CONFIG "  shlib_minor => '","{- $config{shlib_minor} -}","',"
647         WRITE CONFIG "  no_shared => '","{- $disabled{shared} -}","',"
648         WRITE CONFIG "  INSTALLTOP => '$(INSTALLTOP)',"
649         WRITE CONFIG "  OPENSSLDIR => '$(OPENSSLDIR)',"
650         WRITE CONFIG "  pointer_size => '","{- $target{pointer_size} -}","',"
651         WRITE CONFIG ");"
652         WRITE CONFIG "our %target = ();"
653         WRITE CONFIG "our %disabled = ();"
654         WRITE CONFIG "our %withargs = ();"
655         WRITE CONFIG "our %unified_info = ();"
656         WRITE CONFIG "1;"
657         CLOSE CONFIG
658
659 install_html_docs : check_INSTALLTOP
660         sourcedir = F$PARSE("{- $sourcedir -}A.;","[]") - "]A.;" + ".DOC]"
661         $(PERL) {- sourcefile("util", "process_docs.pl") -} -
662                 --sourcedir='sourcedir' --destdir=ossl_installroot:[HTML] -
663                 --type=html
664
665 check_INSTALLTOP :
666         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
667                 WRITE SYS$ERROR "INSTALLTOP should not be empty"
668         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
669                 EXIT %x10000002
670
671 # Helper targets #####################################################
672
673 # Developer targets ##################################################
674
675 debug_logicals :
676         SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
677
678 # Building targets ###################################################
679
680 configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
681         perl configdata.pm -r
682         @ WRITE SYS$OUTPUT "*************************************************"
683         @ WRITE SYS$OUTPUT "***                                           ***"
684         @ WRITE SYS$OUTPUT "***   Please run the same mms command again   ***"
685         @ WRITE SYS$OUTPUT "***                                           ***"
686         @ WRITE SYS$OUTPUT "*************************************************"
687         @ PIPE ( EXIT %X10000000 )
688
689 reconfigure reconf :
690         perl configdata.pm -r
691
692 {-
693   use File::Basename;
694   use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
695
696   # Helper function to figure out dependencies on libraries
697   # It takes a list of library names and outputs a list of dependencies
698   sub compute_lib_depends {
699       if ($disabled{shared}) {
700           return map { $_ =~ /\.a$/ ? $`.".OLB" : $_.".OLB" } @_;
701       }
702       return map { $_ =~ /\.a$/
703                    ? $`.".OLB"
704                    : $unified_info{sharednames}->{$_}.".EXE" } @_;
705   }
706
707   # Helper function to deal with inclusion directory specs.
708   # We have to deal with two things:
709   # 1. comma separation and no possibility of trailing comma
710   # 2. no inclusion directories given at all
711   # 3. long compiler command lines
712   # To resolve 1, we need to iterate through the sources of inclusion
713   # directories, and only add a comma when needed.
714   # To resolve 2, we need to have a variable that will hold the whole
715   # inclusion qualifier, or be the empty string if there are no inclusion
716   # directories.  That's the symbol 'qual_includes' that's used in CPPFLAGS
717   # To resolve 3, we creata a logical name TMP_INCLUDES: to hold the list
718   # of inclusion directories.
719   #
720   # This function returns a list of two lists, one being the collection of
721   # commands to execute before the compiler is called, and the other being
722   # the collection of commands to execute after.  It takes as arguments the
723   # collection of strings to include as directory specs.
724   sub includes {
725       my @stuff = ( @_ );
726       my @before = (
727           'qual_includes :=',
728       );
729       my @after = (
730           'DELETE/SYMBOL/LOCAL qual_includes',
731       );
732
733       if (scalar @stuff > 0) {
734           push @before, 'tmp_includes := '.shift(@stuff);
735           while (@stuff) {
736               push @before, 'tmp_add := '.shift(@stuff);
737               push @before, 'IF tmp_includes .NES. "" .AND. tmp_add .NES. "" THEN tmp_includes = tmp_includes + ","';
738               push @before, 'tmp_includes = tmp_includes + tmp_add';
739           }
740           push @before, "IF tmp_includes .NES. \"\" THEN DEFINE tmp_includes 'tmp_includes'";
741           push @before, 'IF tmp_includes .NES. "" THEN qual_includes := /INCLUDE=(tmp_includes:)';
742           push @before, 'DELETE/SYMBOL/LOCAL tmp_includes';
743           push @before, 'DELETE/SYMBOL/LOCAL tmp_add';
744           push @after, 'DEASSIGN tmp_includes:'
745       }
746       return ([ @before ], [ @after ]);
747   }
748
749   sub generatesrc {
750       my %args = @_;
751       (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
752       my $generator = join(" ", @{$args{generator}});
753       my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
754       my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
755
756       if ($target !~ /\.asm$/) {
757           if ($args{generator}->[0] =~ m|^.*\.in$|) {
758               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
759                                                    "util", "dofile.pl")),
760                                    rel2abs($config{builddir}));
761               return <<"EOF";
762 $target : $args{generator}->[0] $deps
763         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\
764             "-o$target{build_file}" $generator > \$\@
765 EOF
766           } else {
767               return <<"EOF";
768 $target : $args{generator}->[0] $deps
769         \$(PERL)$generator_incs $generator > \$\@
770 EOF
771           }
772       } else {
773           if ($args{generator}->[0] =~ /\.pl$/) {
774               $generator = '$(PERL)'.$generator_incs.' '.$generator;
775           } elsif ($args{generator}->[0] =~ /\.S$/) {
776               $generator = undef;
777           } else {
778               die "Generator type for $src unknown: $generator\n";
779           }
780
781           my $cppflags = {
782               shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
783               lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
784               dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
785               bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
786           } -> {$args{intent}};
787           my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
788                                      lib => '$(LIB_INCLUDES)',
789                                      dso => '$(DSO_INCLUDES)',
790                                      bin => '$(BIN_INCLUDES)' } -> {$args{intent}},
791                                    '$(CNF_INCLUDES)',
792                                    '$(INCLUDES)',
793                                    @{$args{incs}});
794           my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
795           my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
796           if (defined($generator)) {
797               # If the target is named foo.S in build.info, we want to
798               # end up generating foo.s in two steps.
799               if ($args{src} =~ /\.S$/) {
800                    return <<"EOF";
801 $target : $args{generator}->[0] $deps
802         $generator \$\@-S
803         \@ $incs_on
804         PIPE \$(CPP) $cppflags \$\@-S | -
805         \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@-i
806         \@ $incs_off
807         RENAME \$\@-i \$\@
808         DELETE \$\@-S
809 EOF
810               }
811               # Otherwise....
812               return <<"EOF";
813 $target : $args{generator}->[0] $deps
814         $generator \$\@
815 EOF
816           }
817           return <<"EOF";
818 $target : $args{generator}->[0] $deps
819         \@ $incs_on
820         SHOW SYMBOL qual_includes
821         PIPE \$(CPP) $cppflags $args{generator}->[0] | -
822         \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@
823         \@ $incs_off
824 EOF
825       }
826   }
827
828   sub src2obj {
829       my %args = @_;
830       my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
831                      } ( @{$args{srcs}} );
832       (my $obj = $args{obj}) =~ s|\.o$||;
833       my $deps = join(", -\n\t\t", @srcs, @{$args{deps}});
834
835       # Because VMS C isn't very good at combining a /INCLUDE path with
836       # #includes having a relative directory (like '#include "../foo.h"),
837       # the best choice is to move to the first source file's intended
838       # directory before compiling, and make sure to write the object file
839       # in the correct position (important when the object tree is other
840       # than the source tree).
841       my $forward = dirname($args{srcs}->[0]);
842       my $backward = abs2rel(rel2abs("."), rel2abs($forward));
843       my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
844       my $objn = basename($obj);
845       my $srcs =
846           join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs);
847       my $before = $unified_info{before}->{$obj.".OBJ"} || "\@ !";
848       my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !";
849
850       if ($srcs[0] =~ /\.asm$/) {
851           my $asflags = { shlib => ' $(LIB_ASFLAGS)',
852                           lib => ' $(LIB_ASFLAGS)',
853                           dso => ' $(DSO_ASFLAGS)',
854                           bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
855           return <<"EOF";
856 $obj.OBJ : $deps
857         ${before}
858         SET DEFAULT $forward
859         \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn}.OBJ $srcs
860         SET DEFAULT $backward
861 EOF
862       }
863
864       my $cflags;
865       if ($args{installed}) {
866           $cflags = { shlib => '$(LIB_CFLAGS)',
867                       lib => '$(LIB_CFLAGS)',
868                       dso => '$(DSO_CFLAGS)',
869                       bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
870       } else {
871           $cflags = { shlib => '$(NO_INST_LIB_CFLAGS)',
872                       lib => '$(NO_INST_LIB_CFLAGS)',
873                       dso => '$(NO_INST_DSO_CFLAGS)',
874                       bin => '$(NO_INST_BIN_CFLAGS)' } -> {$args{intent}};
875       }
876       $cflags .= { shlib => '$(LIB_CPPFLAGS)',
877                    lib => '$(LIB_CPPFLAGS)',
878                    dso => '$(DSO_CPPFLAGS)',
879                    bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
880
881       my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
882                                  lib => '$(LIB_INCLUDES)',
883                                  dso => '$(DSO_INCLUDES)',
884                                  bin => '$(BIN_INCLUDES)' } -> {$args{intent}},
885                                '$(INCLUDES)',
886                                map {
887                                    file_name_is_absolute($_)
888                                    ? $_ : catdir($backward,$_)
889                                } @{$args{incs}});
890       my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
891       my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
892       my $depbuild = $disabled{makedepend} ? ""
893           : " /MMS=(FILE=${objd}${objn}.D,TARGET=$obj.OBJ)";
894
895       return <<"EOF";
896 $obj.OBJ : $deps
897         ${before}
898         SET DEFAULT $forward
899         \@ $incs_on
900         \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
901         \@ $incs_off
902         SET DEFAULT $backward
903         ${after}
904         - PURGE $obj.OBJ
905 EOF
906   }
907   sub obj2shlib {
908       my %args = @_;
909       my $lib = $args{lib};
910       my $shlib = $args{shlib};
911       my $libd = dirname($lib);
912       my $libn = basename($lib);
913       my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x }
914                  grep { $_ =~ m|\.o$| }
915                  @{$args{objs}};
916       my @defs = grep { $_ =~ /\.opt$/ } @{$args{objs}};
917       my @deps = compute_lib_depends(@{$args{deps}});
918       die "More than one symbol vector" if scalar @defs > 1;
919       my $deps = join(", -\n\t\t", @objs, @defs, @deps);
920       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
921       my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
922                                                      "VMS", "translatesyms.pl")),
923                                      rel2abs($config{builddir}));
924       # The "[]" hack is because in .OPT files, each line inherits the
925       # previous line's file spec as default, so if no directory spec
926       # is present in the current line and the previous line has one that
927       # doesn't apply, you're in for a surprise.
928       my $write_opt1 =
929           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
930                                  "WRITE OPT_FILE \"$x" } @objs).
931           "\"";
932       my $write_opt2 =
933           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
934                              $x =~ s|(\.EXE)|$1/SHARE|;
935                              $x =~ s|(\.OLB)|$1/LIB|;
936                              "WRITE OPT_FILE \"$x\"" } @deps)
937           || "\@ !";
938       return <<"EOF"
939 $shlib.EXE : $deps
940         \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
941         OPEN/WRITE/SHARE=READ OPT_FILE $lib-components.OPT
942         $write_opt1
943         $write_opt2
944         CLOSE OPT_FILE
945         LINK \$(LIB_LDFLAGS)/SHARE=\$\@ $defs[0]-translated/OPT,-
946                 $lib-components.OPT/OPT \$(LIB_EX_LIBS)
947         DELETE $defs[0]-translated;*,$lib-components.OPT;*
948         PURGE $shlib.EXE,$shlib.MAP
949 EOF
950         . ($config{target} =~ m|alpha| ? "" : <<"EOF"
951         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
952 EOF
953         );
954   }
955   sub obj2dso {
956       my %args = @_;
957       my $lib = $args{lib};
958       my $libd = dirname($lib);
959       my $libn = basename($lib);
960       (my $libn_nolib = $libn) =~ s/^lib//;
961       my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
962       my @deps = compute_lib_depends(@{$args{deps}});
963       my $deps = join(", -\n\t\t", @objs, @deps);
964       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
965       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
966                                                "VMS", "engine.opt")),
967                                rel2abs($config{builddir}));
968       # The "[]" hack is because in .OPT files, each line inherits the
969       # previous line's file spec as default, so if no directory spec
970       # is present in the current line and the previous line has one that
971       # doesn't apply, you're in for a surprise.
972       my $write_opt1 =
973           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
974                                  "WRITE OPT_FILE \"$x" } @objs).
975           "\"";
976       my $write_opt2 =
977           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
978                              $x =~ s|(\.EXE)|$1/SHARE|;
979                              $x =~ s|(\.OLB)|$1/LIB|;
980                              "WRITE OPT_FILE \"$x\"" } @deps)
981           || "\@ !";
982       return <<"EOF"
983 $lib.EXE : $deps
984         OPEN/WRITE/SHARE=READ OPT_FILE $lib.OPT
985         TYPE $engine_opt /OUTPUT=OPT_FILE:
986         $write_opt1
987         $write_opt2
988         CLOSE OPT_FILE
989         LINK \$(DSO_LDFLAGS)/SHARE=\$\@ $lib.OPT/OPT \$(DSO_EX_LIBS)
990         - PURGE $lib.EXE,$lib.OPT,$lib.MAP
991 EOF
992         . ($config{target} =~ m|alpha| ? "" : <<"EOF"
993         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
994 EOF
995         );
996   }
997   sub obj2lib {
998       my %args = @_;
999       (my $lib = $args{lib}) =~ s/\.a$//;
1000       my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
1001       my $objs = join(", -\n\t\t", @objs);
1002       my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_" }
1003                                    @objs));
1004       return <<"EOF";
1005 $lib.OLB : $objs
1006         LIBRARY/CREATE/OBJECT $lib.OLB
1007         $fill_lib
1008         - PURGE $lib.OLB
1009 EOF
1010   }
1011   sub obj2bin {
1012       my %args = @_;
1013       my $bin = $args{bin};
1014       my $bind = dirname($bin);
1015       my $binn = basename($bin);
1016       my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
1017       my $objs = join(",", @objs);
1018       my @deps = compute_lib_depends(@{$args{deps}});
1019       my $deps = join(", -\n\t\t", @objs, @deps);
1020
1021       my $olb_count = scalar grep(m|\.OLB$|, @deps);
1022       my $analyse_objs = "@ !";
1023       if ($olb_count > 0) {
1024           my $analyse_quals =
1025               $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
1026           $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
1027       }
1028       # The "[]" hack is because in .OPT files, each line inherits the
1029       # previous line's file spec as default, so if no directory spec
1030       # is present in the current line and the previous line has one that
1031       # doesn't apply, you're in for a surprise.
1032       my $write_opt1 =
1033           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1034                                  "\@ WRITE OPT_FILE \"$x" } @objs).
1035           "\"";
1036       my $write_opt2 =
1037           join("\n\t", map { my @lines = (
1038                                  "\ WRITE OPT_FILE \"CASE_SENSITIVE=YES\""
1039                              );
1040                              my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1041                              if ($x =~ m|\.EXE$|) {
1042                                  push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\"";
1043                              } elsif ($x =~ m|\.OLB$|) {
1044                                  (my $l = $x) =~ s/\W/_/g;
1045                                  push @lines, 
1046                                      "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB\$(INCLUDE_MAIN_$l)\"",
1047                                      "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\""
1048                              }
1049                              @lines
1050                            } @deps)
1051           || "\@ !";
1052       # The linking commands looks a bit complex, but it's for good reason.
1053       # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
1054       # bar.obj happens to have a symbol that also exists in libsomething.exe,
1055       # the linker will warn about it, loudly, and will then choose to pick
1056       # the first copy encountered (the one in bar.obj in this example).
1057       # On Unix and on Windows, the corresponding maneuvre goes through
1058       # silently with the same effect.
1059       # With some test programs, made for checking the internals of OpenSSL,
1060       # we do this kind of linking deliberately, picking a few specific object
1061       # files from within [.crypto] or [.ssl] so we can reach symbols that are
1062       # otherwise unreachable (since the shareable images only exports the
1063       # symbols listed in [.util]*.num), and then with the shared libraries
1064       # themselves.  So we need to silence the warning about multiply defined
1065       # symbols, to mimic the way linking work on Unix and Windows, and so
1066       # the build isn't interrupted (MMS stops when warnings are signaled,
1067       # by default), and so someone building doesn't have to worry where it
1068       # isn't necessary.  If there are other warnings, however, we show them
1069       # and let it break the build.
1070       return <<"EOF"
1071 $bin.EXE : $deps
1072         $analyse_objs
1073         @ OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
1074         $write_opt1
1075         $write_opt2
1076         @ CLOSE OPT_FILE
1077         TYPE $bin.opt ! For debugging
1078         - pipe SPAWN/WAIT/NOLOG/OUT=$bin.LINKLOG -
1079                     LINK \$(BIN_LDFLAGS)/EXEC=\$\@ $bin.OPT/OPT \$(BIN_EX_LIBS) ; -
1080                link_status = \$status ; link_severity = link_status .AND. 7
1081         @ search_severity = 1
1082         -@ IF link_severity .EQ. 0 THEN -
1083                 pipe SEARCH $bin.LINKLOG "%","-"/MATCH=AND | -
1084                      SPAWN/WAIT/NOLOG/OUT=NLA0: -
1085                           SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
1086                      search_severity = \$severity
1087         @ ! search_severity is 3 when the last search didn't find any matching
1088         @ ! string: %SEARCH-I-NOMATCHES, no strings matched
1089         @ ! If that was the result, we pretend linking got through without
1090         @ ! fault or warning.
1091         @ IF search_severity .EQ. 3 THEN link_severity = 1
1092         @ ! At this point, if link_severity shows that there was a fault
1093         @ ! or warning, make sure to restore the linking status.
1094         -@ IF .NOT. link_severity THEN TYPE $bin.LINKLOG
1095         -@ DELETE $bin.LINKLOG;*
1096         @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
1097         - PURGE $bin.EXE,$bin.OPT
1098 EOF
1099       . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1100         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1101 EOF
1102         );
1103   }
1104   sub in2script {
1105       my %args = @_;
1106       my $script = $args{script};
1107       return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
1108       my $sources = join(" ", @{$args{sources}});
1109       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1110                                            "util", "dofile.pl")),
1111                            rel2abs($config{builddir}));
1112       return <<"EOF";
1113 $script : $sources
1114         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
1115             "-o$target{build_file}" $sources > $script
1116         SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
1117         PURGE $script
1118 EOF
1119   }
1120   ""    # Important!  This becomes part of the template result.
1121 -}