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