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