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