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