Windows: Make DESTDIR work
[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 => '$(MAJOR).$(MINOR)',"
441         WRITE CONFIG "  no_shared => '","{- $disabled{shared} -}","',"
442         WRITE CONFIG "  INSTALLTOP => '$(INSTALLTOP)',"
443         WRITE CONFIG "  OPENSSLDIR => '$(OPENSSLDIR)',"
444         WRITE CONFIG "  pointersize => '","{- $target{pointersize} -}","',"
445         WRITE CONFIG "  shared_libs => ["
446         {- $disabled{shared}
447            ? "\@ !"
448            : join("\n        ", map { "WRITE CONFIG \"    '$_'," } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}})
449         -}
450         WRITE CONFIG "  ],"
451         WRITE CONFIG ");"
452         WRITE CONFIG "our %target = ();"
453         WRITE CONFIG "our %disabled = ();"
454         WRITE CONFIG "our %withargs = ();"
455         WRITE CONFIG "our %unified_info = ();"
456         WRITE CONFIG "1;"
457         CLOSE CONFIG
458
459 install_html_docs : check_INSTALLTOP
460         @ $(PERL) {- sourcefile("util", "process_docs.pl") -} -
461                 --destdir=ossl_installroot:[HTML] --type=html
462
463 check_INSTALLTOP :
464         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
465                 WRITE SYS$ERROR "INSTALLTOP should not be empty"
466         @ IF "$(INSTALLTOP)" .EQS. "" THEN -
467                 EXIT %x10000002
468
469 # Helper targets #####################################################
470
471 # Developer targets ##################################################
472
473 debug_logicals :
474         SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
475
476 # Building targets ###################################################
477
478 configdata.pm : {- join(" ", sourcefile("Configurations", "descrip.mms.tmpl"), sourcefile("Configurations", "common.tmpl")) -} $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_infos}}) -}
479         @ WRITE SYS$OUTPUT "Reconfiguring..."
480         perl $(SRCDIR)Configure reconf
481         @ WRITE SYS$OUTPUT "*************************************************"
482         @ WRITE SYS$OUTPUT "***                                           ***"
483         @ WRITE SYS$OUTPUT "***   Please run the same mms command again   ***"
484         @ WRITE SYS$OUTPUT "***                                           ***"
485         @ WRITE SYS$OUTPUT "*************************************************"
486         @ PIPE ( EXIT %X10000000 )
487
488 {-
489   use File::Basename;
490   use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
491
492   sub generatesrc {
493       my %args = @_;
494       my $generator = join(" ", @{$args{generator}});
495       my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
496       my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
497
498       if ($args{src} !~ /\.[sS]$/) {
499           if ($args{generator}->[0] =~ m|^.*\.in$|) {
500               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
501                                                    "util", "dofile.pl")),
502                                    rel2abs($config{builddir}));
503               return <<"EOF";
504 $args{src} : $args{generator}->[0] $deps
505         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\
506             "-o$target{build_file}" $generator > \$@
507 EOF
508           } else {
509               return <<"EOF";
510 $args{src} : $args{generator}->[0] $deps
511         \$(PERL)$generator_incs $generator > \$@
512 EOF
513           }
514       } else {
515           die "No method to generate assembler source present.\n";
516       }
517   }
518
519   sub src2obj {
520       my %args = @_;
521       my $obj = $args{obj};
522       my $deps = join(", -\n\t\t", @{$args{srcs}}, @{$args{deps}});
523
524       # Because VMS C isn't very good at combining a /INCLUDE path with
525       # #includes having a relative directory (like '#include "../foo.h"),
526       # the best choice is to move to the first source file's intended
527       # directory before compiling, and make sure to write the object file
528       # in the correct position (important when the object tree is other
529       # than the source tree).
530       my $forward = dirname($args{srcs}->[0]);
531       my $backward = abs2rel(rel2abs("."), rel2abs($forward));
532       my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
533       my $objn = basename($obj);
534       my $srcs =
535           join(", ",
536                map { abs2rel(rel2abs($_), rel2abs($forward)) } @{$args{srcs}});
537       my $ecflags = { lib => '$(LIB_CFLAGS)',
538                       dso => '$(DSO_CFLAGS)',
539                       bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
540       my $incs_on = "\@ !";
541       my $incs_off = "\@ !";
542       my $incs = "";
543       my @incs = ();
544       push @incs, @{$args{incs}} if @{$args{incs}};
545       unless ($disabled{zlib}) {
546           # GNV$ZLIB_INCLUDE is the standard logical name for later zlib
547           # incarnations.
548           push @incs, ($withargs{zlib_include} || 'GNV$ZLIB_INCLUDE:');
549       }
550       if (@incs) {
551           $incs_on =
552               "DEFINE tmp_includes "
553               .join(",-\n\t\t\t", map {
554                                       file_name_is_absolute($_)
555                                       ? $_ : catdir($backward,$_)
556                                   } @incs);
557           $incs_off = "DEASSIGN tmp_includes";
558           $incs = " /INCLUDE=(tmp_includes:)";
559       }
560       my $before = $unified_info{before}->{$obj.".OBJ"} || "\@ !";
561       my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !";
562       my $depbuild = $disabled{makedepend} ? ""
563           : " /MMS=(FILE=${objd}${objn}.tmp-D,TARGET=$obj.OBJ)";
564
565       return <<"EOF";
566 $obj.OBJ : $deps
567         ${before}
568         SET DEFAULT $forward
569         $incs_on
570         \$(CC) \$(CFLAGS)${ecflags}${incs}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
571         $incs_off
572         SET DEFAULT $backward
573         ${after}
574         \@ PIPE ( \$(PERL) -e "use File::Compare qw/compare_text/; my \$x = compare_text(""$obj.D"",""$obj.tmp-D""); exit(0x10000000 + (\$x == 0));" || -
575                  RENAME $obj.tmp-D $obj.d )
576         \@ IF F\$SEARCH("$obj.tmp-D") .NES. "" THEN DELETE $obj.tmp-D;*
577         - PURGE $obj.OBJ
578 EOF
579   }
580   sub libobj2shlib {
581       my %args = @_;
582       my $lib = $args{lib};
583       my $shlib = $args{shlib};
584       my $libd = dirname($lib);
585       my $libn = basename($lib);
586       (my $mkdef_key = $libn) =~ s/^${osslprefix_q}lib//i;
587       my @deps = map {
588           $disabled{shared} ? $_.".OLB"
589               : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
590       my $deps = join(", -\n\t\t", @deps);
591       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
592       my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
593       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
594                                                "VMS", "engine.opt")),
595                                rel2abs($config{builddir}));
596       my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
597                                              "util", "mkdef.pl")),
598                              rel2abs($config{builddir}));
599       my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
600                                                      "VMS", "translatesyms.pl")),
601                                      rel2abs($config{builddir}));
602       # The "[]" hack is because in .OPT files, each line inherits the
603       # previous line's file spec as default, so if no directory spec
604       # is present in the current line and the previous line has one that
605       # doesn't apply, you're in for a surprise.
606       my $write_opt =
607           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
608                              $x =~ s|(\.EXE)|$1/SHARE|;
609                              $x =~ s|(\.OLB)|$1/LIB|;
610                              "WRITE OPT_FILE \"$x\"" } @deps)
611           || "\@ !";
612       return <<"EOF";
613 $shlib.EXE : $lib.OLB $deps $ordinalsfile
614         \$(PERL) $mkdef_pl "$mkdef_key" "VMS" > $shlib.SYMVEC-tmp
615         \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $shlib.SYMVEC-tmp > $shlib.SYMVEC
616         DELETE $shlib.SYMVEC-tmp;*
617         OPEN/WRITE/SHARE=READ OPT_FILE $shlib.OPT
618         WRITE OPT_FILE "IDENTIFICATION=""V$config{version}"""
619         TYPE $shlib.SYMVEC /OUTPUT=OPT_FILE:
620         WRITE OPT_FILE "$lib.OLB/LIBRARY"
621         $write_opt
622         CLOSE OPT_FILE
623         LINK /MAP=$shlib.MAP /FULL/SHARE=$shlib.EXE $shlib.OPT/OPT \$(EX_LIBS)
624         DELETE $shlib.SYMVEC;*
625         PURGE $shlib.EXE,$shlib.OPT,$shlib.MAP
626 EOF
627   }
628   sub obj2dso {
629       my %args = @_;
630       my $lib = $args{lib};
631       my $libd = dirname($lib);
632       my $libn = basename($lib);
633       (my $libn_nolib = $libn) =~ s/^lib//;
634       my @objs = map { "$_.OBJ" } @{$args{objs}};
635       my @deps = map {
636           $disabled{shared} ? $_.".OLB"
637               : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
638       my $deps = join(", -\n\t\t", @objs, @deps);
639       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
640       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
641                                                "VMS", "engine.opt")),
642                                rel2abs($config{builddir}));
643       # The "[]" hack is because in .OPT files, each line inherits the
644       # previous line's file spec as default, so if no directory spec
645       # is present in the current line and the previous line has one that
646       # doesn't apply, you're in for a surprise.
647       my $write_opt =
648           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
649                                  "WRITE OPT_FILE \"$x" } @objs).
650           "\"\n\t".
651           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
652                              $x =~ s|(\.EXE)|$1/SHARE|;
653                              $x =~ s|(\.OLB)|$1/LIB|;
654                              "WRITE OPT_FILE \"$x\"" } @deps)
655           || "\@ !";
656       return <<"EOF";
657 $lib.EXE : $deps
658         OPEN/WRITE/SHARE=READ OPT_FILE $lib.OPT
659         TYPE $engine_opt /OUTPUT=OPT_FILE:
660         $write_opt
661         CLOSE OPT_FILE
662         LINK /MAP=$lib.MAP /FULL/SHARE=$lib.EXE $lib.OPT/OPT \$(EX_LIBS)
663         - PURGE $lib.EXE,$lib.OPT,$lib.MAP
664 EOF
665   }
666   sub obj2lib {
667       my %args = @_;
668       my $lib = $args{lib};
669       my $objs = join(", -\n\t\t", map { $_.".OBJ" } (@{$args{objs}}));
670       my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_.OBJ" }
671                                     @{$args{objs}}));
672       return <<"EOF";
673 $lib.OLB : $objs
674         LIBRARY/CREATE/OBJECT $lib
675         $fill_lib
676         - PURGE $lib.OLB
677 EOF
678   }
679   sub obj2bin {
680       my %args = @_;
681       my $bin = $args{bin};
682       my $bind = dirname($bin);
683       my $binn = basename($bin);
684       my @objs = map { "$_.OBJ" } @{$args{objs}};
685       my @deps = map {
686           $disabled{shared} ? $_.".OLB"
687               : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
688       my $deps = join(", -\n\t\t", @objs, @deps);
689       # The "[]" hack is because in .OPT files, each line inherits the
690       # previous line's file spec as default, so if no directory spec
691       # is present in the current line and the previous line has one that
692       # doesn't apply, you're in for a surprise.
693       my $write_opt =
694           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
695                                  "WRITE OPT_FILE \"$x" } @objs).
696           "\"\n\t".
697           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
698                              $x =~ s|(\.EXE)|$1/SHARE|;
699                              $x =~ s|(\.OLB)|$1/LIB|;
700                              "WRITE OPT_FILE \"$x\"" } @deps)
701           || "\@ !";
702       return <<"EOF";
703 $bin.EXE : $deps
704         OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
705         $write_opt
706         CLOSE OPT_FILE
707         LINK/EXEC=$bin.EXE \$(LDFLAGS) $bin.OPT/OPT \$(EX_LIBS)
708         - PURGE $bin.EXE,$bin.OPT
709 EOF
710   }
711   sub in2script {
712       my %args = @_;
713       my $script = $args{script};
714       return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
715       my $sources = join(" ", @{$args{sources}});
716       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
717                                            "util", "dofile.pl")),
718                            rel2abs($config{builddir}));
719       return <<"EOF";
720 $script : $sources
721         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
722             "-o$target{build_file}" $sources > $script
723         SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
724         PURGE $script
725 EOF
726   }
727   ""    # Important!  This becomes part of the template result.
728 -}