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