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