Missed a mention of RT
[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 =
67       ( "[.test]cipher_overhead_test.o",
68         "[.test]dtls_mtu_test.o",
69         "[.test]heartbeat_test.o",
70         "[.test]ssltest_old.o",
71         grep /^\[\.ssl\.(?:record|statem)\].*\.o$/, keys %{$unified_info{sources}} );
72   foreach (@ssl_locl_users) {
73       (my $x = $_) =~ s|\.o$|.OBJ|;
74       $unified_info{before}->{$x}
75           = qq(record_include = F\$PARSE("$sd1","A.;",,,"SYNTAX_ONLY") - "A.;"
76         define record 'record_include'
77         statem_include = F\$PARSE("$sd2","A.;",,,"SYNTAX_ONLY") - "A.;"
78         define statem 'statem_include');
79       $unified_info{after}->{$x}
80           = qq(deassign statem
81         deassign record);
82   }
83   #use Data::Dumper;
84   #print STDERR "DEBUG: before:\n", Dumper($unified_info{before});
85   #print STDERR "DEBUG: after:\n", Dumper($unified_info{after});
86   "";
87 -}
88 PLATFORM={- $config{target} -}
89 OPTIONS={- $config{options} -}
90 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
91 SRCDIR={- $config{sourcedir} -}
92 BLDDIR={- $config{builddir} -}
93
94 # Allow both V and VERBOSE to indicate verbosity.  This only applies
95 # to testing.
96 VERBOSE=$(V)
97
98 VERSION={- $config{version} -}
99 MAJOR={- $config{major} -}
100 MINOR={- $config{minor} -}
101 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
102 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
103 SHLIB_MAJOR={- $config{shlib_major} -}
104 SHLIB_MINOR={- $config{shlib_minor} -}
105 SHLIB_TARGET={- $target{shared_target} -}
106
107 EXE_EXT=.EXE
108 LIB_EXT=.OLB
109 SHLIB_EXT=.EXE
110 OBJ_EXT=.OBJ
111 DEP_EXT=.D
112
113 LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @{$unified_info{libraries}}) -}
114 SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
115 ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{engines}}) -}
116 PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -}
117 SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
118 {- output_off() if $disabled{makedepend}; "" -}
119 DEPS={- our @deps = map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
120                     grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
121                     keys %{$unified_info{sources}};
122         join(", ", map { "-\n\t".$_ } @deps); -}
123 {- output_on() if $disabled{makedepend}; "" -}
124 GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
125 GENERATED={- join(", ", map { "-\n\t".$_ } @generated) -}
126
127 INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @{$unified_info{install}->{libraries}}) -}
128 INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
129 INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{engines}}) -}
130 INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{programs}}) -}
131 {- output_off() if $disabled{apps}; "" -}
132 BIN_SCRIPTS=[.tools]c_rehash.pl
133 MISC_SCRIPTS=[.apps]CA.pl, [.apps]tsget.pl
134 {- output_on() if $disabled{apps}; "" -}
135
136 # DESTDIR is for package builders so that they can configure for, say,
137 # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
138 # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
139 # MMS with /MACROS=(DESTDIR=STAGING:[USER]).  The result will end up in
140 # STAGING:[USER.OPENSSL].
141 # Normally it is left empty.
142 DESTDIR=
143
144 # Do not edit this manually. Use Configure --prefix=DIR to change this!
145 INSTALLTOP={- our $installtop =
146                   catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
147               $installtop -}
148 SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
149 # This is the standard central area to store certificates, private keys...
150 OPENSSLDIR={- catdir($config{openssldir}) or
151               $config{prefix} ? catdir($config{prefix},"COMMON")
152                               : "SYS\$COMMON:[OPENSSL-COMMON]" -}
153 # The same, but for C
154 OPENSSLDIR_C={- $osslprefix -}DATAROOT:[000000]
155 # Where installed engines reside, for C
156 ENGINESDIR_C={- $osslprefix -}ENGINES{- $sover.$target{pointer_size} -}:
157
158 CC= {- $target{cc} -}
159 CFLAGS= /DEFINE=({- join(",", @{$target{defines}}, @{$config{defines}},"OPENSSLDIR=\"\"\"\$(OPENSSLDIR_C)\"\"\"","ENGINESDIR=\"\"\"\$(ENGINESDIR_C)\"\"\"") -}) {- $target{cflags} -} {- $config{cflags} -}
160 CFLAGS_Q=$(CFLAGS)
161 DEPFLAG= /DEFINE=({- join(",", @{$config{depdefines}}) -})
162 LDFLAGS= {- $target{lflags} -}
163 EX_LIBS= {- $target{ex_libs} ? ",".$target{ex_libs} : "" -}{- $config{ex_libs} ? ",".$config{ex_libs} : "" -}
164 LIB_CFLAGS={- $target{lib_cflags} || "" -}
165 DSO_CFLAGS={- $target{dso_cflags} || "" -}
166 BIN_CFLAGS={- $target{bin_cflags} || "" -}
167 NO_INST_LIB_CFLAGS={- $target{no_inst_lib_cflags} || '$(LIB_CFLAGS)' -}
168 NO_INST_DSO_CFLAGS={- $target{no_inst_dso_cflags} || '$(DSO_CFLAGS)' -}
169 NO_INST_BIN_CFLAGS={- $target{no_inst_bin_cflags} || '$(BIN_CFLAGS)' -}
170
171 PERL={- $config{perl} -}
172
173 # We let the C compiler driver to take care of .s files. This is done in
174 # order to be excused from maintaining a separate set of architecture
175 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
176 # gcc, then the driver will automatically translate it to -xarch=v8plus
177 # and pass it down to assembler.
178 AS={- $target{as} -}
179 ASFLAG={- $target{asflags} -}
180
181 # .FIRST and .LAST are special targets with MMS and MMK.
182 # The defines in there are for C.  includes that look like
183 # this:
184 #
185 #    #include <openssl/foo.h>
186 #    #include "internal/bar.h"
187 #
188 # will use the logical names to find the files.  Expecting
189 # DECompHP C to find files in subdirectories of whatever was
190 # given with /INCLUDE is a fantasy, unfortunately.
191 NODEBUG=@
192 .FIRST :
193         $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
194         $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
195         $(NODEBUG) internal_inc1 = F$PARSE("[.crypto.include.internal]","A.;",,,"SYNTAX_ONLY") - "A.;"
196         $(NODEBUG) internal_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
197         $(NODEBUG) internal_inc3 = F$PARSE("{- catdir($config{sourcedir},"[.crypto.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
198         $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
199         $(NODEBUG) DEFINE internal 'internal_inc1','internal_inc2','internal_inc3'
200         $(NODEBUG) staging_dir = "$(DESTDIR)"
201         $(NODEBUG) staging_instdir = ""
202         $(NODEBUG) staging_datadir = ""
203         $(NODEBUG) IF staging_dir .NES. "" THEN -
204                 staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
205         $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
206                 staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
207         $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
208                 staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
209         $(NODEBUG) IF staging_dir .NES. "" THEN -
210                 staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
211         $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
212                 staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
213         $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
214                 staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
215         $(NODEBUG) !
216         $(NODEBUG) ! Installation logical names
217         $(NODEBUG) !
218         $(NODEBUG) installtop = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
219         $(NODEBUG) datatop = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
220         $(NODEBUG) DEFINE ossl_installroot 'installtop'
221         $(NODEBUG) DEFINE ossl_dataroot 'datatop'
222         $(NODEBUG) !
223         $(NODEBUG) ! Figure out the architecture
224         $(NODEBUG) !
225         $(NODEBUG) arch == f$edit( f$getsyi( "arch_name"), "upcase")
226         $(NODEBUG) !
227         $(NODEBUG) ! Set up logical names for the libraries, so LINK and
228         $(NODEBUG) ! running programs can use them.
229         $(NODEBUG) !
230         $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}}) || "!" -}
231
232 .LAST :
233         $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}}) || "!" -}
234         $(NODEBUG) DEASSIGN ossl_dataroot
235         $(NODEBUG) DEASSIGN ossl_installroot
236         $(NODEBUG) DEASSIGN internal
237         $(NODEBUG) DEASSIGN openssl
238 .DEFAULT :
239         @ ! MMS cannot handle no actions...
240
241 # The main targets ###################################################
242
243 all : build_generated, -
244       build_libs_nodep, build_engines_nodep, build_programs_nodep, -
245       depend
246
247 build_libs : build_generated, build_libs_nodep, depend
248 build_libs_nodep : $(LIBS), $(SHLIBS)
249 build_engines : build_generated, build_engines_nodep, depend
250 build_engines_nodep : $(ENGINES)
251 build_programs : build_generated, build_programs_nodep, depend
252 build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
253
254 build_generated : $(GENERATED_MANDATORY)
255
256 # Kept around for backward compatibility
257 build_apps build_tests : build_programs
258
259 test tests : build_generated, build_programs_nodep, build_engines_nodep, -
260              depend
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   sub generatesrc {
533       my %args = @_;
534       my $generator = join(" ", @{$args{generator}});
535       my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
536       my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
537
538       if ($args{src} !~ /\.[sS]$/) {
539           if ($args{generator}->[0] =~ m|^.*\.in$|) {
540               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
541                                                    "util", "dofile.pl")),
542                                    rel2abs($config{builddir}));
543               return <<"EOF";
544 $args{src} : $args{generator}->[0] $deps
545         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\
546             "-o$target{build_file}" $generator > \$@
547 EOF
548           } else {
549               return <<"EOF";
550 $args{src} : $args{generator}->[0] $deps
551         \$(PERL)$generator_incs $generator > \$@
552 EOF
553           }
554       } else {
555           die "No method to generate assembler source present.\n";
556       }
557   }
558
559   sub src2obj {
560       my %args = @_;
561       my $obj = $args{obj};
562       my $deps = join(", -\n\t\t", @{$args{srcs}}, @{$args{deps}});
563
564       # Because VMS C isn't very good at combining a /INCLUDE path with
565       # #includes having a relative directory (like '#include "../foo.h"),
566       # the best choice is to move to the first source file's intended
567       # directory before compiling, and make sure to write the object file
568       # in the correct position (important when the object tree is other
569       # than the source tree).
570       my $forward = dirname($args{srcs}->[0]);
571       my $backward = abs2rel(rel2abs("."), rel2abs($forward));
572       my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
573       my $objn = basename($obj);
574       my $srcs =
575           join(", ",
576                map { abs2rel(rel2abs($_), rel2abs($forward)) } @{$args{srcs}});
577       my $ecflags;
578       if ($args{installed}) {
579           $ecflags = { lib => '$(LIB_CFLAGS)',
580                        dso => '$(DSO_CFLAGS)',
581                        bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
582       } else {
583           $ecflags = { lib => '$(NO_INST_LIB_CFLAGS)',
584                        dso => '$(NO_INST_DSO_CFLAGS)',
585                        bin => '$(NO_INST_BIN_CFLAGS)' } -> {$args{intent}};
586       }
587       my $incs_on = "\@ !";
588       my $incs_off = "\@ !";
589       my $incs = "";
590       my @incs = ();
591       push @incs, @{$args{incs}} if @{$args{incs}};
592       unless ($disabled{zlib}) {
593           # GNV$ZLIB_INCLUDE is the standard logical name for later zlib
594           # incarnations.
595           push @incs, ($withargs{zlib_include} || 'GNV$ZLIB_INCLUDE:');
596       }
597       if (@incs) {
598           $incs_on =
599               "DEFINE tmp_includes "
600               .join(",-\n\t\t\t", map {
601                                       file_name_is_absolute($_)
602                                       ? $_ : catdir($backward,$_)
603                                   } @incs);
604           $incs_off = "DEASSIGN tmp_includes";
605           $incs = " /INCLUDE=(tmp_includes:)";
606       }
607       my $before = $unified_info{before}->{$obj.".OBJ"} || "\@ !";
608       my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !";
609       my $depbuild = $disabled{makedepend} ? ""
610           : " /MMS=(FILE=${objd}${objn}.tmp-D,TARGET=$obj.OBJ)";
611
612       return <<"EOF";
613 $obj.OBJ : $deps
614         ${before}
615         SET DEFAULT $forward
616         $incs_on
617         \$(CC) \$(CFLAGS)${ecflags}${incs}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
618         $incs_off
619         SET DEFAULT $backward
620         ${after}
621         \@ PIPE ( \$(PERL) -e "use File::Compare qw/compare_text/; my \$x = compare_text(""$obj.D"",""$obj.tmp-D""); exit(0x10000000 + (\$x == 0));" || -
622                  RENAME $obj.tmp-D $obj.d )
623         \@ IF F\$SEARCH("$obj.tmp-D") .NES. "" THEN DELETE $obj.tmp-D;*
624         - PURGE $obj.OBJ
625 EOF
626   }
627   sub libobj2shlib {
628       my %args = @_;
629       my $lib = $args{lib};
630       my $shlib = $args{shlib};
631       my $libd = dirname($lib);
632       my $libn = basename($lib);
633       (my $mkdef_key = $libn) =~ s/^${osslprefix_q}lib([^0-9]*)\d*/$1/i;
634       my @deps = map {
635           $disabled{shared} ? $_.".OLB"
636               : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
637       my $deps = join(", -\n\t\t", @deps);
638       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
639       my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
640       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
641                                                "VMS", "engine.opt")),
642                                rel2abs($config{builddir}));
643       my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
644                                              "util", "mkdef.pl")),
645                              rel2abs($config{builddir}));
646       my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
647                                                      "VMS", "translatesyms.pl")),
648                                      rel2abs($config{builddir}));
649       # The "[]" hack is because in .OPT files, each line inherits the
650       # previous line's file spec as default, so if no directory spec
651       # is present in the current line and the previous line has one that
652       # doesn't apply, you're in for a surprise.
653       my $write_opt =
654           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
655                              $x =~ s|(\.EXE)|$1/SHARE|;
656                              $x =~ s|(\.OLB)|$1/LIB|;
657                              "WRITE OPT_FILE \"$x\"" } @deps)
658           || "\@ !";
659       return <<"EOF";
660 $shlib.EXE : $lib.OLB $deps $ordinalsfile
661         \$(PERL) $mkdef_pl "$mkdef_key" "VMS" > $shlib.SYMVEC-tmp
662         \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $shlib.SYMVEC-tmp > $shlib.SYMVEC
663         DELETE $shlib.SYMVEC-tmp;*
664         OPEN/WRITE/SHARE=READ OPT_FILE $shlib.OPT
665         WRITE OPT_FILE "IDENTIFICATION=""V$config{version}"""
666         TYPE $shlib.SYMVEC /OUTPUT=OPT_FILE:
667         WRITE OPT_FILE "$lib.OLB/LIBRARY"
668         $write_opt
669         CLOSE OPT_FILE
670         LINK /MAP=$shlib.MAP /FULL/SHARE=$shlib.EXE $shlib.OPT/OPT \$(EX_LIBS)
671         DELETE $shlib.SYMVEC;*
672         PURGE $shlib.EXE,$shlib.OPT,$shlib.MAP
673 EOF
674   }
675   sub obj2dso {
676       my %args = @_;
677       my $lib = $args{lib};
678       my $libd = dirname($lib);
679       my $libn = basename($lib);
680       (my $libn_nolib = $libn) =~ s/^lib//;
681       my @objs = map { "$_.OBJ" } @{$args{objs}};
682       my @deps = map {
683           $disabled{shared} ? $_.".OLB"
684               : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
685       my $deps = join(", -\n\t\t", @objs, @deps);
686       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
687       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
688                                                "VMS", "engine.opt")),
689                                rel2abs($config{builddir}));
690       # The "[]" hack is because in .OPT files, each line inherits the
691       # previous line's file spec as default, so if no directory spec
692       # is present in the current line and the previous line has one that
693       # doesn't apply, you're in for a surprise.
694       my $write_opt1 =
695           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
696                                  "WRITE OPT_FILE \"$x" } @objs).
697           "\"";
698       my $write_opt2 =
699           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
700                              $x =~ s|(\.EXE)|$1/SHARE|;
701                              $x =~ s|(\.OLB)|$1/LIB|;
702                              "WRITE OPT_FILE \"$x\"" } @deps)
703           || "\@ !";
704       return <<"EOF";
705 $lib.EXE : $deps
706         OPEN/WRITE/SHARE=READ OPT_FILE $lib.OPT
707         TYPE $engine_opt /OUTPUT=OPT_FILE:
708         $write_opt1
709         $write_opt2
710         CLOSE OPT_FILE
711         LINK /MAP=$lib.MAP /FULL/SHARE=$lib.EXE $lib.OPT/OPT \$(EX_LIBS)
712         - PURGE $lib.EXE,$lib.OPT,$lib.MAP
713 EOF
714   }
715   sub obj2lib {
716       my %args = @_;
717       my $lib = $args{lib};
718       my $objs = join(", -\n\t\t", map { $_.".OBJ" } (@{$args{objs}}));
719       my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_.OBJ" }
720                                     @{$args{objs}}));
721       return <<"EOF";
722 $lib.OLB : $objs
723         LIBRARY/CREATE/OBJECT $lib.OLB
724         $fill_lib
725         - PURGE $lib.OLB
726 EOF
727   }
728   sub obj2bin {
729       my %args = @_;
730       my $bin = $args{bin};
731       my $bind = dirname($bin);
732       my $binn = basename($bin);
733       my @objs = map { "$_.OBJ" } @{$args{objs}};
734       my @deps = map {
735           $disabled{shared} ? $_.".OLB"
736               : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
737       my $deps = join(", -\n\t\t", @objs, @deps);
738       # The "[]" hack is because in .OPT files, each line inherits the
739       # previous line's file spec as default, so if no directory spec
740       # is present in the current line and the previous line has one that
741       # doesn't apply, you're in for a surprise.
742       my $write_opt1 =
743           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
744                                  "WRITE OPT_FILE \"$x" } @objs).
745           "\"";
746       my $write_opt2 =
747           join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
748                              $x =~ s|(\.EXE)|$1/SHARE|;
749                              $x =~ s|(\.OLB)|$1/LIB|;
750                              "WRITE OPT_FILE \"$x\"" } @deps)
751           || "\@ !";
752       # The linking commands looks a bit complex, but it's for good reason.
753       # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
754       # bar.obj happens to have a symbol that also exists in libsomething.exe,
755       # the linker will warn about it, loudly, and will then choose to pick
756       # the first copy encountered (the one in bar.obj in this example).
757       # On Unix and on Windows, the corresponding maneuvre goes through
758       # silently with the same effect.
759       # With some test programs, made for checking the internals of OpenSSL,
760       # we do this kind of linking deliberately, picking a few specific object
761       # files from within [.crypto] or [.ssl] so we can reach symbols that are
762       # otherwise unreachable (since the shareable images only exports the
763       # symbols listed in [.util]*.num), and then with the shared libraries
764       # themselves.  So we need to silence the warning about multiply defined
765       # symbols, to mimic the way linking work on Unix and Windows, and so
766       # the build isn't interrupted (MMS stops when warnings are signaled,
767       # by default), and so someone building doesn't have to worry where it
768       # isn't necessary.  If there are other warnings, however, we show them
769       # and let it break the build.
770       return <<"EOF";
771 $bin.EXE : $deps
772         OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
773         $write_opt1
774         $write_opt2
775         CLOSE OPT_FILE
776         - pipe SPAWN/WAIT/NOLOG/OUT=$bin.LINKLOG -
777                     LINK/EXEC=$bin.EXE \$(LDFLAGS) $bin.OPT/OPT \$(EX_LIBS) ; -
778                link_status = \$status ; link_severity = link_status .AND. 7
779         @ search_severity = 1
780         -@ IF link_severity .EQ. 0 THEN -
781                 pipe SEARCH $bin.LINKLOG "%","-"/MATCH=AND | -
782                      SPAWN/WAIT/NOLOG/OUT=NLA0: -
783                           SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
784                      search_severity = \$severity
785         @ ! search_severity is 3 when the last search didn't find any matching
786         @ ! string: %SEARCH-I-NOMATCHES, no strings matched
787         @ ! If that was the result, we pretend linking got through without
788         @ ! fault or warning.
789         @ IF search_severity .EQ. 3 THEN link_severity = 1
790         @ ! At this point, if link_severity shows that there was a fault
791         @ ! or warning, make sure to restore the linking status.
792         -@ IF .NOT. link_severity THEN TYPE $bin.LINKLOG
793         -@ DELETE $bin.LINKLOG;*
794         @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
795         - PURGE $bin.EXE,$bin.OPT
796 EOF
797   }
798   sub in2script {
799       my %args = @_;
800       my $script = $args{script};
801       return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
802       my $sources = join(" ", @{$args{sources}});
803       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
804                                            "util", "dofile.pl")),
805                            rel2abs($config{builddir}));
806       return <<"EOF";
807 $script : $sources
808         \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
809             "-o$target{build_file}" $sources > $script
810         SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
811         PURGE $script
812 EOF
813   }
814   ""    # Important!  This becomes part of the template result.
815 -}