Have the VMS shared library file names contain the shared version
[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 $sourcedir = $config{sourcedir};
13   our $builddir = $config{builddir};
14   sub sourcefile {
15       catfile($sourcedir, @_);
16   }
17   sub buildfile {
18       catfile($builddir, @_);
19   }
20   sub sourcedir {
21       catdir($sourcedir, @_);
22   }
23   sub builddir {
24       catdir($builddir, @_);
25   }
26   sub tree {
27       (my $x = shift) =~ s|\]$|...]|;
28       $x
29   }
30   sub move {
31       my $f = catdir(@_);
32       my $b = abs2rel(rel2abs("."),rel2abs($f));
33       $sourcedir = catdir($b,$sourcedir)
34           if !file_name_is_absolute($sourcedir);
35       $builddir = catdir($b,$builddir)
36           if !file_name_is_absolute($builddir);
37       "";
38   }
39
40   # Because we need to make two computations of these data,
41   # we store them in arrays for reuse
42   our @shlibs = map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}};
43   our @programs = grep { !m|^\[\.test\]| } @{$unified_info{programs}};
44   our @testprogs = grep { m|^\[\.test\]| } @{$unified_info{programs}};
45   our @generated = ( ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
46                        grep { defined $unified_info{generate}->{$_} }
47                        map { @{$unified_info{sources}->{$_}} }
48                        grep { /\.o$/ } keys %{$unified_info{sources}} ),
49                      ( grep { /\.h$/ } keys %{$unified_info{generate}} ) );
50
51   # This is a horrible hack, but is needed because recursive inclusion of files
52   # in different directories does not work well with HP C.
53   my $sd = sourcedir("crypto", "async", "arch");
54   foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) {
55       (my $x = $_) =~ s|\.o$|.OBJ|;
56       $unified_info{before}->{$x}
57           = qq(arch_include = F\$PARSE("$sd","A.;",,,"SYNTAX_ONLY") - "A.;"
58         define arch 'arch_include');
59       $unified_info{after}->{$x}
60           = qq(deassign arch);
61   }
62   my $sd1 = sourcedir("ssl","record");
63   my $sd2 = sourcedir("ssl","statem");
64   $unified_info{before}->{"[.test]heartbeat_test.OBJ"}
65       = $unified_info{before}->{"[.test]ssltest_old.OBJ"}
66       = qq(record_include = F\$PARSE("$sd1","A.;",,,"SYNTAX_ONLY") - "A.;"
67         define record 'record_include'
68         statem_include = F\$PARSE("$sd2","A.;",,,"SYNTAX_ONLY") - "A.;"
69         define statem 'statem_include');
70   $unified_info{after}->{"[.test]heartbeat_test.OBJ"}
71       = $unified_info{after}->{"[.test]ssltest.OBJ"}
72       = qq(deassign statem
73         deassign record);
74   foreach (grep /^\[\.ssl\.(?:record|statem)\].*\.o$/, keys %{$unified_info{sources}}) {
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   #use Data::Dumper;
86   #print STDERR "DEBUG: before:\n", Dumper($unified_info{before});
87   #print STDERR "DEBUG: after:\n", Dumper($unified_info{after});
88   "";
89 -}
90 PLATFORM={- $config{target} -}
91 OPTIONS={- $config{options} -}
92 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
93 SRCDIR={- $config{sourcedir} -}
94 BLDDIR={- $config{builddir} -}
95
96 # Allow both V and VERBOSE to indicate verbosity.  This only applies
97 # to testing.
98 VERBOSE=$(V)
99
100 VERSION={- $config{version} -}
101 MAJOR={- $config{major} -}
102 MINOR={- $config{minor} -}
103 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
104 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
105 SHLIB_MAJOR={- $config{shlib_major} -}
106 SHLIB_MINOR={- $config{shlib_minor} -}
107 SHLIB_TARGET={- $target{shared_target} -}
108
109 EXE_EXT=.EXE
110 LIB_EXT=.OLB
111 SHLIB_EXT=.EXE
112 OBJ_EXT=.OBJ
113 DEP_EXT=.D
114
115 LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @{$unified_info{libraries}}) -}
116 SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
117 ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{engines}}) -}
118 PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @programs) -}
119 TESTPROGS={- join(", ", map { "-\n\t".$_.".EXE" } @testprogs) -}
120 SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
121 {- output_off() if $disabled{makedepend}; "" -}
122 DEPS={- our @deps = map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
123                     grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
124                     keys %{$unified_info{sources}};
125         join(", ", map { "-\n\t".$_ } @deps); -}
126 {- output_on() if $disabled{makedepend}; "" -}
127 GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
128 GENERATED={- join(", ", map { "-\n\t".$_ } @generated) -}
129
130 {- output_off() if $disabled{apps}; "" -}
131 BIN_SCRIPTS=[.tools]c_rehash.pl
132 MISC_SCRIPTS=[.apps]CA.pl, [.apps]tsget.pl
133 {- output_on() if $disabled{apps}; "" -}
134
135 # DESTDIR is for package builders so that they can configure for, say,
136 # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
137 # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
138 # MMS with /MACROS=(DESTDIR=STAGING:[USER]).  The result will end up in
139 # STAGING:[USER.OPENSSL].
140 # Normally it is left empty.
141 DESTDIR=
142
143 # Do not edit this manually. Use Configure --prefix=DIR to change this!
144 INSTALLTOP={- (my $x = $config{version}) =~ s|\.|_|g;
145               our $installtop =
146                   catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL-$x]";
147               $installtop -}
148 SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
149 # This is the standard central area to store certificates, private keys...
150 OPENSSLDIR={- catdir($config{openssldir}) ||
151               $config{prefix} ? catdir($config{prefix},"COMMON")
152                               : "SYS\$COMMON:[OPENSSL-COMMON]" -}
153 # Where installed engines reside
154 ENGINESDIR={- $osslprefix -}ENGINES:
155
156 CC= {- $target{cc} -}
157 CFLAGS= /DEFINE=({- join(",", @{$target{defines}}, @{$config{defines}},"OPENSSLDIR=\"\"\"\$(OPENSSLDIR)\"\"\"","ENGINESDIR=\"\"\"\$(ENGINESDIR)\"\"\"") -}) {- $target{cflags} -} {- $config{cflags} -}
158 CFLAGS_Q=$(CFLAGS)
159 DEPFLAG= /DEFINE=({- join(",", @{$config{depdefines}}) -})
160 LDFLAGS= {- $target{lflags} -}
161 EX_LIBS= {- $target{ex_libs} ? ",".$target{ex_libs} : "" -}{- $config{ex_libs} ? ",".$config{ex_libs} : "" -}
162 LIB_CFLAGS={- $target{lib_cflags} || "" -}
163 DSO_CFLAGS={- $target{dso_cflags} || "" -}
164 BIN_CFLAGS={- $target{bin_cflags} || "" -}
165
166 PERL={- $config{perl} -}
167
168 # We let the C compiler driver to take care of .s files. This is done in
169 # order to be excused from maintaining a separate set of architecture
170 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
171 # gcc, then the driver will automatically translate it to -xarch=v8plus
172 # and pass it down to assembler.
173 AS={- $target{as} -}
174 ASFLAG={- $target{asflags} -}
175
176 # .FIRST and .LAST are special targets with MMS and MMK.
177 # The defines in there are for C.  includes that look like
178 # this:
179 #
180 #    #include <openssl/foo.h>
181 #    #include "internal/bar.h"
182 #
183 # will use the logical names to find the files.  Expecting
184 # DECompHP C to find files in subdirectories of whatever was
185 # given with /INCLUDE is a fantasy, unfortunately.
186 NODEBUG=@
187 .FIRST :
188         $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
189         $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
190         $(NODEBUG) internal_inc1 = F$PARSE("[.crypto.include.internal]","A.;",,,"SYNTAX_ONLY") - "A.;"
191         $(NODEBUG) internal_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
192         $(NODEBUG) internal_inc3 = F$PARSE("{- catdir($config{sourcedir},"[.crypto.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
193         $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
194         $(NODEBUG) DEFINE internal 'internal_inc1','internal_inc2','internal_inc3'
195         $(NODEBUG) staging_dir = "$(DESTDIR)"
196         $(NODEBUG) staging_instdir = ""
197         $(NODEBUG) staging_datadir = ""
198         $(NODEBUG) IF staging_dir .NES. "" THEN -
199                 staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
200         $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
201                 staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
202         $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
203                 staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
204         $(NODEBUG) IF staging_dir .NES. "" THEN -
205                 staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
206         $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
207                 staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
208         $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
209                 staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
210         $(NODEBUG) !
211         $(NODEBUG) ! Installation logical names
212         $(NODEBUG) !
213         $(NODEBUG) installtop = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
214         $(NODEBUG) datatop = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
215         $(NODEBUG) DEFINE ossl_installroot 'installtop'
216         $(NODEBUG) DEFINE ossl_dataroot 'datatop'
217         $(NODEBUG) !
218         $(NODEBUG) ! Figure out the architecture
219         $(NODEBUG) !
220         $(NODEBUG) arch == f$edit( f$getsyi( "arch_name"), "upcase")
221         $(NODEBUG) !
222         $(NODEBUG) ! Set up logical names for the libraries, so LINK and
223         $(NODEBUG) ! running programs can use them.
224         $(NODEBUG) !
225         $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}}) || "!" -}
226
227 .LAST :
228         $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}}) || "!" -}
229         $(NODEBUG) DEASSIGN ossl_dataroot
230         $(NODEBUG) DEASSIGN ossl_installroot
231         $(NODEBUG) DEASSIGN internal
232         $(NODEBUG) DEASSIGN openssl
233 .DEFAULT :
234         @ ! MMS cannot handle no actions...
235
236 # The main targets ###################################################
237
238 all : build_generated, -
239       build_libs_nodep, build_engines_nodep, build_apps_nodep, -
240       depend
241
242 build_libs : build_generated, build_libs_nodep, depend
243 build_libs_nodep : $(LIBS)
244 build_engines : build_generated, build_engines_nodep, depend
245 build_engines_nodep : $(ENGINES)
246 build_apps : build_generated, build_apps_nodep, depend
247 build_apps_nodep : $(PROGRAMS), $(SCRIPTS)
248 build_tests : build_generated, build_tests_nodep, depend
249 build_tests_nodep : $(TESTPROGS)
250
251 build_generated : $(GENERATED_MANDATORY)
252
253 test tests : build_generated, -
254              build_apps_nodep, build_engines_nodep, build_tests_nodep, -
255              depend
256         @ ! {- output_off() if $disabled{tests}; "" -}
257         SET DEFAULT [.test]{- move("test") -}
258         DEFINE SRCTOP {- sourcedir() -}
259         DEFINE BLDTOP {- builddir() -}
260         DEFINE OPENSSL_ENGINES {- builddir("engines") -}
261         IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
262         $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
263         DEASSIGN OPENSSL_ENGINES
264         DEASSIGN BLDTOP
265         DEASSIGN SRCTOP
266         SET DEFAULT [-]{- move("..") -}
267         @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
268         @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
269         @ ! {- output_on() if !$disabled{tests}; "" -}
270
271 list-tests :
272         @ ! {- output_off() if $disabled{tests}; "" -}
273         @ DEFINE SRCTOP {- sourcedir() -}
274         @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
275         @ DEASSIGN SRCTOP
276         @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
277         @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
278         @ ! {- output_on() if !$disabled{tests}; "" -}
279
280 install : install_sw install_ssldirs install_docs
281         @ WRITE SYS$OUTPUT ""
282         @ WRITE SYS$OUTPUT "######################################################################"
283         @ WRITE SYS$OUTPUT ""
284         @ IF "$(DESTDIR)" .EQS. "" THEN -
285              PIPE ( WRITE SYS$OUTPUT "Installation complete" ; -
286                     WRITE SYS$OUTPUT "" ; -
287                     WRITE SYS$OUTPUT "Run @$(INSTALLTOP)openssl_startup to set up logical names" ; -
288                     WRITE SYS$OUTPUT "then run @$(INSTALLTOP)openssl_setup to define commands" ; -
289                     WRITE SYS$OUTPUT "" )
290         @ IF "$(DESTDIR)" .NES. "" THEN -
291              PIPE ( WRITE SYS$OUTPUT "Staging installation complete" ; -
292                     WRITE SYS$OUTPUT "" ; -
293                     WRITE SYS$OUTPUT "Finish or package in such a way that the contents of the directory tree" ; -
294                     WRITE SYS$OUTPUT staging_instdir ; -
295                     WRITE SYS$OUTPUT "ends up in $(INSTALLTOP)," ; -
296                     WRITE SYS$OUTPUT "and that the contents of the contents of the directory tree" ; -
297                     WRITE SYS$OUTPUT staging_datadir ; -
298                     WRITE SYS$OUTPUT "ends up in $(OPENSSLDIR)" ; -
299                     WRITE SYS$OUTPUT "" ; -
300                     WRITE SYS$OUTPUT "When in its final destination," ; -
301                     WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup to set up logical names" ; -
302                     WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils to define commands" ; -
303                     WRITE SYS$OUTPUT "" )
304
305 uninstall : uninstall_docs uninstall_sw
306
307 # Because VMS wants the generation number (or *) to delete files, we can't
308 # use $(LIBS), $(PROGRAMS), $(GENERATED), $(ENGINES) and $(TESTPROGS) directly.
309 libclean :
310         {- join("\n\t", map { "- DELETE $_.OLB;*" } @{$unified_info{libraries}}) || "@ !" -}
311         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*,$_.OPT;*" } @shlibs) || "@ !" -}
312
313 clean : libclean
314         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @programs) || "@ !" -}
315         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @testprogs) || "@ !" -}
316         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{engines}}) || "@ !" -}
317         {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
318         {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
319         - DELETE [...]*.MAP;*
320         - DELETE [...]*.D;*
321         - DELETE [...]*.OBJ;*,*.LIS;*
322         - DELETE []CXX$DEMANGLER_DB.;*
323         - DELETE [.VMS]openssl_startup.com;*
324         - DELETE [.VMS]openssl_shutdown.com;*
325         - DELETE []vmsconfig.pm;*
326
327 distclean : clean
328         - DELETE configdata.pm;*
329         - DELETE descrip.mms;*
330
331 depend : descrip.mms
332 descrip.mms : FORCE
333         @ ! {- output_off() if $disabled{makedepend}; "" -}
334         @ $(PERL) -pe "if (/^# DO NOT DELETE.*/) { exit(0); }" -
335                 < descrip.mms > descrip.mms-new
336         @ OPEN/APPEND DESCRIP descrip.mms-new
337         @ WRITE DESCRIP "# DO NOT DELETE THIS LINE -- make depend depends on it."
338         {- join("\n\t", map { "\@ IF F\$SEARCH(\"$_\") .NES. \"\" THEN TYPE $_ /OUTPUT=DESCRIP:" } @deps); -}
339         @ CLOSE DESCRIP
340         @ PIPE ( $(PERL) -e "use File::Compare qw/compare_text/; my $x = compare_text(""descrip.mms"",""descrip.mms-new""); exit(0x10000000 + ($x == 0));" || -
341                  RENAME descrip.mms-new descrip.mms )
342         @ IF F$SEARCH("descrip.mms-new") .NES. "" THEN DELETE descrip.mms-new;*
343         -@ SPAWN/OUTPUT=NLA0: PURGE/NOLOG descrip.mms
344         @ ! {- output_on() if $disabled{makedepend}; "" -}
345
346 # Install helper targets #############################################
347
348 install_sw : all install_dev install_engines install_runtime install_startup
349
350 uninstall_sw : uninstall_dev uninstall_engines uninstall_runtime uninstall_startup
351
352 install_docs : install_html_docs
353
354 uninstall_docs : uninstall_html_docs
355
356 install_ssldirs : check_INSTALLTOP
357         - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
358         IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
359                 CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
360         IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
361                 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
362         IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
363                 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
364         COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
365         @ ! Install configuration file
366         COPY/PROT=W:RE {- sourcefile("apps", "openssl-vms.cnf") -} -
367                 ossl_dataroot:[000000]openssl.cnf
368
369 install_dev : check_INSTALLTOP
370         @ WRITE SYS$OUTPUT "*** Installing development files"
371         @ ! Install header files
372         - CREATE/DIR ossl_installroot:[include.openssl]
373         COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
374         @ ! Install libraries
375         - CREATE/DIR ossl_installroot:[LIB.'arch']
376         {- join("\n        ",
377                 map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
378                 @{$unified_info{libraries}}) -}
379         @ {- output_off() if $disabled{shared}; "" -} !
380         {- join("\n        ",
381                 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[LIB.'arch']" }
382                 map { $unified_info{sharednames}->{$_} || () }
383                 @{$unified_info{libraries}}) -}
384         @ {- output_on() if $disabled{shared}; "" -} !
385
386 install_runtime : check_INSTALLTOP
387         @ ! {- output_off() if $disabled{apps}; "" -}
388         @ WRITE SYS$OUTPUT "*** Installing runtime files"
389         @ ! Install the main program
390         - CREATE/DIR ossl_installroot:[EXE.'arch']
391         COPY/PROT=W:RE [.APPS]openssl.EXE ossl_installroot:[EXE.'arch']
392         @ ! Install scripts
393         - CREATE/DIR ossl_installroot:[EXE]
394         COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
395         @ ! {- output_on() if $disabled{apps}; "" -}
396
397 install_engines : check_INSTALLTOP
398         @ {- output_off() unless scalar @{$unified_info{engines}}; "" -} !
399         @ WRITE SYS$OUTPUT "*** Installing engines"
400         - CREATE/DIR ossl_installroot:[ENGINES.'arch']
401         {- join("\n        ",
402                 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES.'arch']" }
403                 grep(!m|ossltest$|i, @{$unified_info{engines}})) -}
404         @ {- output_on() unless scalar @{$unified_info{engines}}; "" -} !
405
406 install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
407                  check_INSTALLTOP
408         - CREATE/DIR ossl_installroot:[SYS$STARTUP]
409         COPY/PROT=W:RE -
410                 [.VMS]openssl_startup.com,openssl_startup.com -
411                 ossl_installroot:[SYS$STARTUP]
412         COPY/PROT=W:RE -
413                 [.VMS]openssl_startup.com,openssl_shutdown.com -
414                 ossl_installroot:[SYS$STARTUP]
415         COPY/PROT=W:RE -
416                 {- sourcefile("VMS", "openssl_utils.com") -} -
417                 ossl_installroot:[SYS$STARTUP]
418
419 [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
420         - CREATE/DIR [.VMS]
421         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
422                 {- sourcefile("VMS", "openssl_startup.com.in") -} -
423                 > [.VMS]openssl_startup.com
424
425 [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
426         - CREATE/DIR [.VMS]
427         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
428                 {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
429                 > [.VMS]openssl_shutdown.com
430
431 vmsconfig.pm : configdata.pm
432         OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
433         WRITE CONFIG "package vmsconfig;"
434         WRITE CONFIG "use strict; use warnings;"
435         WRITE CONFIG "use Exporter;"
436         WRITE CONFIG "our @ISA = qw(Exporter);"
437         WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
438         WRITE CONFIG "our %config = ("
439         WRITE CONFIG "  target => '","{- $config{target} -}","',"
440         WRITE CONFIG "  version => '","{- $config{version} -}","',"
441         WRITE CONFIG "  shlib_major => '","{- $config{shlib_major} -}","',"
442         WRITE CONFIG "  shlib_minor => '","{- $config{shlib_minor} -}","',"
443         WRITE CONFIG "  no_shared => '","{- $disabled{shared} -}","',"
444         WRITE CONFIG "  INSTALLTOP => '$(INSTALLTOP)',"
445         WRITE CONFIG "  OPENSSLDIR => '$(OPENSSLDIR)',"
446         WRITE CONFIG "  pointer_size => '","{- $target{pointer_size} -}","',"
447         WRITE CONFIG ");"
448         WRITE CONFIG "our %target = ();"
449         WRITE CONFIG "our %disabled = ();"
450         WRITE CONFIG "our %withargs = ();"
451         WRITE CONFIG "our %unified_info = ();"
452         WRITE CONFIG "1;"
453         CLOSE CONFIG
454
455 install_html_docs : check_INSTALLTOP
456         @ $(PERL) {- sourcefile("util", "process_docs.pl") -} -
457                 --destdir=ossl_installroot:[HTML] --type=html
458
459 check_INSTALLTOP :
460         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
461                 WRITE SYS$ERROR "INSTALLTOP should not be empty"
462         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
463                 EXIT %x10000002
464
465 # Helper targets #####################################################
466
467 # Developer targets ##################################################
468
469 debug_logicals :
470         SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
471
472 # Building targets ###################################################
473
474 configdata.pm : {- join(" ", sourcefile("Configurations", "descrip.mms.tmpl"), sourcefile("Configurations", "common.tmpl")) -} $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_infos}}) -}
475         @ WRITE SYS$OUTPUT "Reconfiguring..."
476         perl $(SRCDIR)Configure reconf
477         @ WRITE SYS$OUTPUT "*************************************************"
478         @ WRITE SYS$OUTPUT "***                                           ***"
479         @ WRITE SYS$OUTPUT "***   Please run the same mms command again   ***"
480         @ WRITE SYS$OUTPUT "***                                           ***"
481         @ WRITE SYS$OUTPUT "*************************************************"
482         @ PIPE ( EXIT %X10000000 )
483
484 {-
485   use File::Basename;
486   use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
487
488   sub generatesrc {
489       my %args = @_;
490       my $generator = join(" ", @{$args{generator}});
491       my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
492       my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
493
494       if ($args{src} !~ /\.[sS]$/) {
495           if ($args{generator}->[0] =~ m|^.*\.in$|) {
496               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
497                                                    "util", "dofile.pl")),
498                                    rel2abs($config{builddir}));
499               return <<"EOF";
500 $args{src} : $args{generator}->[0] $deps
501         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\
502             "-o$target{build_file}" $generator > \$@
503 EOF
504           } else {
505               return <<"EOF";
506 $args{src} : $args{generator}->[0] $deps
507         \$(PERL)$generator_incs $generator > \$@
508 EOF
509           }
510       } else {
511           die "No method to generate assembler source present.\n";
512       }
513   }
514
515   sub src2obj {
516       my %args = @_;
517       my $obj = $args{obj};
518       my $deps = join(", -\n\t\t", @{$args{srcs}}, @{$args{deps}});
519
520       # Because VMS C isn't very good at combining a /INCLUDE path with
521       # #includes having a relative directory (like '#include "../foo.h"),
522       # the best choice is to move to the first source file's intended
523       # directory before compiling, and make sure to write the object file
524       # in the correct position (important when the object tree is other
525       # than the source tree).
526       my $forward = dirname($args{srcs}->[0]);
527       my $backward = abs2rel(rel2abs("."), rel2abs($forward));
528       my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
529       my $objn = basename($obj);
530       my $srcs =
531           join(", ",
532                map { abs2rel(rel2abs($_), rel2abs($forward)) } @{$args{srcs}});
533       my $ecflags = { lib => '$(LIB_CFLAGS)',
534                       dso => '$(DSO_CFLAGS)',
535                       bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
536       my $incs_on = "\@ !";
537       my $incs_off = "\@ !";
538       my $incs = "";
539       my @incs = ();
540       push @incs, @{$args{incs}} if @{$args{incs}};
541       unless ($disabled{zlib}) {
542           # GNV$ZLIB_INCLUDE is the standard logical name for later zlib
543           # incarnations.
544           push @incs, ($withargs{zlib_include} || 'GNV$ZLIB_INCLUDE:');
545       }
546       if (@incs) {
547           $incs_on =
548               "DEFINE tmp_includes "
549               .join(",-\n\t\t\t", map {
550                                       file_name_is_absolute($_)
551                                       ? $_ : catdir($backward,$_)
552                                   } @incs);
553           $incs_off = "DEASSIGN tmp_includes";
554           $incs = " /INCLUDE=(tmp_includes:)";
555       }
556       my $before = $unified_info{before}->{$obj.".OBJ"} || "\@ !";
557       my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !";
558       my $depbuild = $disabled{makedepend} ? ""
559           : " /MMS=(FILE=${objd}${objn}.tmp-D,TARGET=$obj.OBJ)";
560
561       return <<"EOF";
562 $obj.OBJ : $deps
563         ${before}
564         SET DEFAULT $forward
565         $incs_on
566         \$(CC) \$(CFLAGS)${ecflags}${incs}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
567         $incs_off
568         SET DEFAULT $backward
569         ${after}
570         \@ PIPE ( \$(PERL) -e "use File::Compare qw/compare_text/; my \$x = compare_text(""$obj.D"",""$obj.tmp-D""); exit(0x10000000 + (\$x == 0));" || -
571                  RENAME $obj.tmp-D $obj.d )
572         \@ IF F\$SEARCH("$obj.tmp-D") .NES. "" THEN DELETE $obj.tmp-D;*
573         - PURGE $obj.OBJ
574 EOF
575   }
576   sub libobj2shlib {
577       my %args = @_;
578       my $lib = $args{lib};
579       my $shlib = $args{shlib};
580       my $libd = dirname($lib);
581       my $libn = basename($lib);
582       (my $mkdef_key = $libn) =~ s/^${osslprefix_q}lib([^0-9]*)\d*/$1/i;
583       my @deps = map {
584           $disabled{shared} ? $_.".OLB"
585               : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
586       my $deps = join(", -\n\t\t", @deps);
587       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
588       my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
589       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
590                                                "VMS", "engine.opt")),
591                                rel2abs($config{builddir}));
592       my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
593                                              "util", "mkdef.pl")),
594                              rel2abs($config{builddir}));
595       my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
596                                                      "VMS", "translatesyms.pl")),
597                                      rel2abs($config{builddir}));
598       # The "[]" hack is because in .OPT files, each line inherits the
599       # previous line's file spec as default, so if no directory spec
600       # is present in the current line and the previous line has one that
601       # doesn't apply, you're in for a surprise.
602       my $write_opt =
603           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
604                              $x =~ s|(\.EXE)|$1/SHARE|;
605                              $x =~ s|(\.OLB)|$1/LIB|;
606                              "WRITE OPT_FILE \"$x\"" } @deps)
607           || "\@ !";
608       return <<"EOF";
609 $shlib.EXE : $lib.OLB $deps $ordinalsfile
610         \$(PERL) $mkdef_pl "$mkdef_key" "VMS" > $shlib.SYMVEC-tmp
611         \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $shlib.SYMVEC-tmp > $shlib.SYMVEC
612         DELETE $shlib.SYMVEC-tmp;*
613         OPEN/WRITE/SHARE=READ OPT_FILE $shlib.OPT
614         WRITE OPT_FILE "IDENTIFICATION=""V$config{version}"""
615         TYPE $shlib.SYMVEC /OUTPUT=OPT_FILE:
616         WRITE OPT_FILE "$lib.OLB/LIBRARY"
617         $write_opt
618         CLOSE OPT_FILE
619         LINK /MAP=$shlib.MAP /FULL/SHARE=$shlib.EXE $shlib.OPT/OPT \$(EX_LIBS)
620         DELETE $shlib.SYMVEC;*
621         PURGE $shlib.EXE,$shlib.OPT,$shlib.MAP
622 EOF
623   }
624   sub obj2dso {
625       my %args = @_;
626       my $lib = $args{lib};
627       my $libd = dirname($lib);
628       my $libn = basename($lib);
629       (my $libn_nolib = $libn) =~ s/^lib//;
630       my @objs = map { "$_.OBJ" } @{$args{objs}};
631       my @deps = map {
632           $disabled{shared} ? $_.".OLB"
633               : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
634       my $deps = join(", -\n\t\t", @objs, @deps);
635       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
636       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
637                                                "VMS", "engine.opt")),
638                                rel2abs($config{builddir}));
639       # The "[]" hack is because in .OPT files, each line inherits the
640       # previous line's file spec as default, so if no directory spec
641       # is present in the current line and the previous line has one that
642       # doesn't apply, you're in for a surprise.
643       my $write_opt =
644           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
645                                  "WRITE OPT_FILE \"$x" } @objs).
646           "\"\n\t".
647           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
648                              $x =~ s|(\.EXE)|$1/SHARE|;
649                              $x =~ s|(\.OLB)|$1/LIB|;
650                              "WRITE OPT_FILE \"$x\"" } @deps)
651           || "\@ !";
652       return <<"EOF";
653 $lib.EXE : $deps
654         OPEN/WRITE/SHARE=READ OPT_FILE $lib.OPT
655         TYPE $engine_opt /OUTPUT=OPT_FILE:
656         $write_opt
657         CLOSE OPT_FILE
658         LINK /MAP=$lib.MAP /FULL/SHARE=$lib.EXE $lib.OPT/OPT \$(EX_LIBS)
659         - PURGE $lib.EXE,$lib.OPT,$lib.MAP
660 EOF
661   }
662   sub obj2lib {
663       my %args = @_;
664       my $lib = $args{lib};
665       my $objs = join(", -\n\t\t", map { $_.".OBJ" } (@{$args{objs}}));
666       my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_.OBJ" }
667                                     @{$args{objs}}));
668       return <<"EOF";
669 $lib.OLB : $objs
670         LIBRARY/CREATE/OBJECT $lib
671         $fill_lib
672         - PURGE $lib.OLB
673 EOF
674   }
675   sub obj2bin {
676       my %args = @_;
677       my $bin = $args{bin};
678       my $bind = dirname($bin);
679       my $binn = basename($bin);
680       my @objs = map { "$_.OBJ" } @{$args{objs}};
681       my @deps = map {
682           $disabled{shared} ? $_.".OLB"
683               : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
684       my $deps = join(", -\n\t\t", @objs, @deps);
685       # The "[]" hack is because in .OPT files, each line inherits the
686       # previous line's file spec as default, so if no directory spec
687       # is present in the current line and the previous line has one that
688       # doesn't apply, you're in for a surprise.
689       my $write_opt =
690           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
691                                  "WRITE OPT_FILE \"$x" } @objs).
692           "\"\n\t".
693           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
694                              $x =~ s|(\.EXE)|$1/SHARE|;
695                              $x =~ s|(\.OLB)|$1/LIB|;
696                              "WRITE OPT_FILE \"$x\"" } @deps)
697           || "\@ !";
698       return <<"EOF";
699 $bin.EXE : $deps
700         OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
701         $write_opt
702         CLOSE OPT_FILE
703         LINK/EXEC=$bin.EXE \$(LDFLAGS) $bin.OPT/OPT \$(EX_LIBS)
704         - PURGE $bin.EXE,$bin.OPT
705 EOF
706   }
707   sub in2script {
708       my %args = @_;
709       my $script = $args{script};
710       return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
711       my $sources = join(" ", @{$args{sources}});
712       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
713                                            "util", "dofile.pl")),
714                            rel2abs($config{builddir}));
715       return <<"EOF";
716 $script : $sources
717         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
718             "-o$target{build_file}" $sources > $script
719         SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
720         PURGE $script
721 EOF
722   }
723   ""    # Important!  This becomes part of the template result.
724 -}