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