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