cde5144a69929e0198828a72eef56b1a82cab6d8
[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   my @ssl_locl_users = grep(/^\[\.(?:ssl\.(?:record|statem)|test)\].*\.o$/,
67                             keys %{$unified_info{sources}});
68   foreach (@ssl_locl_users) {
69       (my $x = $_) =~ s|\.o$|.OBJ|;
70       $unified_info{before}->{$x}
71           = 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');
75       $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 -}
84 PLATFORM={- $config{target} -}
85 OPTIONS={- $config{options} -}
86 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
87 SRCDIR={- $config{sourcedir} -}
88 BLDDIR={- $config{builddir} -}
89
90 # Allow both V and VERBOSE to indicate verbosity.  This only applies
91 # to testing.
92 VERBOSE=$(V)
93
94 VERSION={- $config{version} -}
95 MAJOR={- $config{major} -}
96 MINOR={- $config{minor} -}
97 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
98 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
99 SHLIB_MAJOR={- $config{shlib_major} -}
100 SHLIB_MINOR={- $config{shlib_minor} -}
101 SHLIB_TARGET={- $target{shared_target} -}
102
103 EXE_EXT=.EXE
104 LIB_EXT=.OLB
105 SHLIB_EXT=.EXE
106 OBJ_EXT=.OBJ
107 DEP_EXT=.D
108
109 LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @{$unified_info{libraries}}) -}
110 SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
111 ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{engines}}) -}
112 PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -}
113 SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
114 {- output_off() if $disabled{makedepend}; "" -}
115 DEPS={- 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); -}
119 {- output_on() if $disabled{makedepend}; "" -}
120 GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
121 GENERATED={- join(", ", map { "-\n\t".$_ } @generated) -}
122
123 INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @{$unified_info{install}->{libraries}}) -}
124 INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
125 INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{engines}}) -}
126 INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{programs}}) -}
127 {- output_off() if $disabled{apps}; "" -}
128 BIN_SCRIPTS=[.tools]c_rehash.pl
129 MISC_SCRIPTS=[.apps]CA.pl, [.apps]tsget.pl
130 {- output_on() if $disabled{apps}; "" -}
131
132 # DESTDIR is for package builders so that they can configure for, say,
133 # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
134 # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
135 # MMS with /MACROS=(DESTDIR=STAGING:[USER]).  The result will end up in
136 # STAGING:[USER.OPENSSL].
137 # Normally it is left empty.
138 DESTDIR=
139
140 # Do not edit this manually. Use Configure --prefix=DIR to change this!
141 INSTALLTOP={- our $installtop =
142                   catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
143               $installtop -}
144 SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
145 # This is the standard central area to store certificates, private keys...
146 OPENSSLDIR={- catdir($config{openssldir}) or
147               $config{prefix} ? catdir($config{prefix},"COMMON")
148                               : "SYS\$COMMON:[OPENSSL-COMMON]" -}
149 # The same, but for C
150 OPENSSLDIR_C={- $osslprefix -}DATAROOT:[000000]
151 # Where installed engines reside, for C
152 ENGINESDIR_C={- $osslprefix -}ENGINES{- $sover.$target{pointer_size} -}:
153
154 CC= {- $target{cc} -}
155 CFLAGS= /DEFINE=({- join(",", @{$target{defines}}, @{$config{defines}},"OPENSSLDIR=\"\"\"\$(OPENSSLDIR_C)\"\"\"","ENGINESDIR=\"\"\"\$(ENGINESDIR_C)\"\"\"") -}) {- $target{cflags} -} {- $config{cflags} -}
156 CFLAGS_Q=$(CFLAGS)
157 DEPFLAG= /DEFINE=({- join(",", @{$config{depdefines}}) -})
158 LDFLAGS= {- $target{lflags} -}
159 EX_LIBS= {- $target{ex_libs} ? ",".$target{ex_libs} : "" -}{- $config{ex_libs} ? ",".$config{ex_libs} : "" -}
160 LIB_CFLAGS={- $target{lib_cflags} || "" -}
161 DSO_CFLAGS={- $target{dso_cflags} || "" -}
162 BIN_CFLAGS={- $target{bin_cflags} || "" -}
163 NO_INST_LIB_CFLAGS={- $target{no_inst_lib_cflags} || '$(LIB_CFLAGS)' -}
164 NO_INST_DSO_CFLAGS={- $target{no_inst_dso_cflags} || '$(DSO_CFLAGS)' -}
165 NO_INST_BIN_CFLAGS={- $target{no_inst_bin_cflags} || '$(BIN_CFLAGS)' -}
166
167 PERL={- $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.
174 AS={- $target{as} -}
175 ASFLAG={- $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.
187 NODEBUG=@
188 .FIRST :
189         $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
190         $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
191         $(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'
196         $(NODEBUG) staging_dir = "$(DESTDIR)"
197         $(NODEBUG) staging_instdir = ""
198         $(NODEBUG) staging_datadir = ""
199         $(NODEBUG) IF staging_dir .NES. "" THEN -
200                 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]"
211         $(NODEBUG) !
212         $(NODEBUG) ! Installation logical names
213         $(NODEBUG) !
214         $(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'
218         $(NODEBUG) !
219         $(NODEBUG) ! Figure out the architecture
220         $(NODEBUG) !
221         $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
222         $(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}}) || "!" -}
230         $(NODEBUG) DEASSIGN ossl_dataroot
231         $(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
239 all : build_generated, -
240       build_libs_nodep, build_engines_nodep, build_programs_nodep, -
241       depend
242
243 build_libs : build_generated, build_libs_nodep, depend
244 build_libs_nodep : $(LIBS), $(SHLIBS)
245 build_engines : build_generated, build_engines_nodep, depend
246 build_engines_nodep : $(ENGINES)
247 build_programs : build_generated, build_programs_nodep, depend
248 build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
249
250 build_generated : $(GENERATED_MANDATORY)
251
252 # Kept around for backward compatibility
253 build_apps build_tests : build_programs
254
255 test tests : build_generated, build_programs_nodep, build_engines_nodep, -
256              depend
257         @ ! {- output_off() if $disabled{tests}; "" -}
258         SET DEFAULT [.test]{- move("test") -}
259         DEFINE SRCTOP {- sourcedir() -}
260         DEFINE BLDTOP {- builddir() -}
261         DEFINE OPENSSL_ENGINES {- builddir("engines") -}
262         DEFINE OPENSSL_DEBUG_MEMORY "on"
263         IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
264         $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
265         DEASSIGN OPENSSL_DEBUG_MEMORY
266         DEASSIGN OPENSSL_ENGINES
267         DEASSIGN BLDTOP
268         DEASSIGN SRCTOP
269         SET DEFAULT [-]{- move("..") -}
270         @ ! {- 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}; "" -}
273
274 list-tests :
275         @ ! {- 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}; "" -}
282
283 install : install_sw install_ssldirs install_docs
284         @ WRITE SYS$OUTPUT ""
285         @ WRITE SYS$OUTPUT "######################################################################"
286         @ WRITE SYS$OUTPUT ""
287         @ IF "$(DESTDIR)" .EQS. "" THEN -
288              PIPE ( WRITE SYS$OUTPUT "Installation complete" ; -
289                     WRITE SYS$OUTPUT "" ; -
290                     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" ; -
292                     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," ; -
304                     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" ; -
306                     WRITE SYS$OUTPUT "" )
307
308 check_install :
309         spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
310
311 uninstall : uninstall_docs uninstall_sw
312
313 # Because VMS wants the generation number (or *) to delete files, we can't
314 # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(ENGINES)directly.
315 libclean :
316         {- join("\n\t", map { "- DELETE $_.OLB;*" } @{$unified_info{libraries}}) || "@ !" -}
317         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*,$_.OPT;*" } @shlibs) || "@ !" -}
318
319 clean : libclean
320         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
321         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{engines}}) || "@ !" -}
322         {- 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;*
331
332 distclean : clean
333         - DELETE configdata.pm;*
334         - DELETE descrip.mms;*
335
336 depend : descrip.mms
337 descrip.mms : FORCE
338         @ ! {- output_off() if $disabled{makedepend}; "" -}
339         @ $(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."
343         {- join("\n\t", map { "\@ IF F\$SEARCH(\"$_\") .NES. \"\" THEN TYPE $_ /OUTPUT=DESCRIP:" } @deps); -}
344         @ CLOSE DESCRIP
345         @ 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 )
347         @ IF F$SEARCH("descrip.mms-new") .NES. "" THEN DELETE descrip.mms-new;*
348         -@ SPAWN/OUTPUT=NLA0: PURGE/NOLOG descrip.mms
349         @ ! {- output_on() if $disabled{makedepend}; "" -}
350
351 # Install helper targets #############################################
352
353 install_sw : all install_shared _install_dev_ns -
354              install_engines _install_runtime_ns -
355              install_startup install_ivp
356
357 uninstall_sw : uninstall_shared _uninstall_dev_ns -
358                uninstall_engines _uninstall_runtime_ns -
359                uninstall_startup uninstall_ivp
360
361 install_docs : install_html_docs
362
363 uninstall_docs : uninstall_html_docs
364
365 install_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
375         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
380         @ ! 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
386
387 install_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
398         @ WRITE SYS$OUTPUT "*** Installing development files"
399         @ ! Install header files
400         - CREATE/DIR ossl_installroot:[include.openssl]
401         COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
402         @ ! Install static (development) libraries
403         - CREATE/DIR ossl_installroot:[LIB.'arch']
404         {- join("\n        ",
405                 map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
406                 @{$unified_info{install}->{libraries}}) -}
407
408 install_dev : install_shared _install_dev_ns
409
410 _install_runtime_ns : check_INSTALLTOP
411         @ ! Install the main program
412         - CREATE/DIR ossl_installroot:[EXE.'arch']
413         COPY/PROT=W:RE [.APPS]openssl.EXE -
414                 ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
415         @ ! Install scripts
416         COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
417         @ ! {- output_on() if $disabled{apps}; "" -}
418
419 install_runtime : install_shared _install_runtime_ns
420
421 install_engines : check_INSTALLTOP
422         @ {- output_off() unless scalar @{$unified_info{engines}}; "" -} !
423         @ WRITE SYS$OUTPUT "*** Installing engines"
424         - CREATE/DIR ossl_installroot:[ENGINES{- $sover.$target{pointer_size} -}.'arch']
425         {- join("\n        ",
426                 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover$target{pointer_size}.'arch']" }
427                 @{$unified_info{install}->{engines}}) -}
428         @ {- output_on() unless scalar @{$unified_info{engines}}; "" -} !
429
430 install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
431                  [.VMS]openssl_utils.com, check_INSTALLTOP
432         - CREATE/DIR ossl_installroot:[SYS$STARTUP]
433         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
439
440 install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
441         - CREATE/DIR ossl_installroot:[SYSTEST]
442         COPY/PROT=W:RE [.VMS]openssl_ivp.com -
443                 ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
444
445 [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
446         - CREATE/DIR [.VMS]
447         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
448                 {- sourcefile("VMS", "openssl_startup.com.in") -} -
449                 > [.VMS]openssl_startup.com
450
451 [.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
457 [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
458         - CREATE/DIR [.VMS]
459         $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
460                 {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
461                 > [.VMS]openssl_shutdown.com
462
463 [.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
469 vmsconfig.pm : configdata.pm
470         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);"
475         WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
476         WRITE CONFIG "our %config = ("
477         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} -}","',"
481         WRITE CONFIG "  no_shared => '","{- $disabled{shared} -}","',"
482         WRITE CONFIG "  INSTALLTOP => '$(INSTALLTOP)',"
483         WRITE CONFIG "  OPENSSLDIR => '$(OPENSSLDIR)',"
484         WRITE CONFIG "  pointer_size => '","{- $target{pointer_size} -}","',"
485         WRITE CONFIG ");"
486         WRITE CONFIG "our %target = ();"
487         WRITE CONFIG "our %disabled = ();"
488         WRITE CONFIG "our %withargs = ();"
489         WRITE CONFIG "our %unified_info = ();"
490         WRITE CONFIG "1;"
491         CLOSE CONFIG
492
493 install_html_docs : check_INSTALLTOP
494         sourcedir = F$PARSE("{- $sourcedir -}A.;","[]") - "]A.;" + ".DOC]"
495         $(PERL) {- sourcefile("util", "process_docs.pl") -} -
496                 --sourcedir='sourcedir' --destdir=ossl_installroot:[HTML] -
497                 --type=html
498
499 check_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
507 # Developer targets ##################################################
508
509 debug_logicals :
510         SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
511
512 # Building targets ###################################################
513
514 configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
515         @ 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 "*************************************************"
522         @ PIPE ( EXIT %X10000000 )
523
524 {-
525   use File::Basename;
526   use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
527
528   # 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
539   sub generatesrc {
540       my %args = @_;
541       my $generator = join(" ", @{$args{generator}});
542       my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
543       my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
544
545       if ($args{src} !~ /\.[sS]$/) {
546           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 > \$@
554 EOF
555           } else {
556               return <<"EOF";
557 $args{src} : $args{generator}->[0] $deps
558         \$(PERL)$generator_incs $generator > \$@
559 EOF
560           }
561       } else {
562           die "No method to generate assembler source present.\n";
563       }
564   }
565
566   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}});
584       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       }
594       my $incs_on = "\@ !";
595       my $incs_off = "\@ !";
596       my $incs = "";
597       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) {
605           $incs_on =
606               "DEFINE tmp_includes "
607               .join(",-\n\t\t\t", map {
608                                       file_name_is_absolute($_)
609                                       ? $_ : catdir($backward,$_)
610                                   } @incs);
611           $incs_off = "DEASSIGN tmp_includes";
612           $incs = " /INCLUDE=(tmp_includes:)";
613       }
614       my $before = $unified_info{before}->{$obj.".OBJ"} || "\@ !";
615       my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !";
616       my $depbuild = $disabled{makedepend} ? ""
617           : " /MMS=(FILE=${objd}${objn}.tmp-D,TARGET=$obj.OBJ)";
618
619       return <<"EOF";
620 $obj.OBJ : $deps
621         ${before}
622         SET DEFAULT $forward
623         $incs_on
624         \$(CC) \$(CFLAGS)${ecflags}${incs}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
625         $incs_off
626         SET DEFAULT $backward
627         ${after}
628         \@ 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;*
631         - PURGE $obj.OBJ
632 EOF
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);
640       (my $mkdef_key = $libn) =~ s/^${osslprefix_q}lib([^0-9]*)\d*/$1/i;
641       my @deps = compute_lib_depends(@{$args{deps}});
642       my $deps = join(", -\n\t\t", @deps);
643       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
644       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|;
661                              $x =~ s|(\.OLB)|$1/LIB|;
662                              "WRITE OPT_FILE \"$x\"" } @deps)
663           || "\@ !";
664       return <<"EOF";
665 $shlib.EXE : $lib.OLB $deps $ordinalsfile
666         \$(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;*
669         OPEN/WRITE/SHARE=READ OPT_FILE $shlib.OPT
670         WRITE OPT_FILE "IDENTIFICATION=""V$config{version}"""
671         TYPE $shlib.SYMVEC /OUTPUT=OPT_FILE:
672         WRITE OPT_FILE "$lib.OLB/LIBRARY"
673         $write_opt
674         CLOSE OPT_FILE
675         LINK /MAP=$shlib.MAP /FULL/SHARE=$shlib.EXE $shlib.OPT/OPT \$(EX_LIBS)
676         DELETE $shlib.SYMVEC;*
677         PURGE $shlib.EXE,$shlib.OPT,$shlib.MAP
678 EOF
679   }
680   sub obj2dso {
681       my %args = @_;
682       my $lib = $args{lib};
683       my $libd = dirname($lib);
684       my $libn = basename($lib);
685       (my $libn_nolib = $libn) =~ s/^lib//;
686       my @objs = map { "$_.OBJ" } @{$args{objs}};
687       my @deps = compute_lib_depends(@{$args{deps}});
688       my $deps = join(", -\n\t\t", @objs, @deps);
689       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
690       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
691                                                "VMS", "engine.opt")),
692                                rel2abs($config{builddir}));
693       # The "[]" hack is because in .OPT files, each line inherits the
694       # previous line's file spec as default, so if no directory spec
695       # is present in the current line and the previous line has one that
696       # doesn't apply, you're in for a surprise.
697       my $write_opt1 =
698           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
699                                  "WRITE OPT_FILE \"$x" } @objs).
700           "\"";
701       my $write_opt2 =
702           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
703                              $x =~ s|(\.EXE)|$1/SHARE|;
704                              $x =~ s|(\.OLB)|$1/LIB|;
705                              "WRITE OPT_FILE \"$x\"" } @deps)
706           || "\@ !";
707       return <<"EOF";
708 $lib.EXE : $deps
709         OPEN/WRITE/SHARE=READ OPT_FILE $lib.OPT
710         TYPE $engine_opt /OUTPUT=OPT_FILE:
711         $write_opt1
712         $write_opt2
713         CLOSE OPT_FILE
714         LINK /MAP=$lib.MAP /FULL/SHARE=$lib.EXE $lib.OPT/OPT \$(EX_LIBS)
715         - PURGE $lib.EXE,$lib.OPT,$lib.MAP
716 EOF
717   }
718   sub obj2lib {
719       my %args = @_;
720       my $lib = $args{lib};
721       my $objs = join(", -\n\t\t", map { $_.".OBJ" } (@{$args{objs}}));
722       my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_.OBJ" }
723                                     @{$args{objs}}));
724       return <<"EOF";
725 $lib.OLB : $objs
726         LIBRARY/CREATE/OBJECT $lib.OLB
727         $fill_lib
728         - PURGE $lib.OLB
729 EOF
730   }
731   sub obj2bin {
732       my %args = @_;
733       my $bin = $args{bin};
734       my $bind = dirname($bin);
735       my $binn = basename($bin);
736       my @objs = map { "$_.OBJ" } @{$args{objs}};
737       my @deps = compute_lib_depends(@{$args{deps}});
738       my $deps = join(", -\n\t\t", @objs, @deps);
739       # The "[]" hack is because in .OPT files, each line inherits the
740       # previous line's file spec as default, so if no directory spec
741       # is present in the current line and the previous line has one that
742       # doesn't apply, you're in for a surprise.
743       my $write_opt1 =
744           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
745                                  "WRITE OPT_FILE \"$x" } @objs).
746           "\"";
747       my $write_opt2 =
748           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
749                              $x =~ s|(\.EXE)|$1/SHARE|;
750                              $x =~ s|(\.OLB)|$1/LIB|;
751                              "WRITE OPT_FILE \"$x\"" } @deps)
752           || "\@ !";
753       # The linking commands looks a bit complex, but it's for good reason.
754       # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
755       # bar.obj happens to have a symbol that also exists in libsomething.exe,
756       # the linker will warn about it, loudly, and will then choose to pick
757       # the first copy encountered (the one in bar.obj in this example).
758       # On Unix and on Windows, the corresponding maneuvre goes through
759       # silently with the same effect.
760       # With some test programs, made for checking the internals of OpenSSL,
761       # we do this kind of linking deliberately, picking a few specific object
762       # files from within [.crypto] or [.ssl] so we can reach symbols that are
763       # otherwise unreachable (since the shareable images only exports the
764       # symbols listed in [.util]*.num), and then with the shared libraries
765       # themselves.  So we need to silence the warning about multiply defined
766       # symbols, to mimic the way linking work on Unix and Windows, and so
767       # the build isn't interrupted (MMS stops when warnings are signaled,
768       # by default), and so someone building doesn't have to worry where it
769       # isn't necessary.  If there are other warnings, however, we show them
770       # and let it break the build.
771       return <<"EOF";
772 $bin.EXE : $deps
773         OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
774         $write_opt1
775         $write_opt2
776         CLOSE OPT_FILE
777         - pipe SPAWN/WAIT/NOLOG/OUT=$bin.LINKLOG -
778                     LINK/EXEC=$bin.EXE \$(LDFLAGS) $bin.OPT/OPT \$(EX_LIBS) ; -
779                link_status = \$status ; link_severity = link_status .AND. 7
780         @ search_severity = 1
781         -@ IF link_severity .EQ. 0 THEN -
782                 pipe SEARCH $bin.LINKLOG "%","-"/MATCH=AND | -
783                      SPAWN/WAIT/NOLOG/OUT=NLA0: -
784                           SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
785                      search_severity = \$severity
786         @ ! search_severity is 3 when the last search didn't find any matching
787         @ ! string: %SEARCH-I-NOMATCHES, no strings matched
788         @ ! If that was the result, we pretend linking got through without
789         @ ! fault or warning.
790         @ IF search_severity .EQ. 3 THEN link_severity = 1
791         @ ! At this point, if link_severity shows that there was a fault
792         @ ! or warning, make sure to restore the linking status.
793         -@ IF .NOT. link_severity THEN TYPE $bin.LINKLOG
794         -@ DELETE $bin.LINKLOG;*
795         @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
796         - PURGE $bin.EXE,$bin.OPT
797 EOF
798   }
799   sub in2script {
800       my %args = @_;
801       my $script = $args{script};
802       return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
803       my $sources = join(" ", @{$args{sources}});
804       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
805                                            "util", "dofile.pl")),
806                            rel2abs($config{builddir}));
807       return <<"EOF";
808 $script : $sources
809         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
810             "-o$target{build_file}" $sources > $script
811         SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
812         PURGE $script
813 EOF
814   }
815   ""    # Important!  This becomes part of the template result.
816 -}