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