]> git.ipfire.org Git - thirdparty/openssl.git/blob - Configurations/descrip.mms.tmpl
Rework how providers/fipsmodule.cnf is produced
[thirdparty/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 use File::Basename;
7 use OpenSSL::Util;
8
9 (our $osslprefix_q = platform->osslprefix()) =~ s/\$/\\\$/;
10
11 our $sover_dirname = platform->shlib_version_as_filename();
12 our $osslver = sprintf "%02d%02d", split(/\./, $config{version});
13
14 our $sourcedir = $config{sourcedir};
15 our $builddir = $config{builddir};
16 sub make_unix_path {
17 # Split the native path
18 (my $vol, my $dirs, my $file) = File::Spec->splitpath($_[0]);
19 my @dirs = File::Spec->splitdir($dirs);
20
21 # Reassemble it as a Unix path
22 $vol =~ s|:$||;
23 return File::Spec::Unix->catpath(
24 '', File::Spec::Unix->catdir('', $vol ? $vol : (), @dirs), $file);
25 }
26 sub sourcefile {
27 catfile($sourcedir, @_);
28 }
29 sub buildfile {
30 catfile($builddir, @_);
31 }
32 sub sourcedir {
33 catdir($sourcedir, @_);
34 }
35 sub builddir {
36 catdir($builddir, @_);
37 }
38 sub tree {
39 (my $x = shift) =~ s|\]$|...]|;
40 $x
41 }
42
43 # Because we need to make two computations of these data,
44 # we store them in arrays for reuse
45 our @libs =
46 map { platform->staticname($_) }
47 @{$unified_info{libraries}};
48 our @shlibs =
49 map { platform->sharedname($_) // () }
50 @{$unified_info{libraries}};
51 our @install_libs =
52 map { platform->staticname($_) }
53 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
54 @{$unified_info{libraries}};
55 our @install_shlibs =
56 map { platform->sharedname($_) // () }
57 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
58 @{$unified_info{libraries}};
59 our @install_engines =
60 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
61 && $unified_info{attributes}->{modules}->{$_}->{engine} }
62 @{$unified_info{modules}};
63 our @install_modules =
64 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
65 && !$unified_info{attributes}->{modules}->{$_}->{engine} }
66 @{$unified_info{modules}};
67 our @install_programs =
68 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
69 @{$unified_info{programs}};
70 our @install_bin_scripts =
71 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
72 && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
73 @{$unified_info{scripts}};
74 our @install_misc_scripts =
75 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
76 && $unified_info{attributes}->{scripts}->{$_}->{misc} }
77 @{$unified_info{scripts}};
78
79 # Configured flags
80
81 our @cnf_asflags = ($target{asflags} || (), @{$config{asflags}});
82 our @cnf_defines = (@{$target{defines}}, @{$config{defines}});
83 our @cnf_includes = (@{$target{includes}}, @{$config{includes}});
84 our @cnf_cppflags = ($target{cppflags} || (), @{$config{cppflags}});
85 our @cnf_cflags = ($target{cflags} || (), @{$config{cflags}});
86 our @cnf_cxxflags = ($target{cxxflags} || (), @{$config{cxxflags}});
87 our @cnf_ldflags = ($target{lflags} || (), @{$config{lflags}});
88 our @cnf_ex_libs = (map{ ",$_" } @{$target{ex_libs}}, @{$config{ex_libs}});
89
90 # Variables starting with $lib_ are used to build library object files
91 # and shared libraries.
92 # Variables starting with $dso_ are used to build DSOs and their object files.
93 # Variables starting with $bin_ are used to build programs and their object
94 # files.
95
96 # The following array is special and is treated separately from the rest of
97 # the lib_ variables.
98 our @lib_cppincludes = (@{$target{lib_includes}}, @{$target{shared_includes}},
99 @{$config{lib_includes}}, @{$config{shared_includes}},
100 @cnf_includes);
101
102 our $lib_cppdefines =
103 join(',', @{$target{lib_defines}}, @{$target{shared_defines}},
104 @{$config{lib_defines}}, @{$config{shared_defines}},
105 @cnf_defines,
106 'OPENSSLDIR="""$(OPENSSLDIR_C)"""',
107 'ENGINESDIR="""$(ENGINESDIR_C)"""',
108 'MODULESDIR="""$(MODULESDIR_C)"""',
109 #'$(DEFINES)'
110 )
111 . "'extradefines'";
112 our $lib_asflags =
113 join(' ', $target{lib_asflags} || (), @{$config{lib_asflags}},
114 @cnf_asflags, '$(ASFLAGS)');
115 our $lib_cppflags =
116 join('', $target{lib_cppflags} || (), $target{shared_cppflags} || (),
117 @{$config{lib_cppflags}}, @{$config{shared_cppflag}},
118 @cnf_cppflags, '/DEFINE=('.$lib_cppdefines.')', '$(CPPFLAGS)');
119 my @lib_cflags = ( $target{lib_cflags} // () );
120 my @lib_cflags_no_inst = ( $target{no_inst_lib_cflags} // @lib_cflags );
121 my @lib_cflags_cont = ( $target{shared_cflag} || (),
122 @{$config{lib_cflags}}, @{$config{shared_cflag}},
123 $cnf_cflags, '$(CFLAGS)');
124 our $lib_cflags = join('', @lib_cflags, @lib_cflags_cont );
125 our $lib_cflags_no_inst = join('', @lib_cflags_no_inst, @lib_cflags_cont );
126 our $lib_ldflags =
127 join('', $target{lib_lflags} || (), $target{shared_ldflag} || (),
128 @{$config{lib_lflags}}, @{$config{shared_ldflag}},
129 @cnf_ldflags, '$(LDFLAGS)');
130 our $lib_ex_libs = join('', @cnf_ex_libs, '$(EX_LIBS)');
131
132 # The following array is special and is treated separately from the rest of
133 # the dso_ variables.
134 our @dso_cppincludes = (@{$target{dso_includes}}, @{$target{module_includes}},
135 @{$config{dso_includes}}, @{$config{module_includes}},
136 @cnf_includes);
137
138 our $dso_cppdefines =
139 join(',', @{$target{dso_defines}}, @{$target{module_defines}},
140 @{$config{dso_defines}}, @{$config{module_defines}},
141 @cnf_defines,
142 #'$(DEFINES)'
143 )
144 . "'extradefines'";
145 our $dso_asflags =
146 join(' ', $target{dso_asflags} || (), $target{module_asflags} || (),
147 @{$config{dso_asflags}}, @{$config{module_asflags}},
148 @cnf_asflags, '$(ASFLAGS)');
149 our $dso_cppflags =
150 join('', $target{dso_cppflags} || (), $target{module_cppflags} || (),
151 @{$config{dso_cppflags}}, @{$config{module_cppflag}},
152 @cnf_cppflags,
153 '/DEFINE=('.$dso_cppdefines.')',
154 '$(CPPFLAGS)');
155 my @dso_cflags = ( $target{dso_cflags} // () );
156 my @dso_cflags_no_inst = ( $target{no_inst_dso_cflags} // @dso_cflags );
157 my @dso_cflags_cont = ( $target{module_cflag} || (),
158 @{$config{dso_cflags}}, @{$config{module_cflag}},
159 $cnf_cflags, '$(CFLAGS)');
160 our $dso_cflags = join('', @dso_cflags, @dso_cflags_cont );
161 our $dso_cflags_no_inst = join('', @dso_cflags_no_inst, @dso_cflags_cont );
162 our $dso_ldflags =
163 join('', $target{dso_lflags} || (), $target{module_ldflag} || (),
164 @{$config{dso_lflags}}, @{$config{module_ldflag}},
165 @cnf_ldflags, '$(LDFLAGS)');
166 our $dso_ex_libs = join('', @cnf_ex_libs, '$(EX_LIBS)');
167
168 # The following array is special and is treated separately from the rest of
169 # the bin_ variables.
170 our @bin_cppincludes = (@{$target{bin_includes}},
171 @{$config{bin_includes}},
172 @cnf_includes);
173
174 our $bin_cppdefines =
175 join(',', @{$target{bin_defines}},
176 @{$config{bin_defines}},
177 @cnf_defines,
178 #'$(DEFINES)'
179 )
180 . "'extradefines'";
181 our $bin_asflags =
182 join(' ', $target{bin_asflags} || (),
183 @{$config{bin_asflags}},
184 @cnf_asflags, '$(ASFLAGS)');
185 our $bin_cppflags =
186 join('', $target{bin_cppflags} || (),
187 @{$config{bin_cppflags}},
188 @cnf_cppflags,
189 '/DEFINE=('.$bin_cppdefines.')',
190 '$(CPPFLAGS)');
191 my @bin_cflags = ( $target{bin_cflags} // () );
192 my @bin_cflags_no_inst = ( $target{no_inst_bin_cflags} // @bin_cflags );
193 my @bin_cflags_cont = ( @{$config{bin_cflags}},
194 $cnf_cflags, '$(CFLAGS)');
195 our $bin_cflags = join('', @bin_cflags, @bin_cflags_cont );
196 our $bin_cflags_no_inst = join('', @bin_cflags_no_inst, @bin_cflags_cont );
197 our $bin_cflags =
198 join('', $target{bin_cflags} || (),
199 @{$config{bin_cflags}},
200 @cnf_cflags, '$(CFLAGS)');
201 our $bin_ldflags =
202 join('', $target{bin_lflags} || (),
203 @{$config{bin_lflags}},
204 @cnf_ldflags, '$(LDFLAGS)');
205 our $bin_ex_libs = join('', @cnf_ex_libs, '$(EX_LIBS)');
206
207 # This is a horrible hack, but is needed because recursive inclusion of files
208 # in different directories does not work well with VMS C. We try to help by
209 # specifying extra relative directories. They must always be in Unix format,
210 # relative to the directory where the .c file is located. The logic is that
211 # any inclusion, merged with one of these relative directories, will find the
212 # requested inclusion file.
213 foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) {
214 my $obj = platform->obj($_);
215 push @{$unified_info{includes_extra}->{$obj}}, qw(../);
216 }
217 foreach (grep /\[\.crypto\.ec\.curve448\].*?\.o$/, keys %{$unified_info{sources}}) {
218 my $obj = platform->obj($_);
219 push @{$unified_info{includes_extra}->{$obj}}, qw(./arch_32 ./arch64);
220 }
221 foreach (grep /\[\.crypto\.ec\.curve448.arch_(?:32|64)\].*?\.o$/, keys %{$unified_info{sources}}) {
222 my $obj = platform->obj($_);
223 push @{$unified_info{includes_extra}->{$obj}}, qw(../);
224 }
225 foreach (grep /\[\.ssl\.(?:record|statem)\].*?\.o$/, keys %{$unified_info{sources}}) {
226 my $obj = platform->obj($_);
227 # Most of the files in [.ssl.record] and [.ssl.statem] include
228 # "../ssl_local.h", which includes things like "record/record.h".
229 # Adding "../" as an inclusion directory helps making this sort of header
230 # from these directories.
231 push @{$unified_info{includes_extra}->{$obj}}, qw(../);
232
233 }
234 foreach (grep /\[\.test\].*?\.o$/, keys %{$unified_info{sources}}) {
235 my $obj = platform->obj($_);
236 push @{$unified_info{includes_extra}->{$obj}}, qw(../ssl ./helpers);
237 }
238 foreach (grep /\[\.test\.helpers\].*?\.o$/, keys %{$unified_info{sources}}) {
239 my $obj = platform->obj($_);
240 push @{$unified_info{includes_extra}->{$obj}}, qw(../../ssl);
241 }
242
243 # This makes sure things get built in the order they need
244 # to. You're welcome.
245 sub dependmagic {
246 my $target = shift;
247
248 return "$target : build_generated\n\t\pipe \$(MMS) \$(MMSQUALIFIERS) depend && \$(MMS) \$(MMSQUALIFIERS) _$target\n_$target";
249 }
250 "";
251 -}
252 PLATFORM={- $config{target} -}
253 OPTIONS={- $config{options} -}
254 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
255 SRCDIR={- $config{sourcedir} -}
256 BLDDIR={- $config{builddir} -}
257 FIPSKEY={- $config{FIPSKEY} -}
258
259 # Allow both V and VERBOSE to indicate verbosity. This only applies
260 # to testing.
261 VERBOSE=$(V)
262 VERBOSE_FAILURE=$(VF)
263
264 VERSION={- "$config{full_version}" -}
265 MAJOR={- $config{major} -}
266 MINOR={- $config{minor} -}
267 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
268 SHLIB_TARGET={- $target{shared_target} -}
269
270 LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @libs) -}
271 SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
272 MODULES={- join(", ", map { "-\n\t".$_.".EXE" }
273 # Drop all modules that are dependencies, they will
274 # be processed through their dependents
275 grep { my $x = $_;
276 !grep { grep { $_ eq $x } @$_ }
277 values %{$unified_info{depends}} }
278 @{$unified_info{modules}}) -}
279 FIPSMODULE={- # We do some extra checking here, as there should be only one
280 use File::Basename;
281 our @fipsmodules =
282 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
283 && $unified_info{attributes}->{modules}->{$_}->{fips} }
284 @{$unified_info{modules}};
285 die "More that one FIPS module" if scalar @fipsmodules > 1;
286 join(" ", map { platform->dso($_) } @fipsmodules) -}
287 FIPSMODULENAME={- die "More that one FIPS module" if scalar @fipsmodules > 1;
288 join(", ", map { basename(platform->dso($_)) } @fipsmodules) -}
289 PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -}
290 SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
291 {- output_off() if $disabled{makedepend}; "" -}
292 DEPS={- our @deps = map { platform->isobj($_) ? platform->dep($_) : $_ }
293 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
294 keys %{$unified_info{sources}};
295 join(", ", map { "-\n\t".$_ } @deps); -}
296 {- output_on() if $disabled{makedepend}; "" -}
297 GENERATED_MANDATORY={- join(", ",
298 map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
299 GENERATED_PODS={- # common0.tmpl provides @generated
300 join(", ",
301 map { my $x = $_;
302 (
303 grep {
304 $unified_info{attributes}->{depends}
305 ->{$x}->{$_}->{pod} // 0
306 }
307 keys %{$unified_info{attributes}->{depends}->{$x}}
308 ) ? "-\n\t".$x : ();
309 }
310 @generated) -}
311 GENERATED={- # common0.tmpl provides @generated
312 join(", ", map { platform->convertext($_) } @generated) -}
313
314 INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
315 INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
316 INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @install_engines) -}
317 INSTALL_MODULES={- join(", ", map { "-\n\t".$_.".EXE" } @install_modules) -}
318 INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @install_programs) -}
319 BIN_SCRIPTS={- join(", ", @install_bin_scripts) -}
320 MISC_SCRIPTS={- join(", ", @install_misc_scripts) -}
321 HTMLDOCS1={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man1}}) -}
322 HTMLDOCS3={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man3}}) -}
323 HTMLDOCS5={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man5}}) -}
324 HTMLDOCS7={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man7}}) -}
325
326 APPS_OPENSSL="{- use File::Spec::Functions;
327 catfile("apps","openssl") -}"
328
329 # DESTDIR is for package builders so that they can configure for, say,
330 # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
331 # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
332 # MMS with /MACROS=(DESTDIR=STAGING:[USER]). The result will end up in
333 # STAGING:[USER.OPENSSL].
334 # Normally it is left empty.
335 DESTDIR=
336
337 # Do not edit this manually. Use Configure --prefix=DIR to change this!
338 INSTALLTOP={- our $installtop =
339 catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
340 $installtop -}
341 SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
342 # This is the standard central area to store certificates, private keys...
343 OPENSSLDIR={- catdir($config{openssldir}) or
344 $config{prefix} ? catdir($config{prefix},"COMMON")
345 : "SYS\$COMMON:[OPENSSL-COMMON]" -}
346 # The same, but for C
347 OPENSSLDIR_C={- platform->osslprefix() -}DATAROOT:[000000]
348 # Where installed ENGINE modules reside, for C
349 ENGINESDIR_C={- platform->osslprefix() -}ENGINES{- $sover_dirname.$target{pointer_size} -}:
350 # Where modules reside, for C
351 MODULESDIR_C={- platform->osslprefix() -}MODULES{- $sover_dirname.$target{pointer_size} -}:
352
353 ##### User defined commands and flags ################################
354
355 CC={- $config{CC} -}
356 CPP={- $config{CPP} -}
357 DEFINES={- our $defines = join('', map { ",$_" } @{$config{CPPDEFINES}}) -}
358 #INCLUDES={- our $includes = join(',', @{$config{CPPINCLUDES}}) -}
359 CPPFLAGS={- our $cppflags = join('', @{$config{CPPFLAGS}}) -}
360 CFLAGS={- join('', @{$config{CFLAGS}}) -}
361 LDFLAGS={- join('', @{$config{LFLAGS}}) -}
362 EX_LIBS={- join('', map { ",$_" } @{$config{LDLIBS}}) -}
363
364 PERL={- $config{PERL} -}
365
366 AS={- $config{AS} -}
367 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
368
369 ##### Special command flags ##########################################
370
371 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
372
373 PERLASM_SCHEME={- $target{perlasm_scheme} -}
374
375 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
376 CPPFLAGS_Q={- (my $c = $lib_cppflags.$cppflags) =~ s|"|""|g;
377 (my $d = $lib_cppdefines) =~ s|"|""|g;
378 my $i = join(',', @lib_cppincludes || (), '$(INCLUDES)');
379 my $x = $c;
380 $x .= "/INCLUDE=($i)" if $i;
381 $x .= "/DEFINE=($d)" if $d;
382 $x; -}
383
384 # .FIRST and .LAST are special targets with MMS and MMK.
385 NODEBUG=@
386 .FIRST :
387 $(NODEBUG) sourcetop = F$PARSE("$(SRCDIR)","[]A.;",,,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
388 $(NODEBUG) DEFINE ossl_sourceroot 'sourcetop'
389 $(NODEBUG) !
390 $(NODEBUG) staging_dir = "$(DESTDIR)"
391 $(NODEBUG) staging_instdir = ""
392 $(NODEBUG) staging_datadir = ""
393 $(NODEBUG) IF staging_dir .NES. "" THEN -
394 staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
395 $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
396 staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
397 $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
398 staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
399 $(NODEBUG) IF staging_dir .NES. "" THEN -
400 staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
401 $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
402 staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
403 $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
404 staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
405 $(NODEBUG) !
406 $(NODEBUG) ! Installation logical names
407 $(NODEBUG) !
408 $(NODEBUG) ! This also creates a few DCL variables that are used for
409 $(NODEBUG) ! the "install_msg" target.
410 $(NODEBUG) !
411 $(NODEBUG) installroot = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;"
412 $(NODEBUG) installtop = installroot + ".]"
413 $(NODEBUG) dataroot = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;"
414 $(NODEBUG) datatop = dataroot + ".]"
415 $(NODEBUG) DEFINE ossl_installroot 'installtop'
416 $(NODEBUG) DEFINE ossl_dataroot 'datatop'
417 $(NODEBUG) !
418 $(NODEBUG) ! Override disturbing system logicals. We can't deassign
419 $(NODEBUG) ! them, so we create it instead. This is an unfortunate
420 $(NODEBUG) ! necessity.
421 $(NODEBUG) !
422 $(NODEBUG) DEFINE openssl "{- sourcedir('include/openssl') -}
423 $(NODEBUG) !
424 $(NODEBUG) ! Figure out the architecture
425 $(NODEBUG) !
426 $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
427 $(NODEBUG) !
428 $(NODEBUG) ! Set up logical names for the libraries, so LINK and
429 $(NODEBUG) ! running programs can use them.
430 $(NODEBUG) !
431 $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } @shlibs) || "!" -}
432
433 .LAST :
434 $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -}
435 $(NODEBUG) DEASSIGN ossl_dataroot
436 $(NODEBUG) DEASSIGN ossl_installroot
437 $(NODEBUG) DEASSIGN openssl
438 .DEFAULT :
439 @ ! MMS cannot handle no actions...
440
441 # The main targets ###################################################
442
443 {- dependmagic('build_sw'); -} : build_libs_nodep, build_modules_nodep, build_programs_nodep copy-utils
444 {- dependmagic('build_libs'); -} : build_libs_nodep
445 {- dependmagic('build_modules'); -} : build_modules_nodep
446 {- dependmagic('build_programs'); -} : build_programs_nodep
447
448 build_generated_pods : $(GENERATED_PODS)
449 build_docs : build_html_docs
450 build_html_docs : $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
451
452 build_generated : $(GENERATED_MANDATORY)
453 build_libs_nodep : $(LIBS), $(SHLIBS)
454 build_modules_nodep : $(MODULES)
455 build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
456
457 # Kept around for backward compatibility
458 build_apps build_tests : build_programs
459
460 # Convenience target to prebuild all generated files, not just the mandatory
461 # ones
462 build_all_generated : $(GENERATED_MANDATORY) $(GENERATED) build_docs
463 @ ! {- output_off() if $disabled{makedepend}; "" -}
464 @ WRITE SYS$OUTPUT "Warning: consider configuring with no-makedepend, because if"
465 @ WRITE SYS$OUTPUT " target system doesn't have $(PERL),"
466 @ WRITE SYS$OUTPUT " then make will fail..."
467 @ ! {- output_on() if $disabled{makedepend}; "" -}
468
469 all : build_sw build_docs
470
471 test : tests
472 {- dependmagic('tests'); -} : build_programs_nodep, build_modules_nodep copy-utils run_tests
473 run_tests :
474 @ ! {- output_off() if $disabled{tests}; "" -}
475 DEFINE SRCTOP "$(SRCDIR)"
476 DEFINE BLDTOP "$(BLDDIR)"
477 DEFINE FIPSKEY "$(FIPSKEY)"
478 IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
479 $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
480 DEASSIGN BLDTOP
481 DEASSIGN SRCTOP
482 DEASSIGN FIPSKEY
483 @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
484 @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
485 @ ! {- output_on() if !$disabled{tests}; "" -}
486
487 list-tests :
488 @ ! {- output_off() if $disabled{tests}; "" -}
489 @ DEFINE SRCTOP "$(SRCDIR)"
490 @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
491 @ DEASSIGN SRCTOP
492 @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
493 @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
494 @ ! {- output_on() if !$disabled{tests}; "" -}
495
496 install : install_sw install_ssldirs install_docs install_msg
497
498 install_msg :
499 @ WRITE SYS$OUTPUT ""
500 @ WRITE SYS$OUTPUT "######################################################################"
501 @ WRITE SYS$OUTPUT ""
502 @ IF "$(DESTDIR)" .EQS. "" THEN -
503 @{- sourcefile("VMS", "msg_install.com") -} "$(SYSTARTUP)" "{- $osslver -}"
504 @ IF "$(DESTDIR)" .NES. "" THEN -
505 @{- sourcefile("VMS", "msg_staging.com") -} -
506 "''installroot']" "''dataroot']" "$(INSTALLTOP)" "$(OPENSSLDIR)" -
507 "$(SYSTARTUP)" "{- $osslver -}"
508
509 check_install :
510 spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
511
512 uninstall : uninstall_docs uninstall_sw
513
514 # Because VMS wants the generation number (or *) to delete files, we can't
515 # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(MODULES) directly.
516 libclean :
517 {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
518 {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
519
520 clean : libclean
521 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man1}}) || "@ !" -}
522 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man3}}) || "@ !" -}
523 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man5}}) || "@ !" -}
524 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man7}}) || "@ !" -}
525 {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
526 {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{modules}}) || "@ !" -}
527 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
528 {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -}
529 {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
530 - DELETE [...]*.MAP;*
531 - DELETE [...]*.D;*
532 - DELETE [...]*.OBJ;*,*.LIS;*
533 - DELETE []CXX$DEMANGLER_DB.;*
534 - DELETE [.VMS]openssl_startup.com;*
535 - DELETE [.VMS]openssl_shutdown.com;*
536 - DELETE []vmsconfig.pm;*
537
538 distclean : clean
539 - DELETE configdata.pm;*
540 - DELETE descrip.mms;*
541
542 depend : descrip.mms
543 descrip.mms : FORCE
544 @ ! {- output_off() if $disabled{makedepend}; "" -}
545 @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "{- $config{makedep_scheme} -}"
546 @ ! {- output_on() if $disabled{makedepend}; "" -}
547
548 # Install helper targets #############################################
549
550 install_sw : install_dev install_engines install_modules -
551 install_runtime install_startup install_ivp
552
553 uninstall_sw : uninstall_dev uninstall_modules uninstall_engines -
554 uninstall_runtime uninstall_startup uninstall_ivp
555
556 install_docs : install_html_docs
557
558 uninstall_docs : uninstall_html_docs
559
560 install_fips : install_sw
561 @ WRITE SYS$OUTPUT "*** Installing FIPS module configuration"
562 @ WRITE SYS$OUTPUT "fipsinstall $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf"
563 openssl fipsinstall -
564 -module ossl_installroot:[MODULES{- $sover_dirname.$target{pointer_size} -}.'arch']$(FIPSMODULENAME) -
565 -out ossl_installroot:[MODULES{- $sover_dirname.$target{pointer_size} -}.'arch']$(FIPSMODULENAME).cnf -
566 -macopt "hexkey:$(FIPSKEY)"
567
568 uninstall_fips : uninstall_sw
569 @ WRITE SYS$OUTPUT "*** Uninstalling FIPS module configuration"
570 DELETE ossl_installroot:[MODULES{- $sover_dirname.$target{pointer_size} -}.'arch']$(FIPSMODULENAME).cnf;*
571
572 install_ssldirs : check_INSTALLTOP
573 - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
574 IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
575 CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
576 IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
577 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
578 IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
579 CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
580 COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
581 @ ! Install configuration file
582 COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
583 ossl_dataroot:[000000]openssl.cnf-dist
584 IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN -
585 COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
586 ossl_dataroot:[000000]openssl.cnf
587 @ ! Install CTLOG configuration file
588 COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
589 ossl_dataroot:[000000]ct_log_list.cnf-dist
590 IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN -
591 COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
592 ossl_dataroot:[000000]ct_log_list.cnf
593
594 install_dev : check_INSTALLTOP install_runtime_libs
595 @ WRITE SYS$OUTPUT "*** Installing development files"
596 @ ! Install header files
597 - CREATE/DIR ossl_installroot:[include.openssl]
598 COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
599 @ ! Install static (development) libraries
600 - CREATE/DIR ossl_installroot:[LIB.'arch']
601 {- join("\n ",
602 map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
603 @install_libs) -}
604
605 install_engines : check_INSTALLTOP install_runtime_libs build_modules
606 @ {- output_off() unless scalar @install_engines; "" -} !
607 @ WRITE SYS$OUTPUT "*** Installing engines"
608 - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
609 {- join("\n ",
610 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
611 @install_engines) -}
612 @ {- output_on() unless scalar @install_engines; "" -} !
613
614 install_modules : check_INSTALLTOP install_runtime_libs build_modules
615 @ {- output_off() unless scalar @install_modules; "" -} !
616 @ WRITE SYS$OUTPUT "*** Installing modules"
617 - CREATE/DIR ossl_installroot:[MODULES{- $sover_dirname.$target{pointer_size} -}.'arch']
618 {- join("\n ",
619 map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[MODULES$sover_dirname$target{pointer_size}.'arch']" }
620 @install_modules) -}
621 @ {- output_on() unless scalar @install_modules; "" -} !
622
623 install_runtime : install_programs
624
625 install_runtime_libs : check_INSTALLTOP build_libs
626 @ {- output_off() if $disabled{shared}; "" -} !
627 @ WRITE SYS$OUTPUT "*** Installing shareable images"
628 @ ! Install shared (runtime) libraries
629 - CREATE/DIR ossl_installroot:[LIB.'arch']
630 {- join("\n ",
631 map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
632 @install_shlibs) -}
633 @ {- output_on() if $disabled{shared}; "" -} !
634
635 install_programs : check_INSTALLTOP install_runtime_libs build_programs
636 @ {- output_off() if $disabled{apps}; "" -} !
637 @ ! Install the main program
638 - CREATE/DIR ossl_installroot:[EXE.'arch']
639 COPY/PROT=W:RE [.APPS]openssl.EXE -
640 ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
641 @ ! Install scripts
642 COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
643 @ ! {- output_on() if $disabled{apps}; "" -}
644
645 install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
646 [.VMS]openssl_utils.com, check_INSTALLTOP
647 - CREATE/DIR ossl_installroot:[SYS$STARTUP]
648 COPY/PROT=W:RE [.VMS]openssl_startup.com -
649 ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com
650 COPY/PROT=W:RE [.VMS]openssl_shutdown.com -
651 ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com
652 COPY/PROT=W:RE [.VMS]openssl_utils.com -
653 ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com
654
655 install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
656 - CREATE/DIR ossl_installroot:[SYSTEST]
657 COPY/PROT=W:RE [.VMS]openssl_ivp.com -
658 ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
659
660 [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
661 - CREATE/DIR [.VMS]
662 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
663 {- sourcefile("VMS", "openssl_startup.com.in") -} -
664 > [.VMS]openssl_startup.com
665
666 [.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -}
667 - CREATE/DIR [.VMS]
668 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
669 {- sourcefile("VMS", "openssl_utils.com.in") -} -
670 > [.VMS]openssl_utils.com
671
672 [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
673 - CREATE/DIR [.VMS]
674 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
675 {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
676 > [.VMS]openssl_shutdown.com
677
678 [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -}
679 - CREATE/DIR [.VMS]
680 $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
681 {- sourcefile("VMS", "openssl_ivp.com.in") -} -
682 > [.VMS]openssl_ivp.com
683
684 vmsconfig.pm : configdata.pm
685 OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
686 WRITE CONFIG "package vmsconfig;"
687 WRITE CONFIG "use strict; use warnings;"
688 WRITE CONFIG "use Exporter;"
689 WRITE CONFIG "our @ISA = qw(Exporter);"
690 WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
691 WRITE CONFIG "our %config = ("
692 WRITE CONFIG " target => '","{- $config{target} -}","',"
693 WRITE CONFIG " version => '","{- $config{version} -}","',"
694 WRITE CONFIG " shlib_version => '","{- $config{shlib_version} -}","',"
695 WRITE CONFIG " shlib_major => '","{- $config{shlib_major} -}","',"
696 WRITE CONFIG " shlib_minor => '","{- $config{shlib_minor} -}","',"
697 WRITE CONFIG " no_shared => '","{- $disabled{shared} -}","',"
698 WRITE CONFIG " INSTALLTOP => '$(INSTALLTOP)',"
699 WRITE CONFIG " OPENSSLDIR => '$(OPENSSLDIR)',"
700 WRITE CONFIG " pointer_size => '","{- $target{pointer_size} -}","',"
701 WRITE CONFIG ");"
702 WRITE CONFIG "our %target = ();"
703 WRITE CONFIG "our %disabled = ();"
704 WRITE CONFIG "our %withargs = ();"
705 WRITE CONFIG "our %unified_info = ();"
706 WRITE CONFIG "1;"
707 CLOSE CONFIG
708
709 install_html_docs : check_INSTALLTOP build_html_docs
710 @ WRITE SYS$OUTPUT "*** Installing HTML docs"
711 - CREATE/DIR ossl_installroot:[HTML.MAN1]
712 - CREATE/DIR ossl_installroot:[HTML.MAN3]
713 - CREATE/DIR ossl_installroot:[HTML.MAN5]
714 - CREATE/DIR ossl_installroot:[HTML.MAN7]
715 {- join("\n ",
716 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN1]" }
717 @{$unified_info{htmldocs}->{man1}} ),
718 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN3]" }
719 @{$unified_info{htmldocs}->{man3}} ),
720 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN5]" }
721 @{$unified_info{htmldocs}->{man5}} ),
722 ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN7]" }
723 @{$unified_info{htmldocs}->{man7}} )) -}
724
725 check_INSTALLTOP :
726 @ IF "$(INSTALLTOP)" .EQS. "" THEN -
727 WRITE SYS$ERROR "INSTALLTOP should not be empty"
728 @ IF "$(INSTALLTOP)" .EQS. "" THEN -
729 EXIT %x10000002
730
731 # Helper targets #####################################################
732
733 copy-utils : [.util]wrap.pl
734
735 [.util]wrap.pl : configdata.pm
736 @ IF "$(SRCDIR)" .NES. "$(BLDDIR)" THEN -
737 CREATE/DIR/LOG [.util]
738 @ IF "$(SRCDIR)" .NES. "$(BLDDIR)" THEN -
739 COPY/LOG ossl_sourceroot:[util]wrap.pl [.util]
740
741 # Developer targets ##################################################
742
743 debug_logicals :
744 SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
745
746 # Building targets ###################################################
747
748 configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
749 perl configdata.pm -r
750 @ WRITE SYS$OUTPUT "*************************************************"
751 @ WRITE SYS$OUTPUT "*** ***"
752 @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***"
753 @ WRITE SYS$OUTPUT "*** ***"
754 @ WRITE SYS$OUTPUT "*************************************************"
755 @ PIPE ( EXIT %X10000000 )
756
757 reconfigure reconf :
758 perl configdata.pm -r
759
760 {-
761 use File::Basename;
762 use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
763 use File::Spec::Unix;
764
765 # Helper function to figure out dependencies on libraries
766 # It takes a list of library names and outputs a list of dependencies
767 sub compute_lib_depends {
768 # Depending on shared libraries:
769 # On Windows POSIX layers, we depend on {libname}.dll.a
770 # On Unix platforms, we depend on {shlibname}.so
771 return map {
772 { lib => platform->sharedlib($_) // platform->staticlib($_),
773 attrs => $unified_info{attributes}->{libraries}->{$_} }
774 } @_;
775 }
776
777 # Helper function to deal with inclusion directory specs.
778 # We're dealing with two issues:
779 # 1. A lot of include directory specs take up a lot of command line real
780 # estate, and the DCL command line is very limited (2KiB).
781 # 2. For optimal usage, include directory paths must be in Unix form,
782 # that's the only way the C compiler can merge multiple include paths
783 # in a sane way (we can stop worrying about 1.h including foo/2.h
784 # including ../3.h).
785 #
786 # To resolve 1, we need to create a file with include directory pragmas,
787 # and let the compiler use it with /FIRST_INCLUDE=.
788 # To resolve 2, we convert all include directory specs we get to Unix,
789 # with available File::Spec functions.
790 #
791 # We use CRC-24 from https://tools.ietf.org/html/rfc4880#section-6,
792 # reimplemented in Perl to get a workable and constant file name for each
793 # combination of include directory specs. It is assumed that the order of
794 # these directories don't matter.
795 #
796 # This function takes as input a list of include directories
797 # This function returns a list two things:
798 # 1. The file name to use with /FIRST_INCLUDE=
799 # 2. Text to insert into descrip.mms (may be the empty string)
800 sub crc24 {
801 my $input = shift;
802
803 my $init_value = 0x00B704CE;
804 my $poly_value = 0x01864CFB;
805
806 my $crc = $init_value;
807
808 foreach my $x (unpack ('C*', $input)) {
809 $crc ^= $x << 16;
810
811 for (my $i; $i < 8; $i++) {
812 $crc <<= 1;
813 if ($crc & 0x01000000) {
814 $crc ^= $poly_value;
815 }
816 }
817 }
818 $crc &= 0xFFFFFF;
819
820 return $crc;
821 }
822 my %includefile_cache;
823 sub make_includefile {
824 my %dirs = map {
825 my $udir = make_unix_path(rel2abs($_));
826
827 $udir => 1;
828 } @_;
829 my @dirs = sort keys %dirs;
830 my $filename = sprintf 'incdirs_%x.h', crc24(join(',', @dirs));
831
832 if ($includefile_cache{$filename}) {
833 return ($filename, "");
834 }
835
836 my $scripture = <<"EOF";
837 $filename :
838 open/write inc_output $filename
839 EOF
840 foreach (@dirs) {
841 $scripture .= <<"EOF";
842 write inc_output "#pragma include_directory ""$_"""
843 EOF
844 }
845 $scripture .= <<"EOF";
846 close inc_output
847 EOF
848 $includefile_cache{$filename} = $scripture;
849
850 return ($filename, $scripture);
851 }
852
853 sub generatetarget {
854 my %args = @_;
855 my $deps = join(" ", @{$args{deps}});
856 return <<"EOF";
857 $args{target} : $deps
858 EOF
859 }
860
861 sub generatesrc {
862 my %args = @_;
863 my $gen0 = $args{generator}->[0];
864 my $gen_args = join('', map { " $_" }
865 @{$args{generator}}[1..$#{$args{generator}}]);
866 my $gen_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
867 my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
868
869 if ($args{src} =~ /\.html$/) {
870 #
871 # HTML generator
872 #
873 my $title = basename($args{src}, ".html");
874 my $pod = $gen0;
875 my $mkpod2html = sourcefile('util', 'mkpod2html.pl');
876 return <<"EOF";
877 $args{src} : $pod
878 \$(PERL) $mkpod2html -i $pod -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
879 EOF
880 } elsif ($args{src} =~ /\.(\d)$/) {
881 #
882 # Man-page generator, on VMS we simply ignore man-pages
883 #
884 return "";
885 } elsif (platform->isdef($args{src})) {
886 #
887 # Linker script-ish generator
888 #
889 my $target = platform->def($args{src});
890 my $mkdef = sourcefile('util', 'mkdef.pl');
891 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
892 my $ord_name =
893 $args{generator}->[1] || basename($args{product}, '.EXE');
894 my $case_insensitive =
895 $target{$args{intent}.'_cflags'} =~ m|/NAMES=[^/]*AS_IS|i
896 ? '' : ' --case-insensitive';
897 return <<"EOF";
898 $target : $gen0 $deps $mkdef
899 \$(PERL) $mkdef$ord_ver --ordinals $gen0 --name $ord_name "--OS" "VMS"$case_insensitive > $target
900 EOF
901 } elsif (platform->isasm($args{src})) {
902 #
903 # Assembler generator
904 #
905 my $cppflags =
906 { shlib => "$lib_cflags $lib_cppflags",
907 lib => "$lib_cflags $lib_cppflags",
908 dso => "$dso_cflags $dso_cppflags",
909 bin => "$bin_cflags $bin_cppflags" } -> {$args{intent}};
910 my $defs = join("", map { ",".$_ } @{$args{defs}});
911 my $target = platform->asm($args{src});
912
913 my $generator;
914 if ($gen0 =~ /\.pl$/) {
915 $generator = '$(PERL)'.$gen_incs.' '.$gen0.$gen_args
916 .' '.$cppflags;
917 } elsif ($gen0 =~ /\.S$/) {
918 $generator = undef;
919 } else {
920 die "Generator type for $src unknown: $gen0.$gen_args\n";
921 }
922
923 if (defined($generator)) {
924 # If the target is named foo.S in build.info, we want to
925 # end up generating foo.s in two steps.
926 if ($args{src} =~ /\.S$/) {
927 return <<"EOF";
928 $target : $gen0 $deps
929 $generator \$\@-S
930 \@ extradefines = "$defs"
931 PIPE \$(CPP) $cppflags \$\@-S | -
932 \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@-i
933 \@ DELETE/SYMBOL/LOCAL extradefines
934 RENAME \$\@-i \$\@
935 DELETE \$\@-S;
936 EOF
937 }
938 # Otherwise....
939 return <<"EOF";
940 $target : $gen0 $deps
941 \@ extradefines = "$defs"
942 $generator \$\@
943 \@ DELETE/SYMBOL/LOCAL extradefines
944 EOF
945 }
946 return <<"EOF";
947 $target : $gen0 $deps
948 \@ extradefines = "$defs"
949 PIPE \$(CPP) $cppflags $gen0 | -
950 \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@
951 \@ DELETE/SYMBOL/LOCAL extradefines
952 EOF
953 } elsif ($gen0 =~ m|^.*\.in$|) {
954 #
955 # "dofile" generator (file.in -> file)
956 #
957 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
958 "util", "dofile.pl")),
959 rel2abs($config{builddir}));
960 my @modules = ( 'configdata.pm',
961 grep { $_ =~ m|\.pm$| } @{$args{deps}} );
962 my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
963 $deps = join(' ', $deps, @modules);
964 @modules = map { '"-M'.basename($_, '.pm').'"' } @modules;
965 my $modules = join(' ', '', sort keys %moduleincs, @modules);
966 return <<"EOF";
967 $args{src} : $gen0 $deps
968 \$(PERL)$modules $dofile "-o$target{build_file}" $gen0$gen_args > \$\@
969 EOF
970 } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
971 #
972 # Generic generator using OpenSSL programs
973 #
974
975 # Redo $deps, because programs aren't expected to have deps of their
976 # own. This is a little more tricky, though, because running programs
977 # may have dependencies on all sorts of files, so we search through
978 # our database of programs and modules to see if our dependencies
979 # are one of those.
980 $deps = join(' ', map { my $x = $_;
981 if (grep { $x eq $_ }
982 @{$unified_info{programs}}) {
983 platform->bin($x);
984 } elsif (grep { $x eq $_ }
985 @{$unified_info{modules}}) {
986 platform->dso($x);
987 } else {
988 $x;
989 }
990 } @{$args{deps}});
991 # Also redo $gen0, to ensure that we have the proper extension
992 $gen0 = platform->bin($gen0);
993 return <<"EOF";
994 $args{src} : $gen0 $deps
995 PIPE MCR $gen0$gen_args > \$@
996 EOF
997 } else {
998 #
999 # Generic generator using Perl
1000 #
1001 return <<"EOF";
1002 $args{src} : $gen0 $deps
1003 \$(PERL)$gen_incs $gen0$gen_args > \$\@
1004 EOF
1005 }
1006 }
1007
1008 sub src2obj {
1009 my $asmext = platform->asmext();
1010 my %args = @_;
1011 my @srcs =
1012 map { my $x = $_;
1013 (platform->isasm($x) && grep { $x eq $_ } @generated)
1014 ? platform->asm($x) : $x }
1015 ( @{$args{srcs}} );
1016 my $obj = platform->obj($args{obj});
1017 my $dep = platform->dep($args{obj});
1018 my $deps = join(", -\n\t\t", @srcs, @{$args{deps}});
1019
1020 # Because VMS C isn't very good at combining a /INCLUDE path with
1021 # #includes having a relative directory (like '#include "../foo.h"),
1022 # the best choice is to move to the first source file's intended
1023 # directory before compiling, and make sure to write the object file
1024 # in the correct position (important when the object tree is other
1025 # than the source tree).
1026 my $forward = dirname($args{srcs}->[0]);
1027 my $backward = abs2rel(rel2abs("."), rel2abs($forward));
1028 my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
1029 my $objn = basename($obj);
1030 my $depd = abs2rel(rel2abs(dirname($dep)), rel2abs($forward));
1031 my $depn = basename($dep);
1032 my $srcs =
1033 join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs);
1034 my $incextra = join(',', map { "\"$_\"" }
1035 @{$unified_info{includes_extra}->{$obj}});
1036 $incextra = "/INCLUDE=($incextra)" if $incextra;
1037 print STDERR "DEBUG: Looking for extra include directories for $obj, found this: $incextra\n"
1038 if $incextra;
1039
1040 my $cflags;
1041 if ($args{attrs}->{noinst}) {
1042 $cflags .= { shlib => $lib_cflags_no_inst,
1043 lib => $lib_cflags_no_inst,
1044 dso => $dso_cflags_no_inst,
1045 bin => $bin_cflags_no_inst } -> {$args{intent}};
1046 } else {
1047 $cflags .= { shlib => $lib_cflags,
1048 lib => $lib_cflags,
1049 dso => $dso_cflags,
1050 bin => $bin_cflags } -> {$args{intent}};
1051 }
1052 $cflags .= { shlib => $lib_cppflags,
1053 lib => $lib_cppflags,
1054 dso => $dso_cppflags,
1055 bin => $bin_cppflags } -> {$args{intent}};
1056 $cflags .= $incextra;
1057 my $defs = join("", map { ",".$_ } @{$args{defs}});
1058 my $asflags = { shlib => $lib_asflags,
1059 lib => $lib_asflags,
1060 dso => $dso_asflags,
1061 bin => $bin_asflags } -> {$args{intent}};
1062
1063 if ($srcs[0] =~ /\Q${asmext}\E$/) {
1064 return <<"EOF";
1065 $obj : $deps
1066 SET DEFAULT $forward
1067 \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn} $srcs
1068 SET DEFAULT $backward
1069 - PURGE $obj
1070 EOF
1071 } elsif ($srcs[0] =~ /.S$/) {
1072 return <<"EOF";
1073 $obj : $deps
1074 SET DEFAULT $forward
1075 \@ $incs_on
1076 \@ extradefines = "$defs"
1077 PIPE \$(CPP) ${cflags} $srcs | -
1078 \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" -
1079 > ${objd}${objn}-asm
1080 \@ DELETE/SYMBOL/LOCAL extradefines
1081 \@ $incs_off
1082 SET DEFAULT $backward
1083 \$(AS) $asflags \$(ASOUTFLAG)$obj $obj-asm
1084 - PURGE $obj
1085 EOF
1086 }
1087
1088 my ($incdir_filename, $incdir_scripture) =
1089 make_includefile(@{ { shlib => [ @lib_cppincludes ],
1090 lib => [ @lib_cppincludes ],
1091 dso => [ @dso_cppincludes ],
1092 bin => [ @bin_cppincludes ] } -> {$args{intent}} },
1093 @{$args{incs}});
1094 $deps .= ", -\n\t\t$incdir_filename";
1095 $cflags =
1096 $target{cflag_incfirst}
1097 . '"'.make_unix_path(rel2abs($incdir_filename)).'"'
1098 . $cflags;
1099
1100 my $depbuild = $disabled{makedepend} ? ""
1101 : " /MMS=(FILE=${depd}${depn},TARGET=$obj)";
1102
1103 return <<"EOF";
1104 $obj : $deps
1105 SET DEFAULT $forward
1106 \@ $incs_on
1107 \@ extradefines = "$defs"
1108 \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn} /REPOSITORY=$backward $srcs
1109 \@ DELETE/SYMBOL/LOCAL extradefines
1110 \@ $incs_off
1111 SET DEFAULT $backward
1112 - PURGE $obj
1113 $incdir_scripture
1114 EOF
1115 }
1116 sub obj2shlib {
1117 my %args = @_;
1118 my $shlibname = platform->sharedname($args{lib});
1119 my $shlib = platform->sharedlib($args{lib});
1120 my @objs = map { platform->convertext($_) }
1121 grep { platform->isobj($_) }
1122 @{$args{objs}};
1123 my @defs = map { platform->convertext($_) }
1124 grep { platform->isdef($_) }
1125 @{$args{objs}};
1126 my @deps = compute_lib_depends(@{$args{deps}});
1127 die "More than one symbol vector" if scalar @defs > 1;
1128 my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
1129 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
1130 my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
1131 "VMS", "translatesyms.pl")),
1132 rel2abs($config{builddir}));
1133 # The "[]" hack is because in .OPT files, each line inherits the
1134 # previous line's file spec as default, so if no directory spec
1135 # is present in the current line and the previous line has one that
1136 # doesn't apply, you're in for a surprise.
1137 my $write_opt1 =
1138 join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1139 "WRITE OPT_FILE \"$x" } @objs).
1140 "\"";
1141 my $write_opt2 =
1142 join("\n\t", map { my $x = $_->{lib} =~ /\[/
1143 ? $_->{lib} : "[]".$_->{lib};
1144 $x =~ s|(\.EXE)|$1/SHARE|;
1145 $x =~ s|(\.OLB)|$1/LIB|;
1146 "WRITE OPT_FILE \"$x\"" } @deps)
1147 || "\@ !";
1148 return <<"EOF"
1149 $shlib : $deps
1150 \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
1151 OPEN/WRITE/SHARE=READ OPT_FILE $shlibname-components.OPT
1152 $write_opt1
1153 $write_opt2
1154 CLOSE OPT_FILE
1155 LINK ${lib_ldflags}/SHARE=\$\@ $defs[0]-translated/OPT,-
1156 $shlibname-components.OPT/OPT \$(LIB_EX_LIBS)
1157 DELETE $defs[0]-translated;*,$shlibname-components.OPT;*
1158 PURGE $shlibname.EXE,$shlibname.MAP
1159 EOF
1160 . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1161 SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1162 EOF
1163 );
1164 }
1165 sub obj2dso {
1166 my %args = @_;
1167 my $dsoname = platform->dsoname($args{module});
1168 my $dso = platform->dso($args{module});
1169 my @objs = map { platform->convertext($_) }
1170 grep { platform->isobj($_) }
1171 @{$args{objs}};
1172 my @defs = map { platform->convertext($_) }
1173 grep { platform->isdef($_) }
1174 @{$args{objs}};
1175 my @deps = compute_lib_depends(@{$args{deps}});
1176 my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
1177 die "More than one symbol vector" if scalar @defs > 1;
1178 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
1179 # The "[]" hack is because in .OPT files, each line inherits the
1180 # previous line's file spec as default, so if no directory spec
1181 # is present in the current line and the previous line has one that
1182 # doesn't apply, you're in for a surprise.
1183 my $write_opt1 =
1184 join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1185 "WRITE OPT_FILE \"$x" } @objs).
1186 "\"";
1187 my $write_opt2 =
1188 join("\n\t", map { my $x = $_->{lib} =~ /\[/
1189 ? $_->{lib} : "[]".$_->{lib};
1190 $x =~ s|(\.EXE)|$1/SHARE|;
1191 $x =~ s|(\.OLB)|$1/LIB|;
1192 "WRITE OPT_FILE \"$x\"" } @deps)
1193 || "\@ !";
1194 return <<"EOF"
1195 $dso : $deps
1196 OPEN/WRITE/SHARE=READ OPT_FILE $dsoname-components.OPT
1197 $write_opt1
1198 $write_opt2
1199 CLOSE OPT_FILE
1200 LINK ${dso_ldflags}/SHARE=\$\@ $defs[0]/OPT,-
1201 $dsoname-components.OPT/OPT \$(DSO_EX_LIBS)
1202 - PURGE $dsoname.EXE,$dsoname.OPT,$dsoname.MAP
1203 EOF
1204 . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1205 SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1206 EOF
1207 );
1208 }
1209 sub obj2lib {
1210 my %args = @_;
1211 my $lib = platform->staticlib($args{lib});
1212 my @objs = map { platform->convertext($_) }
1213 grep { platform->isobj($_) }
1214 @{$args{objs}};
1215 my $objs = join(", -\n\t\t", @objs);
1216 my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib $_" } @objs));
1217 return <<"EOF";
1218 $lib : $objs
1219 LIBRARY/CREATE/OBJECT $lib
1220 $fill_lib
1221 - PURGE $lib
1222 EOF
1223 }
1224 sub obj2bin {
1225 my %args = @_;
1226 my $bin = platform->bin($args{bin});
1227 my $binname = platform->binname($args{bin});
1228 my @objs = map { platform->convertext($_) }
1229 grep { platform->isobj($_) }
1230 @{$args{objs}};
1231 my $objs = join(",", @objs);
1232 my @deps = compute_lib_depends(@{$args{deps}});
1233 my $deps = join(", -\n\t\t", @objs, map { $_->{lib} } @deps);
1234
1235 my $olb_count = scalar grep(m|\.OLB$|, map { $_->{lib} } @deps);
1236 my $analyse_objs = "@ !";
1237 if ($olb_count > 0) {
1238 my $analyse_quals =
1239 $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
1240 $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
1241 }
1242 # The "[]" hack is because in .OPT files, each line inherits the
1243 # previous line's file spec as default, so if no directory spec
1244 # is present in the current line and the previous line has one that
1245 # doesn't apply, you're in for a surprise.
1246 my $write_opt1 =
1247 join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
1248 "\@ WRITE OPT_FILE \"$x" } @objs).
1249 "\"";
1250 my $write_opt2 =
1251 join("\n\t", "WRITE OPT_FILE \"CASE_SENSITIVE=YES\"",
1252 map { my @lines = ();
1253 use Data::Dumper;
1254 my $x = $_->{lib} =~ /\[/
1255 ? $_->{lib} : "[]".$_->{lib};
1256 if ($x =~ m|\.EXE$|) {
1257 push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\"";
1258 } elsif ($x =~ m|\.OLB$|) {
1259 # Special hack to include the MAIN object
1260 # module explicitly. This will only be done
1261 # if there isn't a 'main' in the program's
1262 # object modules already.
1263 my $main = $_->{attrs}->{has_main}
1264 ? '/INCLUDE=main' : '';
1265 push @lines,
1266 "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB$main\"",
1267 "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\""
1268 }
1269 @lines
1270 } @deps)
1271 || "\@ !";
1272 # The linking commands looks a bit complex, but it's for good reason.
1273 # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
1274 # bar.obj happens to have a symbol that also exists in libsomething.exe,
1275 # the linker will warn about it, loudly, and will then choose to pick
1276 # the first copy encountered (the one in bar.obj in this example).
1277 # On Unix and on Windows, the corresponding maneuver goes through
1278 # silently with the same effect.
1279 # With some test programs, made for checking the internals of OpenSSL,
1280 # we do this kind of linking deliberately, picking a few specific object
1281 # files from within [.crypto] or [.ssl] so we can reach symbols that are
1282 # otherwise unreachable (since the shareable images only exports the
1283 # symbols listed in [.util]*.num), and then with the shared libraries
1284 # themselves. So we need to silence the warning about multiply defined
1285 # symbols, to mimic the way linking work on Unix and Windows, and so
1286 # the build isn't interrupted (MMS stops when warnings are signaled,
1287 # by default), and so someone building doesn't have to worry where it
1288 # isn't necessary. If there are other warnings, however, we show them
1289 # and let it break the build.
1290 return <<"EOF"
1291 $bin : $deps
1292 $analyse_objs
1293 @ OPEN/WRITE/SHARE=READ OPT_FILE $binname.OPT
1294 $write_opt1
1295 $write_opt2
1296 @ CLOSE OPT_FILE
1297 TYPE $binname.OPT ! For debugging
1298 - pipe SPAWN/WAIT/NOLOG/OUT=$binname.LINKLOG -
1299 LINK ${bin_ldflags}/EXEC=\$\@ $binname.OPT/OPT \$(BIN_EX_LIBS) ; -
1300 link_status = \$status ; link_severity = link_status .AND. 7
1301 @ search_severity = 1
1302 -@ IF link_severity .EQ. 0 THEN -
1303 pipe SEARCH $binname.LINKLOG "%","-"/MATCH=AND | -
1304 SPAWN/WAIT/NOLOG/OUT=NLA0: -
1305 SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
1306 search_severity = \$severity
1307 @ ! search_severity is 3 when the last search didn't find any matching
1308 @ ! string: %SEARCH-I-NOMATCHES, no strings matched
1309 @ ! If that was the result, we pretend linking got through without
1310 @ ! fault or warning.
1311 @ IF search_severity .EQ. 3 THEN link_severity = 1
1312 @ ! At this point, if link_severity shows that there was a fault
1313 @ ! or warning, make sure to restore the linking status.
1314 -@ IF .NOT. link_severity THEN TYPE $binname.LINKLOG
1315 -@ DELETE $binname.LINKLOG;*
1316 @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
1317 - PURGE $bin,$binname.OPT
1318 EOF
1319 . ($config{target} =~ m|alpha| ? "" : <<"EOF"
1320 SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
1321 EOF
1322 );
1323 }
1324 sub in2script {
1325 my %args = @_;
1326 my $script = $args{script};
1327 return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
1328 my $sources = join(" ", @{$args{sources}});
1329 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1330 "util", "dofile.pl")),
1331 rel2abs($config{builddir}));
1332 return <<"EOF";
1333 $script : $sources
1334 \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
1335 "-o$target{build_file}" $sources > $script
1336 SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
1337 PURGE $script
1338 EOF
1339 }
1340 "" # Important! This becomes part of the template result.
1341 -}