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