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