blob: b6eb94a580a3b7f091aed8a27550e9fcaf83b425 [file] [log] [blame]
Richard Levittee84193e2016-01-30 07:14:58 +01001## 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
Richard Levittee8fb1292016-07-06 18:53:56 +020012 our $sover = sprintf "%02d%02d", $config{shlib_major}, $config{shlib_minor};
13 our $osslver = sprintf "%02d%02d", split(/\./, $config{version});
14
Richard Levittee84193e2016-01-30 07:14:58 +010015 our $sourcedir = $config{sourcedir};
16 our $builddir = $config{builddir};
17 sub sourcefile {
18 catfile($sourcedir, @_);
19 }
20 sub buildfile {
21 catfile($builddir, @_);
22 }
23 sub sourcedir {
24 catdir($sourcedir, @_);
25 }
26 sub builddir {
27 catdir($builddir, @_);
28 }
29 sub tree {
30 (my $x = shift) =~ s|\]$|...]|;
31 $x
32 }
33 sub move {
34 my $f = catdir(@_);
35 my $b = abs2rel(rel2abs("."),rel2abs($f));
36 $sourcedir = catdir($b,$sourcedir)
37 if !file_name_is_absolute($sourcedir);
38 $builddir = catdir($b,$builddir)
39 if !file_name_is_absolute($builddir);
40 "";
41 }
42
Richard Levitte4813ad22016-06-17 00:23:43 +020043 # Because we need to make two computations of these data,
44 # we store them in arrays for reuse
45 our @shlibs = map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}};
Richard Levitte0f01b7b2016-07-08 14:52:09 +020046 our @install_shlibs = map { $unified_info{sharednames}->{$_} || () } @{$unified_info{install}->{libraries}};
Richard Levitte4813ad22016-06-17 00:23:43 +020047 our @generated = ( ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
48 grep { defined $unified_info{generate}->{$_} }
49 map { @{$unified_info{sources}->{$_}} }
50 grep { /\.o$/ } keys %{$unified_info{sources}} ),
51 ( grep { /\.h$/ } keys %{$unified_info{generate}} ) );
52
Richard Levittee84193e2016-01-30 07:14:58 +010053 # This is a horrible hack, but is needed because recursive inclusion of files
54 # in different directories does not work well with HP C.
55 my $sd = sourcedir("crypto", "async", "arch");
56 foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) {
57 (my $x = $_) =~ s|\.o$|.OBJ|;
58 $unified_info{before}->{$x}
Richard Levitte4813ad22016-06-17 00:23:43 +020059 = qq(arch_include = F\$PARSE("$sd","A.;",,,"SYNTAX_ONLY") - "A.;"
60 define arch 'arch_include');
Richard Levittee84193e2016-01-30 07:14:58 +010061 $unified_info{after}->{$x}
62 = qq(deassign arch);
63 }
64 my $sd1 = sourcedir("ssl","record");
65 my $sd2 = sourcedir("ssl","statem");
Richard Levitte5a5b85d2016-11-10 00:41:53 +010066 my @ssl_locl_users = grep(/^\[\.(?:ssl\.(?:record|statem)|test)\].*\.o$/,
67 keys %{$unified_info{sources}});
Richard Levitte5c3dbd22016-11-04 14:08:55 +010068 foreach (@ssl_locl_users) {
Richard Levittee84193e2016-01-30 07:14:58 +010069 (my $x = $_) =~ s|\.o$|.OBJ|;
70 $unified_info{before}->{$x}
Richard Levitte4813ad22016-06-17 00:23:43 +020071 = qq(record_include = F\$PARSE("$sd1","A.;",,,"SYNTAX_ONLY") - "A.;"
72 define record 'record_include'
73 statem_include = F\$PARSE("$sd2","A.;",,,"SYNTAX_ONLY") - "A.;"
74 define statem 'statem_include');
Richard Levittee84193e2016-01-30 07:14:58 +010075 $unified_info{after}->{$x}
76 = qq(deassign statem
77 deassign record);
78 }
79 #use Data::Dumper;
80 #print STDERR "DEBUG: before:\n", Dumper($unified_info{before});
81 #print STDERR "DEBUG: after:\n", Dumper($unified_info{after});
82 "";
83-}
84PLATFORM={- $config{target} -}
85OPTIONS={- $config{options} -}
86CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
87SRCDIR={- $config{sourcedir} -}
Richard Levitteb867c702016-06-14 22:03:08 +020088BLDDIR={- $config{builddir} -}
Richard Levittee84193e2016-01-30 07:14:58 +010089
Richard Levittee8173152016-05-08 16:57:55 +020090# Allow both V and VERBOSE to indicate verbosity. This only applies
91# to testing.
92VERBOSE=$(V)
93
Richard Levittee84193e2016-01-30 07:14:58 +010094VERSION={- $config{version} -}
95MAJOR={- $config{major} -}
96MINOR={- $config{minor} -}
97SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
98SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
99SHLIB_MAJOR={- $config{shlib_major} -}
100SHLIB_MINOR={- $config{shlib_minor} -}
101SHLIB_TARGET={- $target{shared_target} -}
102
103EXE_EXT=.EXE
104LIB_EXT=.OLB
105SHLIB_EXT=.EXE
106OBJ_EXT=.OBJ
Richard Levitte4813ad22016-06-17 00:23:43 +0200107DEP_EXT=.D
Richard Levittee84193e2016-01-30 07:14:58 +0100108
109LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @{$unified_info{libraries}}) -}
Richard Levitte4813ad22016-06-17 00:23:43 +0200110SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
Richard Levittee84193e2016-01-30 07:14:58 +0100111ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{engines}}) -}
Richard Levitte1e3d16b2016-07-08 17:58:36 +0200112PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -}
Richard Levittee84193e2016-01-30 07:14:58 +0100113SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
Richard Levitte952a9d12016-03-09 01:16:10 +0100114{- output_off() if $disabled{makedepend}; "" -}
Richard Levittec058fcd2016-02-18 19:41:57 +0100115DEPS={- our @deps = map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
116 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
117 keys %{$unified_info{sources}};
118 join(", ", map { "-\n\t".$_ } @deps); -}
Richard Levitte952a9d12016-03-09 01:16:10 +0100119{- output_on() if $disabled{makedepend}; "" -}
Richard Levitte4813ad22016-06-17 00:23:43 +0200120GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
121GENERATED={- join(", ", map { "-\n\t".$_ } @generated) -}
Richard Levitte7cae3862016-06-13 22:02:11 +0200122
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200123INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @{$unified_info{install}->{libraries}}) -}
124INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
125INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{engines}}) -}
126INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{programs}}) -}
Richard Levitte2ff4d292016-05-23 16:46:45 +0200127{- output_off() if $disabled{apps}; "" -}
128BIN_SCRIPTS=[.tools]c_rehash.pl
129MISC_SCRIPTS=[.apps]CA.pl, [.apps]tsget.pl
130{- output_on() if $disabled{apps}; "" -}
Richard Levittee84193e2016-01-30 07:14:58 +0100131
Richard Levitte3c655772016-02-12 21:14:03 +0100132# DESTDIR is for package builders so that they can configure for, say,
Richard Levittee84193e2016-01-30 07:14:58 +0100133# SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
134# In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
Richard Levitte3c655772016-02-12 21:14:03 +0100135# MMS with /MACROS=(DESTDIR=STAGING:[USER]). The result will end up in
136# STAGING:[USER.OPENSSL].
Richard Levittee84193e2016-01-30 07:14:58 +0100137# Normally it is left empty.
Richard Levitte3c655772016-02-12 21:14:03 +0100138DESTDIR=
Richard Levittee84193e2016-01-30 07:14:58 +0100139
140# Do not edit this manually. Use Configure --prefix=DIR to change this!
Richard Levittee8fb1292016-07-06 18:53:56 +0200141INSTALLTOP={- our $installtop =
142 catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
Richard Levitte40ea24b2016-03-29 20:01:33 +0200143 $installtop -}
144SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
Richard Levittee84193e2016-01-30 07:14:58 +0100145# This is the standard central area to store certificates, private keys...
Richard Levitte661a3962016-08-26 22:34:39 +0200146OPENSSLDIR={- catdir($config{openssldir}) or
Richard Levitte667c6bf2016-03-23 23:04:32 +0100147 $config{prefix} ? catdir($config{prefix},"COMMON")
148 : "SYS\$COMMON:[OPENSSL-COMMON]" -}
Richard Levitteafea0062016-07-08 18:30:43 +0200149# The same, but for C
150OPENSSLDIR_C={- $osslprefix -}DATAROOT:[000000]
151# Where installed engines reside, for C
Richard Levitte74981622016-07-09 11:06:44 +0200152ENGINESDIR_C={- $osslprefix -}ENGINES{- $sover.$target{pointer_size} -}:
Richard Levittee84193e2016-01-30 07:14:58 +0100153
154CC= {- $target{cc} -}
Richard Levitteafea0062016-07-08 18:30:43 +0200155CFLAGS= /DEFINE=({- join(",", @{$target{defines}}, @{$config{defines}},"OPENSSLDIR=\"\"\"\$(OPENSSLDIR_C)\"\"\"","ENGINESDIR=\"\"\"\$(ENGINESDIR_C)\"\"\"") -}) {- $target{cflags} -} {- $config{cflags} -}
Richard Levittea4b4bb02016-03-07 19:48:17 +0100156CFLAGS_Q=$(CFLAGS)
Richard Levittee84193e2016-01-30 07:14:58 +0100157DEPFLAG= /DEFINE=({- join(",", @{$config{depdefines}}) -})
Richard Levitte940a09b2016-02-27 11:42:13 +0100158LDFLAGS= {- $target{lflags} -}
Richard Levitte2952b9b2016-03-02 10:57:05 +0100159EX_LIBS= {- $target{ex_libs} ? ",".$target{ex_libs} : "" -}{- $config{ex_libs} ? ",".$config{ex_libs} : "" -}
Richard Levittee590afd2016-04-28 18:18:04 +0200160LIB_CFLAGS={- $target{lib_cflags} || "" -}
161DSO_CFLAGS={- $target{dso_cflags} || "" -}
162BIN_CFLAGS={- $target{bin_cflags} || "" -}
Richard Levitte17501422016-09-08 19:23:38 +0200163NO_INST_LIB_CFLAGS={- $target{no_inst_lib_cflags} || '$(LIB_CFLAGS)' -}
164NO_INST_DSO_CFLAGS={- $target{no_inst_dso_cflags} || '$(DSO_CFLAGS)' -}
165NO_INST_BIN_CFLAGS={- $target{no_inst_bin_cflags} || '$(BIN_CFLAGS)' -}
Richard Levittee84193e2016-01-30 07:14:58 +0100166
167PERL={- $config{perl} -}
168
169# We let the C compiler driver to take care of .s files. This is done in
170# order to be excused from maintaining a separate set of architecture
171# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
172# gcc, then the driver will automatically translate it to -xarch=v8plus
173# and pass it down to assembler.
174AS={- $target{as} -}
175ASFLAG={- $target{asflags} -}
176
177# .FIRST and .LAST are special targets with MMS and MMK.
178# The defines in there are for C. includes that look like
179# this:
180#
181# #include <openssl/foo.h>
182# #include "internal/bar.h"
183#
184# will use the logical names to find the files. Expecting
185# DECompHP C to find files in subdirectories of whatever was
186# given with /INCLUDE is a fantasy, unfortunately.
187NODEBUG=@
188.FIRST :
189 $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
Richard Levitte15766632016-02-19 02:32:22 +0100190 $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
Richard Levittee84193e2016-01-30 07:14:58 +0100191 $(NODEBUG) internal_inc1 = F$PARSE("[.crypto.include.internal]","A.;",,,"SYNTAX_ONLY") - "A.;"
192 $(NODEBUG) internal_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
193 $(NODEBUG) internal_inc3 = F$PARSE("{- catdir($config{sourcedir},"[.crypto.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
194 $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
195 $(NODEBUG) DEFINE internal 'internal_inc1','internal_inc2','internal_inc3'
Richard Levitte3c655772016-02-12 21:14:03 +0100196 $(NODEBUG) staging_dir = "$(DESTDIR)"
Richard Levitte6bd1ef92016-03-23 23:08:18 +0100197 $(NODEBUG) staging_instdir = ""
198 $(NODEBUG) staging_datadir = ""
Richard Levittee84193e2016-01-30 07:14:58 +0100199 $(NODEBUG) IF staging_dir .NES. "" THEN -
Richard Levitte6bd1ef92016-03-23 23:08:18 +0100200 staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
201 $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
202 staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
203 $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
204 staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
205 $(NODEBUG) IF staging_dir .NES. "" THEN -
206 staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
207 $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
208 staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
209 $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
210 staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
Richard Levittee84193e2016-01-30 07:14:58 +0100211 $(NODEBUG) !
212 $(NODEBUG) ! Installation logical names
213 $(NODEBUG) !
Richard Levitte6bd1ef92016-03-23 23:08:18 +0100214 $(NODEBUG) installtop = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
215 $(NODEBUG) datatop = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
216 $(NODEBUG) DEFINE ossl_installroot 'installtop'
217 $(NODEBUG) DEFINE ossl_dataroot 'datatop'
Richard Levittee84193e2016-01-30 07:14:58 +0100218 $(NODEBUG) !
219 $(NODEBUG) ! Figure out the architecture
220 $(NODEBUG) !
Richard Levitte3ee24d42016-11-04 19:11:11 +0100221 $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
Richard Levittee84193e2016-01-30 07:14:58 +0100222 $(NODEBUG) !
223 $(NODEBUG) ! Set up logical names for the libraries, so LINK and
224 $(NODEBUG) ! running programs can use them.
225 $(NODEBUG) !
226 $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}}) || "!" -}
227
228.LAST :
229 $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}}) || "!" -}
Richard Levitte6bd1ef92016-03-23 23:08:18 +0100230 $(NODEBUG) DEASSIGN ossl_dataroot
Richard Levittee84193e2016-01-30 07:14:58 +0100231 $(NODEBUG) DEASSIGN ossl_installroot
232 $(NODEBUG) DEASSIGN internal
233 $(NODEBUG) DEASSIGN openssl
234.DEFAULT :
235 @ ! MMS cannot handle no actions...
236
237# The main targets ###################################################
238
Richard Levitte932eaf02016-06-14 21:39:13 +0200239all : build_generated, -
Richard Levitte1e3d16b2016-07-08 17:58:36 +0200240 build_libs_nodep, build_engines_nodep, build_programs_nodep, -
Richard Levittec058fcd2016-02-18 19:41:57 +0100241 depend
Richard Levittee84193e2016-01-30 07:14:58 +0100242
Richard Levitte932eaf02016-06-14 21:39:13 +0200243build_libs : build_generated, build_libs_nodep, depend
Richard Levitte8478a702016-07-06 03:07:16 +0200244build_libs_nodep : $(LIBS), $(SHLIBS)
Richard Levitte932eaf02016-06-14 21:39:13 +0200245build_engines : build_generated, build_engines_nodep, depend
Richard Levittec058fcd2016-02-18 19:41:57 +0100246build_engines_nodep : $(ENGINES)
Richard Levitte1e3d16b2016-07-08 17:58:36 +0200247build_programs : build_generated, build_programs_nodep, depend
248build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
Richard Levitte68a5f1a2016-02-13 18:15:51 +0100249
Richard Levitte932eaf02016-06-14 21:39:13 +0200250build_generated : $(GENERATED_MANDATORY)
251
Richard Levitte1e3d16b2016-07-08 17:58:36 +0200252# Kept around for backward compatibility
253build_apps build_tests : build_programs
254
255test tests : build_generated, build_programs_nodep, build_engines_nodep, -
Rich Salz6ab36412016-02-27 12:32:42 -0500256 depend
Matt Caswelld90a6be2016-04-14 13:44:15 +0100257 @ ! {- output_off() if $disabled{tests}; "" -}
Richard Levittee84193e2016-01-30 07:14:58 +0100258 SET DEFAULT [.test]{- move("test") -}
259 DEFINE SRCTOP {- sourcedir() -}
260 DEFINE BLDTOP {- builddir() -}
Richard Levittea7177382016-03-05 13:11:37 +0100261 DEFINE OPENSSL_ENGINES {- builddir("engines") -}
Richard Levitte6d4bc8a2016-11-03 17:08:10 +0100262 DEFINE OPENSSL_DEBUG_MEMORY "on"
Richard Levittee8173152016-05-08 16:57:55 +0200263 IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
Richard Levittee84193e2016-01-30 07:14:58 +0100264 $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
Richard Levitte6d4bc8a2016-11-03 17:08:10 +0100265 DEASSIGN OPENSSL_DEBUG_MEMORY
Richard Levittea7177382016-03-05 13:11:37 +0100266 DEASSIGN OPENSSL_ENGINES
Richard Levittee84193e2016-01-30 07:14:58 +0100267 DEASSIGN BLDTOP
268 DEASSIGN SRCTOP
269 SET DEFAULT [-]{- move("..") -}
Matt Caswelld90a6be2016-04-14 13:44:15 +0100270 @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
271 @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
272 @ ! {- output_on() if !$disabled{tests}; "" -}
Richard Levittee84193e2016-01-30 07:14:58 +0100273
274list-tests :
Richard Levitte4813ad22016-06-17 00:23:43 +0200275 @ ! {- output_off() if $disabled{tests}; "" -}
276 @ DEFINE SRCTOP {- sourcedir() -}
277 @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
278 @ DEASSIGN SRCTOP
279 @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
280 @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
281 @ ! {- output_on() if !$disabled{tests}; "" -}
Richard Levittee84193e2016-01-30 07:14:58 +0100282
Richard Levitte4813ad22016-06-17 00:23:43 +0200283install : install_sw install_ssldirs install_docs
Richard Levittea8a421b2016-02-19 09:53:05 +0100284 @ WRITE SYS$OUTPUT ""
285 @ WRITE SYS$OUTPUT "######################################################################"
286 @ WRITE SYS$OUTPUT ""
Richard Levitte687237e2016-02-28 09:31:46 +0100287 @ IF "$(DESTDIR)" .EQS. "" THEN -
Richard Levitte6bd1ef92016-03-23 23:08:18 +0100288 PIPE ( WRITE SYS$OUTPUT "Installation complete" ; -
289 WRITE SYS$OUTPUT "" ; -
Richard Levittee78884d2016-07-06 21:54:47 +0200290 WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
291 WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
Richard Levitte6bd1ef92016-03-23 23:08:18 +0100292 WRITE SYS$OUTPUT "" )
293 @ IF "$(DESTDIR)" .NES. "" THEN -
294 PIPE ( WRITE SYS$OUTPUT "Staging installation complete" ; -
295 WRITE SYS$OUTPUT "" ; -
296 WRITE SYS$OUTPUT "Finish or package in such a way that the contents of the directory tree" ; -
297 WRITE SYS$OUTPUT staging_instdir ; -
298 WRITE SYS$OUTPUT "ends up in $(INSTALLTOP)," ; -
299 WRITE SYS$OUTPUT "and that the contents of the contents of the directory tree" ; -
300 WRITE SYS$OUTPUT staging_datadir ; -
301 WRITE SYS$OUTPUT "ends up in $(OPENSSLDIR)" ; -
302 WRITE SYS$OUTPUT "" ; -
303 WRITE SYS$OUTPUT "When in its final destination," ; -
Richard Levittee8fb1292016-07-06 18:53:56 +0200304 WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
305 WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
Richard Levitte687237e2016-02-28 09:31:46 +0100306 WRITE SYS$OUTPUT "" )
Richard Levittee84193e2016-01-30 07:14:58 +0100307
Richard Levitte3426de22016-07-02 10:28:39 +0200308check_install :
Richard Levittee8fb1292016-07-06 18:53:56 +0200309 spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
Richard Levitte3426de22016-07-02 10:28:39 +0200310
Richard Levittee84193e2016-01-30 07:14:58 +0100311uninstall : uninstall_docs uninstall_sw
312
Richard Levitte4813ad22016-06-17 00:23:43 +0200313# Because VMS wants the generation number (or *) to delete files, we can't
Richard Levitte1e3d16b2016-07-08 17:58:36 +0200314# use $(LIBS), $(PROGRAMS), $(GENERATED) and $(ENGINES)directly.
Richard Levitte4813ad22016-06-17 00:23:43 +0200315libclean :
316 {- join("\n\t", map { "- DELETE $_.OLB;*" } @{$unified_info{libraries}}) || "@ !" -}
Richard Levitte1ae4c072017-03-15 02:52:20 +0100317 {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*,$_.OPT;*" } @shlibs) || "@ !" -}
Richard Levitte4813ad22016-06-17 00:23:43 +0200318
Richard Levittee84193e2016-01-30 07:14:58 +0100319clean : libclean
Richard Levitte1ae4c072017-03-15 02:52:20 +0100320 {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
321 {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{engines}}) || "@ !" -}
Richard Levitte4813ad22016-06-17 00:23:43 +0200322 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
323 {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
324 - DELETE [...]*.MAP;*
325 - DELETE [...]*.D;*
326 - DELETE [...]*.OBJ;*,*.LIS;*
327 - DELETE []CXX$DEMANGLER_DB.;*
328 - DELETE [.VMS]openssl_startup.com;*
329 - DELETE [.VMS]openssl_shutdown.com;*
330 - DELETE []vmsconfig.pm;*
Richard Levittee84193e2016-01-30 07:14:58 +0100331
Richard Levitte7cae3862016-06-13 22:02:11 +0200332distclean : clean
333 - DELETE configdata.pm;*
334 - DELETE descrip.mms;*
335
Richard Levittec058fcd2016-02-18 19:41:57 +0100336depend : descrip.mms
337descrip.mms : FORCE
Richard Levitte952a9d12016-03-09 01:16:10 +0100338 @ ! {- output_off() if $disabled{makedepend}; "" -}
Richard Levittec058fcd2016-02-18 19:41:57 +0100339 @ $(PERL) -pe "if (/^# DO NOT DELETE.*/) { exit(0); }" -
340 < descrip.mms > descrip.mms-new
341 @ OPEN/APPEND DESCRIP descrip.mms-new
342 @ WRITE DESCRIP "# DO NOT DELETE THIS LINE -- make depend depends on it."
Richard Levitte5be5e562016-02-19 02:35:33 +0100343 {- join("\n\t", map { "\@ IF F\$SEARCH(\"$_\") .NES. \"\" THEN TYPE $_ /OUTPUT=DESCRIP:" } @deps); -}
Richard Levittec058fcd2016-02-18 19:41:57 +0100344 @ CLOSE DESCRIP
Richard Levitte5be5e562016-02-19 02:35:33 +0100345 @ PIPE ( $(PERL) -e "use File::Compare qw/compare_text/; my $x = compare_text(""descrip.mms"",""descrip.mms-new""); exit(0x10000000 + ($x == 0));" || -
346 RENAME descrip.mms-new descrip.mms )
Richard Levittec058fcd2016-02-18 19:41:57 +0100347 @ IF F$SEARCH("descrip.mms-new") .NES. "" THEN DELETE descrip.mms-new;*
348 -@ SPAWN/OUTPUT=NLA0: PURGE/NOLOG descrip.mms
Richard Levitte952a9d12016-03-09 01:16:10 +0100349 @ ! {- output_on() if $disabled{makedepend}; "" -}
Richard Levittee84193e2016-01-30 07:14:58 +0100350
351# Install helper targets #############################################
352
Richard Levitte82c78ee2016-07-21 12:33:23 +0200353install_sw : all install_shared _install_dev_ns -
354 install_engines _install_runtime_ns -
355 install_startup install_ivp
Richard Levittee84193e2016-01-30 07:14:58 +0100356
Richard Levitte82c78ee2016-07-21 12:33:23 +0200357uninstall_sw : uninstall_shared _uninstall_dev_ns -
358 uninstall_engines _uninstall_runtime_ns -
359 uninstall_startup uninstall_ivp
Richard Levittee84193e2016-01-30 07:14:58 +0100360
Richard Levitte4813ad22016-06-17 00:23:43 +0200361install_docs : install_html_docs
Richard Levittee84193e2016-01-30 07:14:58 +0100362
Richard Levitte4813ad22016-06-17 00:23:43 +0200363uninstall_docs : uninstall_html_docs
364
365install_ssldirs : check_INSTALLTOP
366 - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
367 IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
368 CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
369 IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
370 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
371 IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
372 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
373 COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
374 @ ! Install configuration file
Richard Levittecb926df2016-08-01 23:18:25 +0200375 COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
376 ossl_dataroot:[000000]openssl.cnf-dist
377 IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN -
378 COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
379 ossl_dataroot:[000000]openssl.cnf
Rich Salzc7af65c2016-09-09 18:05:41 -0400380 @ ! Install CTLOG configuration file
381 COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
382 ossl_dataroot:[000000]ct_log_list.cnf-dist
383 IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN -
384 COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
385 ossl_dataroot:[000000]ct_log_list.cnf
Richard Levittee84193e2016-01-30 07:14:58 +0100386
Richard Levitte82c78ee2016-07-21 12:33:23 +0200387install_shared : check_INSTALLTOP
388 @ {- output_off() if $disabled{shared}; "" -} !
389 @ WRITE SYS$OUTPUT "*** Installing shareable images"
390 @ ! Install shared (runtime) libraries
391 - CREATE/DIR ossl_installroot:[LIB.'arch']
392 {- join("\n ",
393 map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
394 @install_shlibs) -}
395 @ {- output_on() if $disabled{shared}; "" -} !
396
397_install_dev_ns : check_INSTALLTOP
Richard Levittee84193e2016-01-30 07:14:58 +0100398 @ WRITE SYS$OUTPUT "*** Installing development files"
399 @ ! Install header files
Richard Levitteb3514b42016-03-24 00:28:38 +0100400 - CREATE/DIR ossl_installroot:[include.openssl]
Richard Levittee84193e2016-01-30 07:14:58 +0100401 COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
Richard Levitte36b53722016-07-19 13:24:57 +0200402 @ ! Install static (development) libraries
Richard Levitteb3514b42016-03-24 00:28:38 +0100403 - CREATE/DIR ossl_installroot:[LIB.'arch']
Richard Levittee84193e2016-01-30 07:14:58 +0100404 {- join("\n ",
Richard Levittea8a421b2016-02-19 09:53:05 +0100405 map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200406 @{$unified_info{install}->{libraries}}) -}
Richard Levittee84193e2016-01-30 07:14:58 +0100407
Richard Levitte82c78ee2016-07-21 12:33:23 +0200408install_dev : install_shared _install_dev_ns
409
410_install_runtime_ns : check_INSTALLTOP
Richard Levittee84193e2016-01-30 07:14:58 +0100411 @ ! Install the main program
Richard Levitteb3514b42016-03-24 00:28:38 +0100412 - CREATE/DIR ossl_installroot:[EXE.'arch']
Richard Levittedbb3aba2016-07-02 09:51:06 +0200413 COPY/PROT=W:RE [.APPS]openssl.EXE -
Richard Levittee8fb1292016-07-06 18:53:56 +0200414 ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
Richard Levittee84193e2016-01-30 07:14:58 +0100415 @ ! Install scripts
Richard Levitte2ff4d292016-05-23 16:46:45 +0200416 COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
Richard Levittef2ead992016-04-14 16:07:37 +0100417 @ ! {- output_on() if $disabled{apps}; "" -}
Richard Levittee84193e2016-01-30 07:14:58 +0100418
Richard Levitte82c78ee2016-07-21 12:33:23 +0200419install_runtime : install_shared _install_runtime_ns
420
Richard Levittee84193e2016-01-30 07:14:58 +0100421install_engines : check_INSTALLTOP
Richard Levittef27f64e2016-02-20 00:10:43 +0100422 @ {- output_off() unless scalar @{$unified_info{engines}}; "" -} !
Richard Levittee84193e2016-01-30 07:14:58 +0100423 @ WRITE SYS$OUTPUT "*** Installing engines"
Richard Levitte74981622016-07-09 11:06:44 +0200424 - CREATE/DIR ossl_installroot:[ENGINES{- $sover.$target{pointer_size} -}.'arch']
Richard Levittef27f64e2016-02-20 00:10:43 +0100425 {- join("\n ",
Richard Levitte74981622016-07-09 11:06:44 +0200426 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover$target{pointer_size}.'arch']" }
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200427 @{$unified_info{install}->{engines}}) -}
Richard Levittef27f64e2016-02-20 00:10:43 +0100428 @ {- output_on() unless scalar @{$unified_info{engines}}; "" -} !
Richard Levittee84193e2016-01-30 07:14:58 +0100429
Richard Levitte4813ad22016-06-17 00:23:43 +0200430install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
Richard Levittedbb3aba2016-07-02 09:51:06 +0200431 [.VMS]openssl_utils.com, check_INSTALLTOP
Richard Levitteb3514b42016-03-24 00:28:38 +0100432 - CREATE/DIR ossl_installroot:[SYS$STARTUP]
Richard Levittee8fb1292016-07-06 18:53:56 +0200433 COPY/PROT=W:RE [.VMS]openssl_startup.com -
434 ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com
435 COPY/PROT=W:RE [.VMS]openssl_shutdown.com -
436 ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com
437 COPY/PROT=W:RE [.VMS]openssl_utils.com -
438 ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com
Richard Levittee84193e2016-01-30 07:14:58 +0100439
Richard Levitte3426de22016-07-02 10:28:39 +0200440install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
441 - CREATE/DIR ossl_installroot:[SYSTEST]
Richard Levittee8fb1292016-07-06 18:53:56 +0200442 COPY/PROT=W:RE [.VMS]openssl_ivp.com -
443 ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
Richard Levitte3426de22016-07-02 10:28:39 +0200444
Richard Levittee073fd12016-05-14 10:51:58 +0200445[.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
Richard Levitteb3514b42016-03-24 00:28:38 +0100446 - CREATE/DIR [.VMS]
Richard Levittee84193e2016-01-30 07:14:58 +0100447 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
448 {- sourcefile("VMS", "openssl_startup.com.in") -} -
449 > [.VMS]openssl_startup.com
450
Richard Levittedbb3aba2016-07-02 09:51:06 +0200451[.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -}
452 - CREATE/DIR [.VMS]
453 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
454 {- sourcefile("VMS", "openssl_utils.com.in") -} -
455 > [.VMS]openssl_utils.com
456
Richard Levittee073fd12016-05-14 10:51:58 +0200457[.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
Richard Levitteb3514b42016-03-24 00:28:38 +0100458 - CREATE/DIR [.VMS]
Richard Levittee84193e2016-01-30 07:14:58 +0100459 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
460 {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
461 > [.VMS]openssl_shutdown.com
462
Richard Levitte3426de22016-07-02 10:28:39 +0200463[.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -}
464 - CREATE/DIR [.VMS]
465 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
466 {- sourcefile("VMS", "openssl_ivp.com.in") -} -
467 > [.VMS]openssl_ivp.com
468
Richard Levitte27f42b42016-02-19 02:30:51 +0100469vmsconfig.pm : configdata.pm
Richard Levittee84193e2016-01-30 07:14:58 +0100470 OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
471 WRITE CONFIG "package vmsconfig;"
472 WRITE CONFIG "use strict; use warnings;"
473 WRITE CONFIG "use Exporter;"
474 WRITE CONFIG "our @ISA = qw(Exporter);"
Richard Levitte0f2d3e42016-02-26 08:46:44 +0100475 WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
Richard Levittee84193e2016-01-30 07:14:58 +0100476 WRITE CONFIG "our %config = ("
Richard Levitte34d54902016-07-02 08:31:00 +0200477 WRITE CONFIG " target => '","{- $config{target} -}","',"
478 WRITE CONFIG " version => '","{- $config{version} -}","',"
479 WRITE CONFIG " shlib_major => '","{- $config{shlib_major} -}","',"
480 WRITE CONFIG " shlib_minor => '","{- $config{shlib_minor} -}","',"
Richard Levitte84af1ba2016-02-22 13:52:46 +0100481 WRITE CONFIG " no_shared => '","{- $disabled{shared} -}","',"
Richard Levittee84193e2016-01-30 07:14:58 +0100482 WRITE CONFIG " INSTALLTOP => '$(INSTALLTOP)',"
483 WRITE CONFIG " OPENSSLDIR => '$(OPENSSLDIR)',"
Richard Levitte34d54902016-07-02 08:31:00 +0200484 WRITE CONFIG " pointer_size => '","{- $target{pointer_size} -}","',"
Richard Levittee84193e2016-01-30 07:14:58 +0100485 WRITE CONFIG ");"
486 WRITE CONFIG "our %target = ();"
Richard Levitte0f2d3e42016-02-26 08:46:44 +0100487 WRITE CONFIG "our %disabled = ();"
Richard Levittee84193e2016-01-30 07:14:58 +0100488 WRITE CONFIG "our %withargs = ();"
489 WRITE CONFIG "our %unified_info = ();"
490 WRITE CONFIG "1;"
491 CLOSE CONFIG
492
Richard Levittee990ec52016-05-19 16:33:58 +0200493install_html_docs : check_INSTALLTOP
Richard Levitte9ad7f6c2016-08-03 12:54:42 +0200494 sourcedir = F$PARSE("{- $sourcedir -}A.;","[]") - "]A.;" + ".DOC]"
495 $(PERL) {- sourcefile("util", "process_docs.pl") -} -
496 --sourcedir='sourcedir' --destdir=ossl_installroot:[HTML] -
497 --type=html
Richard Levittee990ec52016-05-19 16:33:58 +0200498
Richard Levittee84193e2016-01-30 07:14:58 +0100499check_INSTALLTOP :
500 @ IF "$(INSTALLTOP)" .EQS. "" THEN -
501 WRITE SYS$ERROR "INSTALLTOP should not be empty"
502 @ IF "$(INSTALLTOP)" .EQS. "" THEN -
503 EXIT %x10000002
504
505# Helper targets #####################################################
506
Richard Levittee84193e2016-01-30 07:14:58 +0100507# Developer targets ##################################################
508
509debug_logicals :
Richard Levitte7285ac02016-05-23 18:35:23 +0200510 SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
Richard Levittee84193e2016-01-30 07:14:58 +0100511
512# Building targets ###################################################
513
Richard Levitte41240e62016-09-17 20:50:56 +0200514configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
Richard Levittee84193e2016-01-30 07:14:58 +0100515 @ WRITE SYS$OUTPUT "Reconfiguring..."
516 perl $(SRCDIR)Configure reconf
517 @ WRITE SYS$OUTPUT "*************************************************"
518 @ WRITE SYS$OUTPUT "*** ***"
519 @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***"
520 @ WRITE SYS$OUTPUT "*** ***"
521 @ WRITE SYS$OUTPUT "*************************************************"
Richard Levitte27f42b42016-02-19 02:30:51 +0100522 @ PIPE ( EXIT %X10000000 )
Richard Levittee84193e2016-01-30 07:14:58 +0100523
524{-
525 use File::Basename;
526 use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
Richard Levitte66ddf172016-03-07 14:38:54 +0100527
Richard Levitte186a31e2016-11-09 20:01:51 +0100528 # Helper function to figure out dependencies on libraries
529 # It takes a list of library names and outputs a list of dependencies
530 sub compute_lib_depends {
531 if ($disabled{shared}) {
532 return map { $_ =~ /\.a$/ ? $`.".OLB" : $_.".OLB" } @_;
533 }
534 return map { $_ =~ /\.a$/
535 ? $`.".OLB"
536 : $unified_info{sharednames}->{$_}.".EXE" } @_;
537 }
538
Richard Levitte66ddf172016-03-07 14:38:54 +0100539 sub generatesrc {
540 my %args = @_;
541 my $generator = join(" ", @{$args{generator}});
Richard Levitte8d34daf2016-04-21 14:30:08 +0200542 my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
543 my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
Richard Levitte66ddf172016-03-07 14:38:54 +0100544
545 if ($args{src} !~ /\.[sS]$/) {
Richard Levitte7cae3862016-06-13 22:02:11 +0200546 if ($args{generator}->[0] =~ m|^.*\.in$|) {
547 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
548 "util", "dofile.pl")),
549 rel2abs($config{builddir}));
550 return <<"EOF";
551$args{src} : $args{generator}->[0] $deps
552 \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\
553 "-o$target{build_file}" $generator > \$@
554EOF
555 } else {
556 return <<"EOF";
Richard Levitte769777b2016-03-19 00:57:35 +0100557$args{src} : $args{generator}->[0] $deps
Richard Levitte8d34daf2016-04-21 14:30:08 +0200558 \$(PERL)$generator_incs $generator > \$@
Richard Levitte66ddf172016-03-07 14:38:54 +0100559EOF
Richard Levitte7cae3862016-06-13 22:02:11 +0200560 }
Richard Levitte66ddf172016-03-07 14:38:54 +0100561 } else {
562 die "No method to generate assembler source present.\n";
563 }
564 }
565
Richard Levittee84193e2016-01-30 07:14:58 +0100566 sub src2obj {
567 my %args = @_;
568 my $obj = $args{obj};
569 my $deps = join(", -\n\t\t", @{$args{srcs}}, @{$args{deps}});
570
571 # Because VMS C isn't very good at combining a /INCLUDE path with
572 # #includes having a relative directory (like '#include "../foo.h"),
573 # the best choice is to move to the first source file's intended
574 # directory before compiling, and make sure to write the object file
575 # in the correct position (important when the object tree is other
576 # than the source tree).
577 my $forward = dirname($args{srcs}->[0]);
578 my $backward = abs2rel(rel2abs("."), rel2abs($forward));
579 my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
580 my $objn = basename($obj);
581 my $srcs =
582 join(", ",
583 map { abs2rel(rel2abs($_), rel2abs($forward)) } @{$args{srcs}});
Richard Levitte17501422016-09-08 19:23:38 +0200584 my $ecflags;
585 if ($args{installed}) {
586 $ecflags = { lib => '$(LIB_CFLAGS)',
587 dso => '$(DSO_CFLAGS)',
588 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
589 } else {
590 $ecflags = { lib => '$(NO_INST_LIB_CFLAGS)',
591 dso => '$(NO_INST_DSO_CFLAGS)',
592 bin => '$(NO_INST_BIN_CFLAGS)' } -> {$args{intent}};
593 }
Richard Levitteb54e35f2016-03-23 19:27:08 +0100594 my $incs_on = "\@ !";
595 my $incs_off = "\@ !";
596 my $incs = "";
Richard Levitteda430a52016-04-12 16:35:32 +0200597 my @incs = ();
598 push @incs, @{$args{incs}} if @{$args{incs}};
599 unless ($disabled{zlib}) {
600 # GNV$ZLIB_INCLUDE is the standard logical name for later zlib
601 # incarnations.
602 push @incs, ($withargs{zlib_include} || 'GNV$ZLIB_INCLUDE:');
603 }
604 if (@incs) {
Richard Levitteb54e35f2016-03-23 19:27:08 +0100605 $incs_on =
606 "DEFINE tmp_includes "
607 .join(",-\n\t\t\t", map {
608 file_name_is_absolute($_)
609 ? $_ : catdir($backward,$_)
Richard Levitteda430a52016-04-12 16:35:32 +0200610 } @incs);
Richard Levitteb54e35f2016-03-23 19:27:08 +0100611 $incs_off = "DEASSIGN tmp_includes";
612 $incs = " /INCLUDE=(tmp_includes:)";
613 }
Richard Levittee84193e2016-01-30 07:14:58 +0100614 my $before = $unified_info{before}->{$obj.".OBJ"} || "\@ !";
615 my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !";
Richard Levitte952a9d12016-03-09 01:16:10 +0100616 my $depbuild = $disabled{makedepend} ? ""
Richard Levitte4813ad22016-06-17 00:23:43 +0200617 : " /MMS=(FILE=${objd}${objn}.tmp-D,TARGET=$obj.OBJ)";
Richard Levittee84193e2016-01-30 07:14:58 +0100618
619 return <<"EOF";
Richard Levitte340da942016-02-28 00:20:50 +0100620$obj.OBJ : $deps
Richard Levitte70ef9052016-02-19 02:34:20 +0100621 ${before}
622 SET DEFAULT $forward
Richard Levitteb54e35f2016-03-23 19:27:08 +0100623 $incs_on
Richard Levittee590afd2016-04-28 18:18:04 +0200624 \$(CC) \$(CFLAGS)${ecflags}${incs}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
Richard Levitteb54e35f2016-03-23 19:27:08 +0100625 $incs_off
Richard Levitte70ef9052016-02-19 02:34:20 +0100626 SET DEFAULT $backward
627 ${after}
Richard Levitte4813ad22016-06-17 00:23:43 +0200628 \@ PIPE ( \$(PERL) -e "use File::Compare qw/compare_text/; my \$x = compare_text(""$obj.D"",""$obj.tmp-D""); exit(0x10000000 + (\$x == 0));" || -
629 RENAME $obj.tmp-D $obj.d )
630 \@ IF F\$SEARCH("$obj.tmp-D") .NES. "" THEN DELETE $obj.tmp-D;*
Richard Levittee84193e2016-01-30 07:14:58 +0100631 - PURGE $obj.OBJ
632EOF
633 }
634 sub libobj2shlib {
635 my %args = @_;
636 my $lib = $args{lib};
637 my $shlib = $args{shlib};
638 my $libd = dirname($lib);
639 my $libn = basename($lib);
Richard Levitte88420052016-07-02 08:35:12 +0200640 (my $mkdef_key = $libn) =~ s/^${osslprefix_q}lib([^0-9]*)\d*/$1/i;
Richard Levitte186a31e2016-11-09 20:01:51 +0100641 my @deps = compute_lib_depends(@{$args{deps}});
Richard Levittee84193e2016-01-30 07:14:58 +0100642 my $deps = join(", -\n\t\t", @deps);
Richard Levitte84af1ba2016-02-22 13:52:46 +0100643 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
Richard Levittee84193e2016-01-30 07:14:58 +0100644 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
645 my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
646 "VMS", "engine.opt")),
647 rel2abs($config{builddir}));
648 my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
649 "util", "mkdef.pl")),
650 rel2abs($config{builddir}));
651 my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
652 "VMS", "translatesyms.pl")),
653 rel2abs($config{builddir}));
654 # The "[]" hack is because in .OPT files, each line inherits the
655 # previous line's file spec as default, so if no directory spec
656 # is present in the current line and the previous line has one that
657 # doesn't apply, you're in for a surprise.
658 my $write_opt =
659 join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
660 $x =~ s|(\.EXE)|$1/SHARE|;
Richard Levitteef3c88c2016-02-19 23:49:05 +0100661 $x =~ s|(\.OLB)|$1/LIB|;
Richard Levittee84193e2016-01-30 07:14:58 +0100662 "WRITE OPT_FILE \"$x\"" } @deps)
663 || "\@ !";
Richard Levittea2880ae2017-03-15 17:10:48 +0100664 return <<"EOF"
Richard Levittee84193e2016-01-30 07:14:58 +0100665$shlib.EXE : $lib.OLB $deps $ordinalsfile
Richard Levitte4813ad22016-06-17 00:23:43 +0200666 \$(PERL) $mkdef_pl "$mkdef_key" "VMS" > $shlib.SYMVEC-tmp
667 \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $shlib.SYMVEC-tmp > $shlib.SYMVEC
668 DELETE $shlib.SYMVEC-tmp;*
Richard Levittee84193e2016-01-30 07:14:58 +0100669 OPEN/WRITE/SHARE=READ OPT_FILE $shlib.OPT
670 WRITE OPT_FILE "IDENTIFICATION=""V$config{version}"""
Richard Levitte4813ad22016-06-17 00:23:43 +0200671 TYPE $shlib.SYMVEC /OUTPUT=OPT_FILE:
Richard Levittee84193e2016-01-30 07:14:58 +0100672 WRITE OPT_FILE "$lib.OLB/LIBRARY"
Richard Levitte4813ad22016-06-17 00:23:43 +0200673 $write_opt
Richard Levittee84193e2016-01-30 07:14:58 +0100674 CLOSE OPT_FILE
Richard Levitte2de2df72017-03-14 22:00:13 +0100675 LINK \$(LDFLAGS)/SHARE=\$\@ $shlib.OPT/OPT \$(EX_LIBS)
Richard Levitte4813ad22016-06-17 00:23:43 +0200676 DELETE $shlib.SYMVEC;*
677 PURGE $shlib.EXE,$shlib.OPT,$shlib.MAP
Richard Levittee84193e2016-01-30 07:14:58 +0100678EOF
Richard Levittea2880ae2017-03-15 17:10:48 +0100679 . ($config{target} =~ m|alpha| ? "" : <<"EOF"
680 SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
681EOF
682 );
Richard Levittee84193e2016-01-30 07:14:58 +0100683 }
Richard Levitte53862872016-02-15 18:45:54 +0100684 sub obj2dso {
Richard Levittee84193e2016-01-30 07:14:58 +0100685 my %args = @_;
686 my $lib = $args{lib};
687 my $libd = dirname($lib);
688 my $libn = basename($lib);
689 (my $libn_nolib = $libn) =~ s/^lib//;
690 my @objs = map { "$_.OBJ" } @{$args{objs}};
Richard Levitte186a31e2016-11-09 20:01:51 +0100691 my @deps = compute_lib_depends(@{$args{deps}});
Richard Levittee84193e2016-01-30 07:14:58 +0100692 my $deps = join(", -\n\t\t", @objs, @deps);
Richard Levitte84af1ba2016-02-22 13:52:46 +0100693 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
Richard Levittee84193e2016-01-30 07:14:58 +0100694 my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
695 "VMS", "engine.opt")),
696 rel2abs($config{builddir}));
697 # The "[]" hack is because in .OPT files, each line inherits the
698 # previous line's file spec as default, so if no directory spec
699 # is present in the current line and the previous line has one that
700 # doesn't apply, you're in for a surprise.
Richard Levitte47852e62016-09-21 01:49:53 +0200701 my $write_opt1 =
Richard Levittee84193e2016-01-30 07:14:58 +0100702 join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
703 "WRITE OPT_FILE \"$x" } @objs).
Richard Levitte47852e62016-09-21 01:49:53 +0200704 "\"";
705 my $write_opt2 =
Richard Levittee84193e2016-01-30 07:14:58 +0100706 join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
707 $x =~ s|(\.EXE)|$1/SHARE|;
Richard Levitteef3c88c2016-02-19 23:49:05 +0100708 $x =~ s|(\.OLB)|$1/LIB|;
Richard Levittee84193e2016-01-30 07:14:58 +0100709 "WRITE OPT_FILE \"$x\"" } @deps)
710 || "\@ !";
Richard Levittea2880ae2017-03-15 17:10:48 +0100711 return <<"EOF"
Richard Levittee84193e2016-01-30 07:14:58 +0100712$lib.EXE : $deps
713 OPEN/WRITE/SHARE=READ OPT_FILE $lib.OPT
714 TYPE $engine_opt /OUTPUT=OPT_FILE:
Richard Levitte47852e62016-09-21 01:49:53 +0200715 $write_opt1
716 $write_opt2
Richard Levittee84193e2016-01-30 07:14:58 +0100717 CLOSE OPT_FILE
Richard Levitte2de2df72017-03-14 22:00:13 +0100718 LINK \$(LDFLAGS)/SHARE=\$\@ $lib.OPT/OPT \$(EX_LIBS)
Richard Levittee84193e2016-01-30 07:14:58 +0100719 - PURGE $lib.EXE,$lib.OPT,$lib.MAP
720EOF
Richard Levittea2880ae2017-03-15 17:10:48 +0100721 . ($config{target} =~ m|alpha| ? "" : <<"EOF"
722 SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
723EOF
724 );
Richard Levittee84193e2016-01-30 07:14:58 +0100725 }
726 sub obj2lib {
727 my %args = @_;
728 my $lib = $args{lib};
729 my $objs = join(", -\n\t\t", map { $_.".OBJ" } (@{$args{objs}}));
730 my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_.OBJ" }
731 @{$args{objs}}));
732 return <<"EOF";
733$lib.OLB : $objs
Richard Levittee45c78f2016-07-06 02:08:53 +0200734 LIBRARY/CREATE/OBJECT $lib.OLB
Richard Levittee84193e2016-01-30 07:14:58 +0100735 $fill_lib
736 - PURGE $lib.OLB
737EOF
738 }
739 sub obj2bin {
740 my %args = @_;
741 my $bin = $args{bin};
742 my $bind = dirname($bin);
743 my $binn = basename($bin);
744 my @objs = map { "$_.OBJ" } @{$args{objs}};
Richard Levitte186a31e2016-11-09 20:01:51 +0100745 my @deps = compute_lib_depends(@{$args{deps}});
Richard Levittee84193e2016-01-30 07:14:58 +0100746 my $deps = join(", -\n\t\t", @objs, @deps);
747 # The "[]" hack is because in .OPT files, each line inherits the
748 # previous line's file spec as default, so if no directory spec
749 # is present in the current line and the previous line has one that
750 # doesn't apply, you're in for a surprise.
Richard Levitte47852e62016-09-21 01:49:53 +0200751 my $write_opt1 =
Richard Levittee84193e2016-01-30 07:14:58 +0100752 join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
753 "WRITE OPT_FILE \"$x" } @objs).
Richard Levitte47852e62016-09-21 01:49:53 +0200754 "\"";
755 my $write_opt2 =
Richard Levittee84193e2016-01-30 07:14:58 +0100756 join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
757 $x =~ s|(\.EXE)|$1/SHARE|;
758 $x =~ s|(\.OLB)|$1/LIB|;
759 "WRITE OPT_FILE \"$x\"" } @deps)
760 || "\@ !";
Richard Levittebbdec3f2016-10-26 22:31:29 +0200761 # The linking commands looks a bit complex, but it's for good reason.
762 # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
763 # bar.obj happens to have a symbol that also exists in libsomething.exe,
764 # the linker will warn about it, loudly, and will then choose to pick
765 # the first copy encountered (the one in bar.obj in this example).
766 # On Unix and on Windows, the corresponding maneuvre goes through
767 # silently with the same effect.
768 # With some test programs, made for checking the internals of OpenSSL,
769 # we do this kind of linking deliberately, picking a few specific object
770 # files from within [.crypto] or [.ssl] so we can reach symbols that are
771 # otherwise unreachable (since the shareable images only exports the
772 # symbols listed in [.util]*.num), and then with the shared libraries
773 # themselves. So we need to silence the warning about multiply defined
774 # symbols, to mimic the way linking work on Unix and Windows, and so
775 # the build isn't interrupted (MMS stops when warnings are signaled,
776 # by default), and so someone building doesn't have to worry where it
777 # isn't necessary. If there are other warnings, however, we show them
778 # and let it break the build.
Richard Levittea2880ae2017-03-15 17:10:48 +0100779 return <<"EOF"
Richard Levittee84193e2016-01-30 07:14:58 +0100780$bin.EXE : $deps
781 OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
Richard Levitte47852e62016-09-21 01:49:53 +0200782 $write_opt1
783 $write_opt2
Richard Levittee84193e2016-01-30 07:14:58 +0100784 CLOSE OPT_FILE
Richard Levittebbdec3f2016-10-26 22:31:29 +0200785 - pipe SPAWN/WAIT/NOLOG/OUT=$bin.LINKLOG -
Richard Levitte2de2df72017-03-14 22:00:13 +0100786 LINK \$(LDFLAGS)/EXEC=\$\@ $bin.OPT/OPT \$(EX_LIBS) ; -
Richard Levittebbdec3f2016-10-26 22:31:29 +0200787 link_status = \$status ; link_severity = link_status .AND. 7
788 @ search_severity = 1
789 -@ IF link_severity .EQ. 0 THEN -
790 pipe SEARCH $bin.LINKLOG "%","-"/MATCH=AND | -
791 SPAWN/WAIT/NOLOG/OUT=NLA0: -
792 SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
793 search_severity = \$severity
794 @ ! search_severity is 3 when the last search didn't find any matching
795 @ ! string: %SEARCH-I-NOMATCHES, no strings matched
Richard Levittefb0abdc2016-11-04 14:08:25 +0100796 @ ! If that was the result, we pretend linking got through without
797 @ ! fault or warning.
798 @ IF search_severity .EQ. 3 THEN link_severity = 1
799 @ ! At this point, if link_severity shows that there was a fault
800 @ ! or warning, make sure to restore the linking status.
801 -@ IF .NOT. link_severity THEN TYPE $bin.LINKLOG
Richard Levittebbdec3f2016-10-26 22:31:29 +0200802 -@ DELETE $bin.LINKLOG;*
Richard Levittefb0abdc2016-11-04 14:08:25 +0100803 @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
Richard Levittee84193e2016-01-30 07:14:58 +0100804 - PURGE $bin.EXE,$bin.OPT
805EOF
Richard Levittea2880ae2017-03-15 17:10:48 +0100806 . ($config{target} =~ m|alpha| ? "" : <<"EOF"
807 SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
808EOF
809 );
Richard Levittee84193e2016-01-30 07:14:58 +0100810 }
811 sub in2script {
812 my %args = @_;
813 my $script = $args{script};
814 return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
815 my $sources = join(" ", @{$args{sources}});
816 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
817 "util", "dofile.pl")),
818 rel2abs($config{builddir}));
819 return <<"EOF";
820$script : $sources
Richard Levitteb867c702016-06-14 22:03:08 +0200821 \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
Richard Levitteba327ad2016-02-14 08:47:47 +0100822 "-o$target{build_file}" $sources > $script
Richard Levittee84193e2016-01-30 07:14:58 +0100823 SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
824 PURGE $script
825EOF
826 }
827 "" # Important! This becomes part of the template result.
828-}