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