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