]> git.ipfire.org Git - thirdparty/openssl.git/blame - Configurations/unix-Makefile.tmpl
Checking __STDC_VERSION__ rather than __STRICT_ANSI__
[thirdparty/openssl.git] / Configurations / unix-Makefile.tmpl
CommitLineData
567a9e6f
RL
1##
2## Makefile for OpenSSL
3##
4## {- join("\n## ", @autowarntext) -}
5{-
da51dc5f
RL
6 use OpenSSL::Util;
7
2e535eb5
RL
8 our $makedep_scheme = $config{makedep_scheme};
9 our $makedepcmd = platform->makedepcmd();
834aae2a 10
567a9e6f 11 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
f5c174ff 12
cff89b17
AP
13 # Shared AIX support is special. We put libcrypto[64].so.ver into
14 # libcrypto.a and use libcrypto_a.a as static one.
15 sub sharedaix { !$disabled{shared} && $config{target} =~ /^aix/ }
16
9dd4ed28 17 our $sover_dirname = platform->shlib_version_as_filename();
33105818 18
27c40a93
BL
19 # This makes sure things get built in the order they need
20 # to. You're welcome.
21 sub dependmagic {
22 my $target = shift;
23
24 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
25 }
c00d9311
RL
26
27 our $COLUMNS = $ENV{COLUMNS};
28 if ($COLUMNS =~ /^\d+$/) {
29 $COLUMNS = int($COLUMNS) - 2; # 2 to leave space for ending ' \'
30 } else {
31 $COLUMNS = 76;
32 }
33
34 sub fill_lines {
35 my $item_sep = shift; # string
36 my $line_length = shift; # number of chars
37
38 my @result = ();
39 my $resultpos = 0;
40
41 foreach (@_) {
42 my $fill_line = $result[$resultpos] // '';
43 my $newline =
44 ($fill_line eq '' ? '' : $fill_line . $item_sep) . $_;
45
46 if (length($newline) > $line_length) {
47 # If this is a single item and the intended result line
48 # is empty, we put it there anyway
49 if ($fill_line eq '') {
50 $result[$resultpos++] = $newline;
51 } else {
52 $result[++$resultpos] = $_;
53 }
54 } else {
55 $result[$resultpos] = $newline;
56 }
57 }
58 return @result;
59 }
834aae2a 60 '';
567a9e6f
RL
61-}
62PLATFORM={- $config{target} -}
63OPTIONS={- $config{options} -}
64CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
65SRCDIR={- $config{sourcedir} -}
66BLDDIR={- $config{builddir} -}
31214258 67FIPSKEY={- $config{FIPSKEY} -}
567a9e6f 68
16942e08 69VERSION={- "$config{full_version}" -}
435981cb 70VERSION_NUMBER={- "$config{version}" -}
567a9e6f
RL
71MAJOR={- $config{major} -}
72MINOR={- $config{minor} -}
3a63dbef 73SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
567a9e6f 74SHLIB_TARGET={- $target{shared_target} -}
9dd4ed28 75
c00d9311
RL
76LIBS={- join(" \\\n" . ' ' x 5,
77 fill_lines(" ", $COLUMNS - 5,
78 map { platform->staticlib($_) // () }
79 @{$unified_info{libraries}})) -}
80SHLIBS={- join(" \\\n" . ' ' x 7,
81 fill_lines(" ", $COLUMNS - 7,
82 map { platform->sharedlib($_) // () }
83 @{$unified_info{libraries}})) -}
84SHLIB_INFO={- join(" \\\n" . ' ' x 11,
85 fill_lines(" ", $COLUMNS - 11,
86 map { my $x = platform->sharedlib($_);
ef161e7b
RL
87 my $y = platform->sharedlib_simple($_) // '';
88 my $z = platform->sharedlib_import($_) // '';
89 $x ? "\"$x;$y;$z\"" : () }
c00d9311
RL
90 @{$unified_info{libraries}})) -}
91MODULES={- join(" \\\n" . ' ' x 8,
92 fill_lines(" ", $COLUMNS - 8,
93 map { platform->dso($_) }
a2405c5f
RL
94 # Drop all modules that are dependencies, they will
95 # be processed through their dependents
96 grep { my $x = $_;
97 !grep { grep { $_ eq $x } @$_ }
98 values %{$unified_info{depends}} }
c00d9311 99 @{$unified_info{modules}})) -}
a2405c5f
RL
100FIPSMODULE={- # We do some extra checking here, as there should be only one
101 use File::Basename;
102 our @fipsmodules =
103 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
104 && $unified_info{attributes}->{modules}->{$_}->{fips} }
105 @{$unified_info{modules}};
106 die "More that one FIPS module" if scalar @fipsmodules > 1;
107 join(" ", map { platform->dso($_) } @fipsmodules) -}
108FIPSMODULENAME={- die "More that one FIPS module" if scalar @fipsmodules > 1;
c9b0214e 109 join(" ", map { basename(platform->dso($_)) } @fipsmodules) -}
a1bfcb15 110
c00d9311
RL
111PROGRAMS={- join(" \\\n" . ' ' x 9,
112 fill_lines(" ", $COLUMNS - 9,
113 map { platform->bin($_) }
114 @{$unified_info{programs}})) -}
115SCRIPTS={- join(" \\\n" . ' ' x 8,
116 fill_lines(" ", $COLUMNS - 8, @{$unified_info{scripts}})) -}
29eed3dd 117{- output_off() if $disabled{makedepend}; "" -}
c00d9311
RL
118DEPS={- join(" \\\n" . ' ' x 5,
119 fill_lines(" ", $COLUMNS - 5,
120 map { platform->isobj($_) ? platform->dep($_) : () }
121 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
122 keys %{$unified_info{sources}})); -}
29eed3dd 123{- output_on() if $disabled{makedepend}; "" -}
c00d9311
RL
124GENERATED_MANDATORY={- join(" \\\n" . ' ' x 20,
125 fill_lines(" ", $COLUMNS - 20,
126 @{$unified_info{depends}->{""}})) -}
9ca08f91
RL
127GENERATED_PODS={- # common0.tmpl provides @generated
128 join(" \\\n" . ' ' x 15,
129 fill_lines(" ", $COLUMNS - 15,
130 map { my $x = $_;
131 (
132 grep {
133 $unified_info{attributes}->{depends}
134 ->{$x}->{$_}->{pod} // 0
135 }
136 keys %{$unified_info{attributes}->{depends}->{$x}}
137 ) ? $x : ();
138 }
139 @generated)) -}
8258975c 140GENERATED={- # common0.tmpl provides @generated
c00d9311
RL
141 join(" \\\n" . ' ' x 5,
142 fill_lines(" ", $COLUMNS - 5,
143 map { platform->convertext($_) } @generated )) -}
9dd4ed28 144
ac6bba6f 145INSTALL_LIBS={-
c00d9311
RL
146 join(" \\\n" . ' ' x 13,
147 fill_lines(" ", $COLUMNS - 13,
148 map { platform->staticlib($_) // () }
149 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
150 @{$unified_info{libraries}}))
ac6bba6f
RL
151-}
152INSTALL_SHLIBS={-
c00d9311
RL
153 join(" \\\n" . ' ' x 15,
154 fill_lines(" ", $COLUMNS - 15,
155 map { platform->sharedlib($_) // () }
156 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
157 @{$unified_info{libraries}}))
ac6bba6f
RL
158-}
159INSTALL_SHLIB_INFO={-
c00d9311
RL
160 join(" \\\n" . ' ' x 19,
161 fill_lines(" ", $COLUMNS - 19,
162 map { my $x = platform->sharedlib($_);
ef161e7b
RL
163 my $y = platform->sharedlib_simple($_) // '';
164 my $z = platform->sharedlib_import($_) // '';
165 $x ? "\"$x;$y;$z\"" : () }
c00d9311
RL
166 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
167 @{$unified_info{libraries}}))
ac6bba6f
RL
168-}
169INSTALL_ENGINES={-
c00d9311
RL
170 join(" \\\n" . ' ' x 16,
171 fill_lines(" ", $COLUMNS - 16,
172 map { platform->dso($_) }
173 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
174 && $unified_info{attributes}->{modules}->{$_}->{engine} }
175 @{$unified_info{modules}}))
ac6bba6f 176-}
f5657ce8 177INSTALL_MODULES={-
5b689181
DMSP
178 join(" \\\n" . ' ' x 16,
179 fill_lines(" ", $COLUMNS - 16,
180 map { platform->dso($_) }
181 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
f5657ce8
RL
182 && !$unified_info{attributes}->{modules}->{$_}->{engine}
183 && !$unified_info{attributes}->{modules}->{$_}->{fips} }
5b689181
DMSP
184 @{$unified_info{modules}}))
185-}
f5657ce8 186INSTALL_FIPSMODULE={-
41149648
RL
187 join(" \\\n" . ' ' x 16,
188 fill_lines(" ", $COLUMNS - 16,
189 map { platform->dso($_) }
190 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
f5657ce8 191 && $unified_info{attributes}->{modules}->{$_}->{fips} }
41149648
RL
192 @{$unified_info{modules}}))
193-}
f5657ce8 194INSTALL_FIPSMODULECONF=providers/fipsmodule.cnf
ac6bba6f 195INSTALL_PROGRAMS={-
c00d9311
RL
196 join(" \\\n" . ' ' x 16,
197 fill_lines(" ", $COLUMNS - 16, map { platform->bin($_) }
198 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
199 @{$unified_info{programs}}))
ac6bba6f 200-}
994e86a9 201BIN_SCRIPTS={-
c00d9311
RL
202 join(" \\\n" . ' ' x 12,
203 fill_lines(" ", $COLUMNS - 12,
204 map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname};
205 $x ? "$_:$x" : $_ }
206 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
207 && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
208 @{$unified_info{scripts}}))
994e86a9
RL
209-}
210MISC_SCRIPTS={-
c00d9311
RL
211 join(" \\\n" . ' ' x 13,
212 fill_lines(" ", $COLUMNS - 13,
213 map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname};
214 $x ? "$_:$x" : $_ }
215 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
216 && $unified_info{attributes}->{scripts}->{$_}->{misc} }
217 @{$unified_info{scripts}}))
994e86a9 218-}
06621ba3
P
219IMAGEDOCS1={-
220 join(" \\\n" . ' ' x 10,
221 fill_lines(" ", $COLUMNS - 10,
222 @{$unified_info{imagedocs}->{man1}})) -}
223IMAGEDOCS3={-
224 join(" \\\n" . ' ' x 10,
225 fill_lines(" ", $COLUMNS - 10,
226 @{$unified_info{imagedocs}->{man3}})) -}
227IMAGEDOCS5={-
228 join(" \\\n" . ' ' x 10,
229 fill_lines(" ", $COLUMNS - 10,
230 @{$unified_info{imagedocs}->{man5}})) -}
231IMAGEDOCS7={-
232 join(" \\\n" . ' ' x 10,
233 fill_lines(" ", $COLUMNS - 10,
234 @{$unified_info{imagedocs}->{man7}})) -}
b0940b33
RL
235HTMLDOCS1={-
236 join(" \\\n" . ' ' x 10,
f6f159e7 237 fill_lines(" ", $COLUMNS - 10,
b0940b33
RL
238 @{$unified_info{htmldocs}->{man1}})) -}
239HTMLDOCS3={-
240 join(" \\\n" . ' ' x 10,
f6f159e7 241 fill_lines(" ", $COLUMNS - 10,
b0940b33
RL
242 @{$unified_info{htmldocs}->{man3}})) -}
243HTMLDOCS5={-
244 join(" \\\n" . ' ' x 10,
f6f159e7 245 fill_lines(" ", $COLUMNS - 10,
b0940b33
RL
246 @{$unified_info{htmldocs}->{man5}})) -}
247HTMLDOCS7={-
248 join(" \\\n" . ' ' x 10,
f6f159e7 249 fill_lines(" ", $COLUMNS - 10,
b0940b33
RL
250 @{$unified_info{htmldocs}->{man7}})) -}
251MANDOCS1={-
252 join(" \\\n" . ' ' x 9,
f6f159e7 253 fill_lines(" ", $COLUMNS - 9,
b0940b33
RL
254 @{$unified_info{mandocs}->{man1}})) -}
255MANDOCS3={-
256 join(" \\\n" . ' ' x 9,
f6f159e7 257 fill_lines(" ", $COLUMNS - 9,
b0940b33
RL
258 @{$unified_info{mandocs}->{man3}})) -}
259MANDOCS5={-
260 join(" \\\n" . ' ' x 9,
f6f159e7 261 fill_lines(" ", $COLUMNS - 9,
b0940b33
RL
262 @{$unified_info{mandocs}->{man5}})) -}
263MANDOCS7={-
264 join(" \\\n" . ' ' x 9,
f6f159e7 265 fill_lines(" ", $COLUMNS - 9,
b0940b33 266 @{$unified_info{mandocs}->{man7}})) -}
567a9e6f 267
a3f1fc25
RL
268APPS_OPENSSL="{- use File::Spec::Functions;
269 catfile("apps","openssl") -}"
6a74806e 270
3c65577f
RL
271# DESTDIR is for package builders so that they can configure for, say,
272# /usr/ and yet have everything installed to /tmp/somedir/usr/.
567a9e6f 273# Normally it is left empty.
3c65577f 274DESTDIR=
567a9e6f
RL
275
276# Do not edit these manually. Use Configure with --prefix or --openssldir
277# to change this! Short explanation in the top comment in Configure
278INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
279 #
280 our $prefix = $config{prefix} || "/usr/local";
281 $prefix -}
282OPENSSLDIR={- #
283 # The logic here is that if no --openssldir was given,
284 # OPENSSLDIR will get the value from $prefix plus "/ssl".
285 # If --openssldir was given and the value is an absolute
286 # path, OPENSSLDIR will get its value without change.
287 # If the value from --openssldir is a relative path,
288 # OPENSSLDIR will get $prefix with the --openssldir
289 # value appended as a subdirectory.
290 #
291 use File::Spec::Functions;
292 our $openssldir =
293 $config{openssldir} ?
294 (file_name_is_absolute($config{openssldir}) ?
295 $config{openssldir}
296 : catdir($prefix, $config{openssldir}))
297 : catdir($prefix, "ssl");
298 $openssldir -}
e454f3ad
RL
299LIBDIR={- our $libdir = $config{libdir};
300 unless ($libdir) {
74b7f339 301 $libdir = "lib$target{multilib}";
e454f3ad
RL
302 }
303 file_name_is_absolute($libdir) ? "" : $libdir -}
304# $(libdir) is chosen to be compatible with the GNU coding standards
305libdir={- file_name_is_absolute($libdir)
306 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
307ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
3f4e8d66 308MODULESDIR=$(libdir)/ossl-modules
567a9e6f 309
fad599f7
RL
310# Convenience variable for those who want to set the rpath in shared
311# libraries and applications
e454f3ad 312LIBRPATH=$(libdir)
fad599f7 313
dde10ab4 314MANDIR=$(INSTALLTOP)/share/man
8be7bdb5
RL
315DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
316HTMLDIR=$(DOCDIR)/html
567a9e6f 317
3544091a
RL
318# MANSUFFIX is for the benefit of anyone who may want to have a suffix
319# appended after the manpage file section number. "ssl" is popular,
320# resulting in files such as config.5ssl rather than config.5.
ae6f65ae 321MANSUFFIX=ossl
567a9e6f
RL
322HTMLSUFFIX=html
323
5407338a
RS
324# For "optional" echo messages, to get "real" silence
325ECHO = echo
567a9e6f 326
abe256e7
RL
327##### User defined commands and flags ################################
328
329# We let the C compiler driver to take care of .s files. This is done in
330# order to be excused from maintaining a separate set of architecture
331# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
332# gcc, then the driver will automatically translate it to -xarch=v8plus
333# and pass it down to assembler. In any case, we do not define AS or
334# ASFLAGS for this reason.
335
336CROSS_COMPILE={- $config{CROSS_COMPILE} -}
337CC=$(CROSS_COMPILE){- $config{CC} -}
338CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
339CPPFLAGS={- our $cppflags1 = join(" ",
340 (map { "-D".$_} @{$config{CPPDEFINES}}),
341 (map { "-I".$_} @{$config{CPPINCLUDES}}),
342 @{$config{CPPFLAGS}}) -}
343CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
344CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
345LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
346EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
347
2e535eb5 348MAKEDEPEND={- $config{makedepcmd} -}
567a9e6f 349
9e265322 350PERL={- $config{PERL} -}
567a9e6f 351
abe256e7
RL
352AR=$(CROSS_COMPILE){- $config{AR} -}
353ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
354RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
355RC= $(CROSS_COMPILE){- $config{RC} -}
356RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
357
567a9e6f 358RM= rm -f
98e5534e 359RMDIR= rmdir
abe256e7
RL
360TAR= {- $target{TAR} || "tar" -}
361TARFLAGS= {- $target{TARFLAGS} -}
567a9e6f
RL
362
363BASENAME= openssl
364NAME= $(BASENAME)-$(VERSION)
b741f153 365# Relative to $(SRCDIR)
567a9e6f
RL
366TARFILE= ../$(NAME).tar
367
abe256e7
RL
368##### Project flags ##################################################
369
370# Variables starting with CNF_ are common variables for all product types
371
372CNF_CPPFLAGS={- our $cppflags2 =
373 join(' ', $target{cppflags} || (),
374 (map { "-D".$_} @{$target{defines}},
375 @{$config{defines}}),
376 (map { "-I".$_} @{$target{includes}},
377 @{$config{includes}}),
378 @{$config{cppflags}}) -}
379CNF_CFLAGS={- join(' ', $target{cflags} || (),
380 @{$config{cflags}}) -}
381CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
382 @{$config{cxxflags}}) -}
383CNF_LDFLAGS={- join(' ', $target{lflags} || (),
384 @{$config{lflags}}) -}
385CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
386 @{$config{ex_libs}}) -}
387
388# Variables starting with LIB_ are used to build library object files
389# and shared libraries.
390# Variables starting with DSO_ are used to build DSOs and their object files.
391# Variables starting with BIN_ are used to build programs and their object
392# files.
393
58d6be5b
RL
394LIB_CPPFLAGS={- our $lib_cppflags =
395 join(' ', $target{lib_cppflags} || (),
abe256e7
RL
396 $target{shared_cppflag} || (),
397 (map { '-D'.$_ }
d368d9d2
RL
398 @{$target{lib_defines} || ()},
399 @{$target{shared_defines} || ()},
2fce15b5
RL
400 @{$config{lib_defines} || ()},
401 @{$config{shared_defines} || ()}),
d368d9d2
RL
402 (map { '-I'.quotify1($_) }
403 @{$target{lib_includes}},
404 @{$target{shared_includes}},
405 @{$config{lib_includes}},
406 @{$config{shared_includes}}),
58d6be5b
RL
407 @{$config{lib_cppflags}},
408 @{$config{shared_cppflag}});
409 join(' ', $lib_cppflags,
410 (map { '-D'.$_ }
abe256e7 411 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
3f4e8d66
RL
412 'ENGINESDIR="\"$(ENGINESDIR)\""',
413 'MODULESDIR="\"$(MODULESDIR)\""'),
abe256e7
RL
414 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
415LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
416 $target{shared_cflag} || (),
417 @{$config{lib_cflags}},
418 @{$config{shared_cflag}},
419 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
420LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
421 $target{shared_cxxflag} || (),
422 @{$config{lib_cxxflags}},
423 @{$config{shared_cxxflag}},
424 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
425LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
426 $config{shared_ldflag} || (),
427 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
428LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
429DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
430 $target{module_cppflags} || (),
2fce15b5 431 (map { '-D'.$_ }
d368d9d2
RL
432 @{$target{dso_defines}},
433 @{$target{module_defines}},
2fce15b5
RL
434 @{$config{dso_defines} || ()},
435 @{$config{module_defines} || ()}),
d368d9d2
RL
436 (map { '-I'.quotify1($_) }
437 @{$target{dso_includes}},
438 @{$target{module_includes}},
439 @{$config{dso_includes}},
440 @{$config{module_includes}}),
abe256e7
RL
441 @{$config{dso_cppflags}},
442 @{$config{module_cppflags}},
443 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
444DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
445 $target{module_cflags} || (),
446 @{$config{dso_cflags}},
447 @{$config{module_cflags}},
448 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
449DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
450 $target{module_cxxflags} || (),
451 @{$config{dso_cxxflags}},
452 @{$config{module_cxxflag}},
453 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
454DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
455 $target{module_ldflags} || (),
456 @{$config{dso_ldflags}},
457 @{$config{module_ldflags}},
458 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
459DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
460BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
2fce15b5 461 (map { '-D'.$_ } @{$config{bin_defines} || ()}),
abe256e7
RL
462 @{$config{bin_cppflags}},
463 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
464BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
465 @{$config{bin_cflags}},
466 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
467BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
468 @{$config{bin_cxxflags}},
469 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
470BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
471 @{$config{bin_lflags}},
472 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
473BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
474
475# CPPFLAGS_Q is used for one thing only: to build up buildinf.h
476CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
477 $cppflags2 =~ s|([\\"])|\\$1|g;
58d6be5b
RL
478 $lib_cppflags =~ s|([\\"])|\\$1|g;
479 join(' ', $lib_cppflags || (), $cppflags2 || (),
480 $cppflags1 || ()) -}
abe256e7 481
567a9e6f
RL
482PERLASM_SCHEME= {- $target{perlasm_scheme} -}
483
484# For x86 assembler: Set PROCESSOR to 386 if you want to support
485# the 80386.
486PROCESSOR= {- $config{processor} -}
487
9c7ce40b
AP
488# We want error [and other] messages in English. Trouble is that make(1)
489# doesn't pass macros down as environment variables unless there already
490# was corresponding variable originally set. In other words we can only
491# reassign environment variables, but not set new ones, not in portable
492# manner that is. That's why we reassign several, just to be sure...
493LC_ALL=C
494LC_MESSAGES=C
495LANG=C
496
567a9e6f
RL
497# The main targets ###################################################
498
b0940b33 499{- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils
27c40a93 500{- dependmagic('build_libs'); -}: build_libs_nodep
1842f369 501{- dependmagic('build_modules'); -}: build_modules_nodep
1e3d16b0 502{- dependmagic('build_programs'); -}: build_programs_nodep
567a9e6f 503
9ca08f91 504build_generated_pods: $(GENERATED_PODS)
b0940b33
RL
505build_docs: build_man_docs build_html_docs
506build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7)
507build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
508
27c40a93 509build_generated: $(GENERATED_MANDATORY)
c058fcd7 510build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
1842f369 511build_modules_nodep: $(MODULES)
1e3d16b0
RL
512build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
513
514# Kept around for backward compatibility
515build_apps build_tests: build_programs
68a5f1a2 516
9b03b91b
RL
517# Convenience target to prebuild all generated files, not just the mandatory
518# ones
b0940b33 519build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
18d15882
AP
520 @ : {- output_off() if $disabled{makedepend}; "" -}
521 @echo "Warning: consider configuring with no-makedepend, because if"
522 @echo " target system doesn't have $(PERL),"
523 @echo " then make will fail..."
524 @ : {- output_on() if $disabled{makedepend}; "" -}
9b03b91b 525
b0940b33
RL
526all: build_sw build_docs
527
1b741653 528test: tests
c612c7a4
DDO
529{- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep link-utils run_tests
530run_tests:
d90a6beb 531 @ : {- output_off() if $disabled{tests}; "" -}
f0790d4d
RL
532 ( SRCTOP=$(SRCDIR) \
533 BLDTOP=$(BLDDIR) \
cbece220 534 PERL="$(PERL)" \
31214258 535 FIPSKEY="$(FIPSKEY)" \
9dd4ed28 536 EXE_EXT={- platform->binext() -} \
f0790d4d 537 $(PERL) $(SRCDIR)/test/run_tests.pl $(TESTS) )
d90a6beb
MC
538 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
539 @echo "Tests are not supported with your chosen Configure options"
540 @ : {- output_on() if !$disabled{tests}; "" -}
567a9e6f
RL
541
542list-tests:
4813ad2d 543 @ : {- output_off() if $disabled{tests}; "" -}
c612c7a4 544 $(MAKE) run_tests TESTS=list
4813ad2d
RL
545 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
546 @echo "Tests are not supported with your chosen Configure options"
547 @ : {- output_on() if !$disabled{tests}; "" -}
548
18da9fc3 549install: install_sw install_ssldirs install_docs {- $disabled{fips} ? "" : "install_fips" -}
4813ad2d 550
18da9fc3 551uninstall: uninstall_docs uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -}
567a9e6f
RL
552
553libclean:
f99f91f1 554 @set -e; for s in $(SHLIB_INFO); do \
49bb4dd0 555 if [ "$$s" = ";" ]; then continue; fi; \
f99f91f1
RL
556 s1=`echo "$$s" | cut -f1 -d";"`; \
557 s2=`echo "$$s" | cut -f2 -d";"`; \
ef161e7b 558 s3=`echo "$$s" | cut -f3 -d";"`; \
49bb4dd0
BE
559 $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
560 $(RM) apps/$$s1; \
561 $(RM) test/$$s1; \
562 $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
f99f91f1 563 $(RM) $$s1; \
ef161e7b 564 if [ "$$s2" != "" ]; then \
5407338a 565 $(ECHO) $(RM) $$s2; \
f99f91f1
RL
566 $(RM) $$s2; \
567 fi; \
ef161e7b
RL
568 if [ "$$s3" != "" ]; then \
569 $(ECHO) $(RM) $$s3; \
570 $(RM) $$s3; \
571 fi; \
f99f91f1
RL
572 done
573 $(RM) $(LIBS)
9dd4ed28 574 $(RM) *{- platform->defext() -}
567a9e6f
RL
575
576clean: libclean
c47a0803
RB
577 $(RM) $(HTMLDOCS1)
578 $(RM) $(HTMLDOCS3)
579 $(RM) $(HTMLDOCS5)
580 $(RM) $(HTMLDOCS7)
581 $(RM) $(MANDOCS1)
582 $(RM) $(MANDOCS3)
583 $(RM) $(MANDOCS5)
584 $(RM) $(MANDOCS7)
d94c2f1b 585 $(RM) $(PROGRAMS) $(TESTPROGS) $(MODULES) $(FIPSMODULE) $(SCRIPTS)
b0a97931 586 $(RM) $(GENERATED_MANDATORY) $(GENERATED)
0ce47b35
RL
587 -find . -name '*{- platform->depext() -}' \! -name '.*' \! -type d -exec $(RM) {} \;
588 -find . -name '*{- platform->objext() -}' \! -name '.*' \! -type d -exec $(RM) {} \;
4813ad2d 589 $(RM) core
5bac37cb 590 $(RM) tags TAGS doc-nits md-nits
d016d1ec 591 $(RM) -r test/test-runs
a3c86ce9 592 $(RM) providers/fips*.new
4813ad2d 593 $(RM) openssl.pc libcrypto.pc libssl.pc
0ce47b35 594 -find . -type l \! -name '.*' -exec $(RM) {} \;
567a9e6f 595
7cae3864 596distclean: clean
ef8040bc 597 $(RM) include/openssl/configuration.h
4813ad2d
RL
598 $(RM) configdata.pm
599 $(RM) Makefile
7cae3864 600
f8d9d6e4 601# We check if any depfile is newer than Makefile and decide to
a6adf099 602# concatenate only if that is true.
468d1517 603depend: Makefile
29eed3dd 604 @: {- output_off() if $disabled{makedepend}; "" -}
2e535eb5 605 @$(PERL) $(SRCDIR)/util/add-depends.pl "{- $makedep_scheme -}"
29eed3dd 606 @: {- output_on() if $disabled{makedepend}; "" -}
567a9e6f
RL
607
608# Install helper targets #############################################
609
41149648 610install_sw: install_dev install_engines install_modules install_runtime
567a9e6f 611
41149648 612uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
567a9e6f
RL
613
614install_docs: install_man_docs install_html_docs
615
616uninstall_docs: uninstall_man_docs uninstall_html_docs
3b8033f3 617 $(RM) -r $(DESTDIR)$(DOCDIR)
567a9e6f 618
18da9fc3 619{- output_off() if $disabled{fips}; "" -}
f5657ce8 620install_fips: build_sw $(INSTALL_FIPSMODULECONF)
5b689181
DMSP
621 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
622 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MODULESDIR)
85efdaab 623 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)
5b689181 624 @$(ECHO) "*** Installing FIPS module"
f5657ce8
RL
625 @$(ECHO) "install $(INSTALL_FIPSMODULE) -> $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
626 @cp "$(INSTALL_FIPSMODULE)" $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new
5b689181
DMSP
627 @chmod 755 $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new
628 @mv -f $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new \
629 $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)
a1bfcb15 630 @$(ECHO) "*** Installing FIPS module configuration"
f5657ce8
RL
631 @$(ECHO) "install $(INSTALL_FIPSMODULECONF) -> $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
632 @cp $(INSTALL_FIPSMODULECONF) $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf
a1bfcb15 633
5b689181 634uninstall_fips:
a1bfcb15 635 @$(ECHO) "*** Uninstalling FIPS module configuration"
c3bda8a2 636 $(RM) $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf
5b689181
DMSP
637 @$(ECHO) "*** Uninstalling FIPS module"
638 $(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)
18da9fc3
DMSP
639{- if ($disabled{fips}) { output_on(); } else { output_off(); } "" -}
640install_fips:
641 @$(ECHO) "The 'install_fips' target requires the 'enable-fips' option"
642
643uninstall_fips:
644 @$(ECHO) "The 'uninstall_fips' target requires the 'enable-fips' option"
645{- output_on() if !$disabled{fips}; "" -}
646
a1bfcb15 647
dde10ab4
RL
648install_ssldirs:
649 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
650 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
66c2eb8b 651 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
4813ad2d
RL
652 @set -e; for x in dummy $(MISC_SCRIPTS); do \
653 if [ "$$x" = "dummy" ]; then continue; fi; \
d8356e1b
RL
654 x1=`echo "$$x" | cut -f1 -d:`; \
655 x2=`echo "$$x" | cut -f2 -d:`; \
656 fn=`basename $$x1`; \
657 $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
658 cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
4813ad2d
RL
659 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
660 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
661 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
d8356e1b
RL
662 if [ "$$x1" != "$$x2" ]; then \
663 ln=`basename "$$x2"`; \
664 : {- output_off() unless windowsdll(); "" -}; \
665 $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
666 cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
667 : {- output_on() unless windowsdll();
668 output_off() if windowsdll(); "" -}; \
669 $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
670 ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
671 : {- output_on() if windowsdll(); "" -}; \
672 fi; \
4813ad2d 673 done
5407338a 674 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
4813ad2d
RL
675 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
676 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
cb926df2 677 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
c7af65c7 678 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
5407338a 679 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
cb926df2
RL
680 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
681 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
682 fi
5407338a 683 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
c7af65c7
RS
684 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
685 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
686 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
687 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
5407338a 688 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
c7af65c7
RS
689 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
690 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
691 fi
dde10ab4 692
c1123d9f 693install_dev: install_runtime_libs
567a9e6f 694 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 695 @$(ECHO) "*** Installing development files"
3c65577f 696 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
6d56fcd8 697 @ : {- output_off() if $disabled{uplink}; "" -}
5407338a 698 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
24c4f736
RL
699 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
700 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
6d56fcd8 701 @ : {- output_on() if $disabled{uplink}; "" -}
567a9e6f
RL
702 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
703 $(BLDDIR)/include/openssl/*.h; do \
704 fn=`basename $$i`; \
5407338a 705 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
3c65577f
RL
706 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
707 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 708 done
e454f3ad 709 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
0f01b7bc 710 @set -e; for l in $(INSTALL_LIBS); do \
567a9e6f 711 fn=`basename $$l`; \
e454f3ad
RL
712 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
713 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
714 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
715 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
716 mv -f $(DESTDIR)$(libdir)/$$fn.new \
717 $(DESTDIR)$(libdir)/$$fn; \
567a9e6f 718 done
84af1bae 719 @ : {- output_off() if $disabled{shared}; "" -}
0f01b7bc 720 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
c8c2b779
RL
721 s1=`echo "$$s" | cut -f1 -d";"`; \
722 s2=`echo "$$s" | cut -f2 -d";"`; \
ef161e7b 723 s3=`echo "$$s" | cut -f3 -d";"`; \
d9c22dde
RL
724 fn1=`basename "$$s1"`; \
725 fn2=`basename "$$s2"`; \
726 fn3=`basename "$$s3"`; \
cff89b17 727 : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
ef161e7b 728 if [ "$$fn2" != "" ]; then \
e454f3ad
RL
729 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
730 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
567a9e6f 731 fi; \
cff89b17 732 : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
d9c22dde
RL
733 if [ "$$fn3" != "" ]; then \
734 $(ECHO) "install $$s3 -> $(DESTDIR)$(libdir)/$$fn3"; \
735 cp $$s3 $(DESTDIR)$(libdir)/$$fn3.new; \
736 chmod 755 $(DESTDIR)$(libdir)/$$fn3.new; \
737 mv -f $(DESTDIR)$(libdir)/$$fn3.new \
738 $(DESTDIR)$(libdir)/$$fn3; \
739 fi; \
cff89b17
AP
740 : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
741 a=$(DESTDIR)$(libdir)/$$fn2; \
742 $(ECHO) "install $$s1 -> $$a"; \
743 if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
744 mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
745 cp -f $$a $$a.new; \
746 for so in `$(AR) t $$a`; do \
747 $(AR) x $$a $$so; \
748 chmod u+w $$so; \
749 strip -X32_64 -e $$so; \
750 $(AR) r $$a.new $$so; \
751 done; \
752 )); fi; \
753 $(AR) r $$a.new $$s1; \
754 mv -f $$a.new $$a; \
755 : {- output_off() if sharedaix(); output_on(); "" -}; \
567a9e6f 756 done
84af1bae 757 @ : {- output_on() if $disabled{shared}; "" -}
e454f3ad
RL
758 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
759 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
760 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
761 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
762 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
763 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
764 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
765 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
766 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
767 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
567a9e6f 768
c1123d9f 769uninstall_dev: uninstall_runtime_libs
5407338a 770 @$(ECHO) "*** Uninstalling development files"
6d56fcd8 771 @ : {- output_off() if $disabled{uplink}; "" -}
5407338a 772 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
24c4f736 773 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
6d56fcd8 774 @ : {- output_on() if $disabled{uplink}; "" -}
567a9e6f
RL
775 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
776 $(BLDDIR)/include/openssl/*.h; do \
777 fn=`basename $$i`; \
5407338a 778 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
3c65577f 779 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 780 done
98e5534e
RL
781 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
782 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
0f01b7bc 783 @set -e; for l in $(INSTALL_LIBS); do \
567a9e6f 784 fn=`basename $$l`; \
e454f3ad
RL
785 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
786 $(RM) $(DESTDIR)$(libdir)/$$fn; \
567a9e6f 787 done
84af1bae 788 @ : {- output_off() if $disabled{shared}; "" -}
0f01b7bc 789 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
c8c2b779
RL
790 s1=`echo "$$s" | cut -f1 -d";"`; \
791 s2=`echo "$$s" | cut -f2 -d";"`; \
ef161e7b 792 s3=`echo "$$s" | cut -f3 -d";"`; \
d9c22dde
RL
793 fn1=`basename "$$s1"`; \
794 fn2=`basename "$$s2"`; \
795 fn3=`basename "$$s3"`; \
c8c2b779 796 : {- output_off() if windowsdll(); "" -}; \
ef161e7b
RL
797 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
798 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
799 if [ -n "$$fn2" ]; then \
800 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
801 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
567a9e6f 802 fi; \
c8c2b779 803 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
d9c22dde
RL
804 if [ -n "$$fn3" ]; then \
805 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn3"; \
806 $(RM) $(DESTDIR)$(libdir)/$$fn3; \
807 fi; \
ce5ed82f 808 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 809 done
c8cca980 810 @ : {- output_on() if $disabled{shared}; "" -}
e454f3ad
RL
811 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
812 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
813 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
814 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
815 -$(RMDIR) $(DESTDIR)$(libdir)
567a9e6f 816
41149648
RL
817_install_modules_deps: install_runtime_libs build_modules
818
819install_engines: _install_modules_deps
567a9e6f 820 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
b2de11c5 821 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
41149648 822 @$(ECHO) "*** Installing engines"
0f01b7bc 823 @set -e; for e in dummy $(INSTALL_ENGINES); do \
2b364f61 824 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 825 fn=`basename $$e`; \
5407338a 826 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
b2de11c5
RL
827 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
828 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
829 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
830 $(DESTDIR)$(ENGINESDIR)/$$fn; \
567a9e6f
RL
831 done
832
833uninstall_engines:
41149648 834 @$(ECHO) "*** Uninstalling engines"
0f01b7bc 835 @set -e; for e in dummy $(INSTALL_ENGINES); do \
2b364f61 836 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 837 fn=`basename $$e`; \
5407338a 838 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
b2de11c5 839 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
567a9e6f 840 done
b2de11c5 841 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
567a9e6f 842
41149648
RL
843install_modules: _install_modules_deps
844 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
845 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MODULESDIR)/
846 @$(ECHO) "*** Installing modules"
847 @set -e; for e in dummy $(INSTALL_MODULES); do \
848 if [ "$$e" = "dummy" ]; then continue; fi; \
849 fn=`basename $$e`; \
850 $(ECHO) "install $$e -> $(DESTDIR)$(MODULESDIR)/$$fn"; \
851 cp $$e $(DESTDIR)$(MODULESDIR)/$$fn.new; \
852 chmod 755 $(DESTDIR)$(MODULESDIR)/$$fn.new; \
853 mv -f $(DESTDIR)$(MODULESDIR)/$$fn.new \
854 $(DESTDIR)$(MODULESDIR)/$$fn; \
855 done
856
857uninstall_modules:
858 @$(ECHO) "*** Uninstalling modules"
859 @set -e; for e in dummy $(INSTALL_MODULES); do \
860 if [ "$$e" = "dummy" ]; then continue; fi; \
861 fn=`basename $$e`; \
41149648
RL
862 $(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$$fn"; \
863 $(RM) $(DESTDIR)$(MODULESDIR)/$$fn; \
864 done
865 -$(RMDIR) $(DESTDIR)$(MODULESDIR)
866
c1123d9f
RL
867install_runtime: install_programs
868
e8d01a60 869install_runtime_libs: build_libs
567a9e6f 870 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
36b53720 871 @ : {- output_off() if windowsdll(); "" -}
e454f3ad 872 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
9694ebf7
RL
873 @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
874 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
875 @ : {- output_on() unless windowsdll(); "" -}
c1123d9f 876 @$(ECHO) "*** Installing runtime libraries"
0f01b7bc 877 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
2b364f61 878 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 879 fn=`basename $$s`; \
36b53720 880 : {- output_off() unless windowsdll(); "" -}; \
5407338a 881 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 882 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
fa63e452 883 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
3c65577f
RL
884 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
885 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
36b53720 886 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
e454f3ad
RL
887 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
888 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
889 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
890 mv -f $(DESTDIR)$(libdir)/$$fn.new \
891 $(DESTDIR)$(libdir)/$$fn; \
36b53720 892 : {- output_on() if windowsdll(); "" -}; \
fcf80c46 893 done
c1123d9f 894
e8d01a60 895install_programs: install_runtime_libs build_programs
c1123d9f
RL
896 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
897 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
898 @$(ECHO) "*** Installing runtime programs"
0f01b7bc 899 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
2b364f61 900 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 901 fn=`basename $$x`; \
5407338a 902 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
903 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
904 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
905 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
906 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 907 done
2b364f61
RL
908 @set -e; for x in dummy $(BIN_SCRIPTS); do \
909 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 910 fn=`basename $$x`; \
5407338a 911 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
912 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
913 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
914 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
915 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 916 done
567a9e6f 917
c1123d9f
RL
918uninstall_runtime: uninstall_programs uninstall_runtime_libs
919
920uninstall_programs:
921 @$(ECHO) "*** Uninstalling runtime programs"
0f01b7bc 922 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
567a9e6f 923 do \
2b364f61 924 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 925 fn=`basename $$x`; \
5407338a 926 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 927 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 928 done;
2b364f61 929 @set -e; for x in dummy $(BIN_SCRIPTS); \
567a9e6f 930 do \
2b364f61 931 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 932 fn=`basename $$x`; \
5407338a 933 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 934 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 935 done
c1123d9f
RL
936 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
937
938uninstall_runtime_libs:
939 @$(ECHO) "*** Uninstalling runtime libraries"
b1837abd 940 @ : {- output_off() unless windowsdll(); "" -}
0f01b7bc 941 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
2b364f61 942 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 943 fn=`basename $$s`; \
5407338a 944 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 945 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
fcf80c46 946 done
b1837abd 947 @ : {- output_on() unless windowsdll(); "" -}
567a9e6f 948
567a9e6f 949
b0940b33 950install_man_docs: build_man_docs
567a9e6f 951 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
b0940b33
RL
952 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man1
953 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man3
954 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man5
955 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man7
5407338a 956 @$(ECHO) "*** Installing manpages"
b0940b33
RL
957 @set -e; for x in dummy $(MANDOCS1); do \
958 if [ "$$x" = "dummy" ]; then continue; fi; \
959 fn=`basename $$x`; \
cf86057a
SAS
960 $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
961 cp $$x $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \
d685fc7a 962 chmod 644 $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \
9e7a6411 963 $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man1 $(BLDDIR)/doc/man1 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man1; \
b0940b33
RL
964 done
965 @set -e; for x in dummy $(MANDOCS3); do \
966 if [ "$$x" = "dummy" ]; then continue; fi; \
967 fn=`basename $$x`; \
cf86057a
SAS
968 $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
969 cp $$x $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \
d685fc7a 970 chmod 644 $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \
9e7a6411 971 $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man3 $(BLDDIR)/doc/man3 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man3; \
b0940b33
RL
972 done
973 @set -e; for x in dummy $(MANDOCS5); do \
974 if [ "$$x" = "dummy" ]; then continue; fi; \
975 fn=`basename $$x`; \
cf86057a
SAS
976 $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
977 cp $$x $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \
d685fc7a 978 chmod 644 $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \
9e7a6411 979 $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man5 $(BLDDIR)/doc/man5 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man5; \
b0940b33
RL
980 done
981 @set -e; for x in dummy $(MANDOCS7); do \
982 if [ "$$x" = "dummy" ]; then continue; fi; \
983 fn=`basename $$x`; \
cf86057a
SAS
984 $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
985 cp $$x $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \
d685fc7a 986 chmod 644 $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \
9e7a6411 987 $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man7 $(BLDDIR)/doc/man7 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man7; \
b0940b33 988 done
567a9e6f 989
9e7a6411 990uninstall_man_docs: build_man_docs
5407338a 991 @$(ECHO) "*** Uninstalling manpages"
b0940b33
RL
992 @set -e; for x in dummy $(MANDOCS1); do \
993 if [ "$$x" = "dummy" ]; then continue; fi; \
994 fn=`basename $$x`; \
cf86057a
SAS
995 $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
996 $(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \
9e7a6411 997 $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man1 $(BLDDIR)/doc/man1 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man1; \
b0940b33
RL
998 done
999 @set -e; for x in dummy $(MANDOCS3); do \
1000 if [ "$$x" = "dummy" ]; then continue; fi; \
1001 fn=`basename $$x`; \
cf86057a
SAS
1002 $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
1003 $(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \
9e7a6411 1004 $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man3 $(BLDDIR)/doc/man3 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man3; \
b0940b33
RL
1005 done
1006 @set -e; for x in dummy $(MANDOCS5); do \
1007 if [ "$$x" = "dummy" ]; then continue; fi; \
1008 fn=`basename $$x`; \
cf86057a
SAS
1009 $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
1010 $(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \
9e7a6411 1011 $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man5 $(BLDDIR)/doc/man5 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man5; \
b0940b33
RL
1012 done
1013 @set -e; for x in dummy $(MANDOCS7); do \
1014 if [ "$$x" = "dummy" ]; then continue; fi; \
1015 fn=`basename $$x`; \
cf86057a
SAS
1016 $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
1017 $(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \
9e7a6411 1018 $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man7 $(BLDDIR)/doc/man7 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man7; \
b0940b33 1019 done
567a9e6f 1020
06621ba3 1021install_html_docs: install_image_docs build_html_docs
567a9e6f 1022 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
b0940b33
RL
1023 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man1
1024 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man3
1025 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man5
1026 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man7
5407338a 1027 @$(ECHO) "*** Installing HTML manpages"
b0940b33
RL
1028 @set -e; for x in dummy $(HTMLDOCS1); do \
1029 if [ "$$x" = "dummy" ]; then continue; fi; \
1030 fn=`basename $$x`; \
1031 $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
1032 cp $$x $(DESTDIR)$(HTMLDIR)/man1/$$fn; \
d685fc7a 1033 chmod 644 $(DESTDIR)$(HTMLDIR)/man1/$$fn; \
b0940b33
RL
1034 done
1035 @set -e; for x in dummy $(HTMLDOCS3); do \
1036 if [ "$$x" = "dummy" ]; then continue; fi; \
1037 fn=`basename $$x`; \
1038 $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
1039 cp $$x $(DESTDIR)$(HTMLDIR)/man3/$$fn; \
d685fc7a 1040 chmod 644 $(DESTDIR)$(HTMLDIR)/man3/$$fn; \
b0940b33
RL
1041 done
1042 @set -e; for x in dummy $(HTMLDOCS5); do \
1043 if [ "$$x" = "dummy" ]; then continue; fi; \
1044 fn=`basename $$x`; \
1045 $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
1046 cp $$x $(DESTDIR)$(HTMLDIR)/man5/$$fn; \
d685fc7a 1047 chmod 644 $(DESTDIR)$(HTMLDIR)/man5/$$fn; \
b0940b33
RL
1048 done
1049 @set -e; for x in dummy $(HTMLDOCS7); do \
1050 if [ "$$x" = "dummy" ]; then continue; fi; \
1051 fn=`basename $$x`; \
1052 $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
1053 cp $$x $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
d685fc7a 1054 chmod 644 $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
b0940b33 1055 done
567a9e6f 1056
06621ba3 1057uninstall_html_docs: uninstall_image_docs
b0940b33
RL
1058 @$(ECHO) "*** Uninstalling HTML manpages"
1059 @set -e; for x in dummy $(HTMLDOCS1); do \
1060 if [ "$$x" = "dummy" ]; then continue; fi; \
1061 fn=`basename $$x`; \
1062 $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
1063 $(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn; \
1064 done
1065 @set -e; for x in dummy $(HTMLDOCS3); do \
1066 if [ "$$x" = "dummy" ]; then continue; fi; \
1067 fn=`basename $$x`; \
1068 $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
1069 $(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn; \
1070 done
1071 @set -e; for x in dummy $(HTMLDOCS5); do \
1072 if [ "$$x" = "dummy" ]; then continue; fi; \
1073 fn=`basename $$x`; \
1074 $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
1075 $(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn; \
1076 done
1077 @set -e; for x in dummy $(HTMLDOCS7); do \
1078 if [ "$$x" = "dummy" ]; then continue; fi; \
1079 fn=`basename $$x`; \
1080 $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
1081 $(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
1082 done
567a9e6f 1083
06621ba3 1084install_image_docs:
06621ba3 1085 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man7/img
06621ba3
P
1086 @set -e; for x in dummy $(IMAGEDOCS7); do \
1087 if [ "$$x" = "dummy" ]; then continue; fi; \
1088 fn=`basename $$x`; \
1089 $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
1090 cp $(SRCDIR)/$$x $(DESTDIR)$(HTMLDIR)/man7/img/$$fn; \
1091 chmod 644 $(DESTDIR)$(HTMLDIR)/man7/img/$$fn; \
1092 done
1093
1094uninstall_image_docs:
06621ba3
P
1095 @set -e; for x in dummy $(IMAGEDOCS7); do \
1096 if [ "$$x" = "dummy" ]; then continue; fi; \
1097 fn=`basename $$x`; \
1098 $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
1099 $(RM) $(DESTDIR)$(HTMLDIR)/man7/img/$$fn; \
1100 done
1101
567a9e6f
RL
1102# Developer targets (note: these are only available on Unix) #########
1103
7b9f8995
RL
1104# It's important that generate_buildinfo comes after ordinals, as ordinals
1105# is sensitive to build.info changes.
1106update: generate errors ordinals generate_buildinfo
6bb2106e 1107
b7650c67 1108generate: generate_apps generate_crypto_bn generate_crypto_objects \
8e32e1ab 1109 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
567a9e6f 1110
7b9f8995
RL
1111generate_buildinfo: generate_doc_buildinfo
1112
5bac37cb 1113.PHONY: doc-nits md-nits
9ca08f91 1114doc-nits: build_generated_pods
5bac37cb 1115 $(PERL) $(SRCDIR)/util/find-doc-nits -c -n -l -e
65718c51 1116
a51f225d
RS
1117# This uses "mdl", the markdownlint application, which is written in ruby.
1118# The source is at https://github.com/markdownlint/markdownlint
1119# If you have ruby installed, "gem install mdl" should work.
1120# Another option is at https://snapcraft.io/install/mdl/debian
1121# Finally, there's a Node.js version, which we haven't tried, that
1122# can be found at https://github.com/DavidAnson/markdownlint
1123md-nits:
9f1fe6a9 1124 mdl -s util/markdownlint.rb .
a51f225d 1125
567a9e6f
RL
1126# Test coverage is a good idea for the future
1127#coverage: $(PROGRAMS) $(TESTPROGRAMS)
1128# ...
1129
567a9e6f
RL
1130lint:
1131 lint -DLINT $(INCLUDES) $(SRCS)
1132
d040a1b9 1133$(SRCDIR)/apps/openssl-vms.cnf: $(SRCDIR)/apps/openssl.cnf
9a9f8ee7
RL
1134 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
1135 < apps/openssl.cnf > apps/openssl-vms.cnf )
d040a1b9
DDO
1136.PHONY: generate_apps
1137generate_apps: $(SRCDIR)/apps/openssl-vms.cnf
9a9f8ee7 1138
d040a1b9 1139$(SRCDIR)/crypto/bn/bn_prime.h: $(SRCDIR)/crypto/bn/bn_prime.pl
9a9f8ee7 1140 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
d040a1b9
DDO
1141.PHONY: generate_crypto_bn
1142generate_crypto_bn: $(SRCDIR)/crypto/bn/bn_prime.h
9a9f8ee7 1143
d040a1b9
DDO
1144$(SRCDIR)/crypto/objects/obj_mac.num: $(SRCDIR)/crypto/objects/objects.pl \
1145 $(SRCDIR)/crypto/objects/objects.txt
22defb43
RS
1146 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
1147 crypto/objects/objects.txt \
1148 crypto/objects/obj_mac.num \
1149 > crypto/objects/obj_mac.new && \
1150 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
d040a1b9
DDO
1151$(SRCDIR)/include/openssl/obj_mac.h: $(SRCDIR)/crypto/objects/objects.pl \
1152 $(SRCDIR)/crypto/objects/obj_dat.pl \
1153 $(SRCDIR)/crypto/objects/obj_mac.num \
1154 $(SRCDIR)/crypto/objects/obj_compat.h
9a9f8ee7
RL
1155 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
1156 crypto/objects/objects.txt \
1157 crypto/objects/obj_mac.num \
d040a1b9
DDO
1158 > include/openssl/obj_mac.h && \
1159 $(PERL) crypto/objects/obj_dat.pl \
e6f2bb66 1160 include/openssl/obj_mac.h \
d040a1b9
DDO
1161 > crypto/objects/obj_dat.h && \
1162 sed -e '1,8d' crypto/objects/obj_compat.h \
1163 >> include/openssl/obj_mac.h )
1164$(SRCDIR)/crypto/objects/obj_dat.h: $(SRCDIR)/include/openssl/obj_mac.h
1165$(SRCDIR)/crypto/objects/obj_xref.h: $(SRCDIR)/crypto/objects/objxref.pl \
1166 $(SRCDIR)/crypto/objects/obj_mac.num \
1167 $(SRCDIR)/crypto/objects/obj_xref.txt
9a9f8ee7
RL
1168 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
1169 crypto/objects/obj_mac.num \
1170 crypto/objects/obj_xref.txt \
1171 > crypto/objects/obj_xref.h )
d040a1b9
DDO
1172.PHONY: generate_crypto_objects
1173generate_crypto_objects: $(SRCDIR)/crypto/objects/obj_dat.h \
1174 $(SRCDIR)/crypto/objects/obj_xref.h
6bb2106e 1175
d040a1b9 1176$(SRCDIR)/crypto/conf/conf_def.h: $(SRCDIR)/crypto/conf/keysets.pl
b7650c67
RL
1177 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
1178 > crypto/conf/conf_def.h )
d040a1b9
DDO
1179.PHONY: generate_crypto_conf
1180generate_crypto_conf: $(SRCDIR)/crypto/conf/conf_def.h
b7650c67 1181
d040a1b9 1182$(SRCDIR)/crypto/asn1/charmap.h: $(SRCDIR)/crypto/asn1/charmap.pl
b7650c67
RL
1183 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
1184 > crypto/asn1/charmap.h )
d040a1b9
DDO
1185.PHONY: generate_crypto_asn1
1186generate_crypto_asn1: $(SRCDIR)/crypto/asn1/charmap.h
b7650c67 1187
d040a1b9 1188$(SRCDIR)/fuzz/oids.txt: $(SRCDIR)/fuzz/mkfuzzoids.pl $(SRCDIR)/crypto/objects/obj_dat.h
8e32e1ab
RL
1189 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
1190 crypto/objects/obj_dat.h \
1191 > fuzz/oids.txt )
d040a1b9
DDO
1192.PHONY: generate_fuzz_oids
1193generate_fuzz_oids: $(SRCDIR)/fuzz/oids.txt
8e32e1ab 1194
7b9f8995
RL
1195generate_doc_buildinfo:
1196 ( $(PERL) -I$(BLDDIR) -Mconfigdata \
1197 $(SRCDIR)/util/dofile.pl -o Makefile \
5a6a6d59
RL
1198 $(SRCDIR)/doc/build.info.in \
1199 > $(SRCDIR)/doc/build.info.new; \
1200 if ( test -e $(SRCDIR)/doc/build.info \
1201 && cmp $(SRCDIR)/doc/build.info.new $(SRCDIR)/doc/build.info \
1202 > /dev/null ); \
1203 then \
1204 rm $(SRCDIR)/doc/build.info.new; \
1205 else \
1206 mv $(SRCDIR)/doc/build.info.new $(SRCDIR)/doc/build.info; \
1207 fi )
7b9f8995 1208
91a05d65 1209generate_fips_sources: providers/fips.module.sources.new
32eebfa2 1210providers/fips.module.sources.new: configdata.pm
27ca03ea
RL
1211 rm -rf sources-tmp
1212 mkdir sources-tmp
1213 ( \
1214 srcdir=`cd $(SRCDIR); pwd`; \
1215 cd sources-tmp \
969fdad7 1216 && $$srcdir/Configure --banner=Configured enable-fips -O0 \
27ca03ea 1217 && ./configdata.pm --query 'get_sources("providers/fips")' > sources1 \
f870a1f8 1218 && $(MAKE) -sj 4 build_generated providers/fips.so \
57bd5fc7 1219 && find . -name '*.d' | xargs cat > dep1 \
969fdad7
P
1220 && $(MAKE) distclean \
1221 && $$srcdir/Configure --banner=Configured enable-fips no-asm -O0 \
27ca03ea 1222 && ./configdata.pm --query 'get_sources("providers/fips")' > sources2 \
f870a1f8 1223 && $(MAKE) -sj 4 build_generated providers/fips.so \
57bd5fc7 1224 && find . -name '*.d' | xargs cat > dep2 \
969fdad7
P
1225 && cat sources1 sources2 \
1226 | grep -v ' : \\$$' | grep -v util/providers.num \
57bd5fc7 1227 | sed -e 's/^ *//' -e 's/ *\\$$//' \
969fdad7 1228 | sort | uniq > sources \
57bd5fc7
RL
1229 && cat dep1 dep2 \
1230 | $(PERL) -p -e 's/\\\n//' \
1231 | sed -e 's/^.*: *//' -e 's/ */ /g' \
1232 | fgrep -f sources \
1233 | tr ' ' '\n' \
1234 | sort | uniq > deps.raw \
1235 && cat deps.raw \
1236 | xargs ./configdata.pm --query 'get_sources(@ARGV)' \
1237 | $(PERL) -p -e 's/\\\n//' \
1238 | sed -e 's/\./\\\./g' -e 's/ : */:/' -e 's/^/s:/' -e 's/$$/:/' \
1239 > deps.sed \
1240 && cat deps.raw | sed -f deps.sed > deps \
27ca03ea
RL
1241 )
1242 ( \
57bd5fc7
RL
1243 cat sources-tmp/sources sources-tmp/deps \
1244 | $(PERL) -p -e 's:^ *\Q../\E:: ;' \
1245 -e 's:^\Q$(SRCDIR)/\E:: if "$(SRCDIR)" ne "." ;' \
1246 -e 'my $$x; do { $$x = $$_; s:(^|/)((?!\Q../\E)[^/]*/)\Q..\E($$|/):$$1: } while ($$x ne $$_) ;' ; \
27ca03ea
RL
1247 cd $(SRCDIR); \
1248 for x in crypto/bn/asm/*.pl crypto/bn/asm/*.S \
1249 crypto/aes/asm/*.pl crypto/aes/asm/*.S \
1250 crypto/ec/asm/*.pl \
27ca03ea 1251 crypto/modes/asm/*.pl \
969fdad7 1252 crypto/sha/asm/*.pl \
57bd5fc7 1253 crypto/x86_64cpuid.pl; do \
27ca03ea
RL
1254 echo "$$x"; \
1255 done \
57bd5fc7 1256 ) | sort | uniq > providers/fips.module.sources.new
27ca03ea 1257 rm -rf sources-tmp
27ca03ea 1258
52df25cf
RS
1259# Set to -force to force a rebuild
1260ERROR_REBUILD=
567a9e6f 1261errors:
aa6cc8d3
RL
1262 ( b=`pwd`; set -e; cd $(SRCDIR); \
1263 $(PERL) util/ck_errf.pl -strict -internal; \
cb7b7275 1264 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
aa6cc8d3 1265 ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
52df25cf 1266 for E in *.ec ; do \
aa6cc8d3
RL
1267 $(PERL) ../util/ck_errf.pl -strict \
1268 -conf $$E `basename $$E .ec`.c; \
cb7b7275 1269 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
52df25cf
RS
1270 -conf $$E `basename $$E .ec`.c ; \
1271 done )
567a9e6f 1272
30699aa1
RL
1273{- use File::Basename;
1274
96296339 1275 my @sslheaders_tmpl =
30699aa1
RL
1276 qw( include/openssl/ssl.h
1277 include/openssl/ssl2.h
1278 include/openssl/ssl3.h
1279 include/openssl/sslerr.h
1280 include/openssl/tls1.h
1281 include/openssl/dtls1.h
f5a46ed7 1282 include/openssl/srtp.h
770ea54b 1283 include/openssl/quic.h
f5a46ed7 1284 include/openssl/sslerr_legacy.h );
96296339 1285 my @cryptoheaders_tmpl =
30699aa1
RL
1286 qw( include/internal/dso.h
1287 include/internal/o_dir.h
30699aa1 1288 include/internal/err.h
c2041da8 1289 include/internal/evp.h
16feca71
RL
1290 include/internal/pem.h
1291 include/internal/asn1.h
30699aa1 1292 include/internal/sslconf.h );
96296339 1293 my @cryptoskipheaders = ( @sslheaders_tmpl,
30699aa1
RL
1294 qw( include/openssl/conf_api.h
1295 include/openssl/ebcdic.h
1296 include/openssl/opensslconf.h
1297 include/openssl/symhacks.h ) );
5d942028
RL
1298 our %cryptoheaders = ();
1299 our %sslheaders = ();
96296339
RL
1300 foreach my $d ( qw( include/openssl include/internal ) ) {
1301 my @header_patterns =
1302 map { catfile($config{sourcedir}, $d, $_) } ( '*.h', '*.h.in' );
1303 foreach my $f ( map { glob($_) } @header_patterns ) {
1304 my $base = basename($f);
1305 my $base_in = basename($f, '.in');
1306 my $dir = catfile($config{sourcedir}, $d);
1307 if ($base ne $base_in) {
1308 # We have a .h.in file, which means the header file is in the
1309 # build tree.
1310 $base = $base_in;
1311 $dir = catfile($config{builddir}, $d);
1312 }
1313 my $new_f = catfile($dir, $base);
1314 my $fn = "$d/$base";
1315 # The logic to add files to @cryptoheaders is a bit complex. The
1316 # file to be added must be either in the public header directory
1317 # or one of the pre-declared internal headers, and must under no
1318 # circumstances be one of those that must be skipped.
5d942028 1319 $cryptoheaders{$new_f} = 1
96296339
RL
1320 if (($d eq 'include/openssl'
1321 || ( grep { $_ eq $fn } @cryptoheaders_tmpl ))
1322 && !( grep { $_ eq $fn } @cryptoskipheaders ));
1323 # The logic to add files to @sslheaders is much simpler...
5d942028 1324 $sslheaders{$new_f} = 1 if grep { $_ eq $fn } @sslheaders_tmpl;
96296339 1325 }
30699aa1
RL
1326 }
1327 "";
1328-}
c00d9311 1329CRYPTOHEADERS={- join(" \\\n" . ' ' x 14,
5d942028 1330 fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -}
c00d9311 1331SSLHEADERS={- join(" \\\n" . ' ' x 11,
5d942028 1332 fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -}
6ee47412
MC
1333
1334renumber: build_generated
435981cb 1335 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
6ee47412
MC
1336 --ordinals $(SRCDIR)/util/libcrypto.num \
1337 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
1338 --renumber \
1339 $(CRYPTOHEADERS)
435981cb 1340 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
6ee47412
MC
1341 --ordinals $(SRCDIR)/util/libssl.num \
1342 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
1343 --renumber \
1344 $(SSLHEADERS)
1345
0e55c3ab 1346$(SRCDIR)/util/libcrypto.num: $(CRYPTOHEADERS) $(SRCDIR)/include/openssl/symhacks.h
435981cb 1347 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
96296339
RL
1348 --ordinals $(SRCDIR)/util/libcrypto.num \
1349 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
1350 $(CRYPTOHEADERS)
0e55c3ab 1351$(SRCDIR)/util/libssl.num: $(SSLHEADERS) $(SRCDIR)/include/openssl/symhacks.h
435981cb 1352 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
96296339
RL
1353 --ordinals $(SRCDIR)/util/libssl.num \
1354 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
1355 $(SSLHEADERS)
0e55c3ab
DDO
1356.PHONY: ordinals
1357ordinals: build_generated $(SRCDIR)/util/libcrypto.num $(SRCDIR)/util/libssl.num
567a9e6f
RL
1358
1359test_ordinals:
c612c7a4 1360 $(MAKE) run_tests TESTS=test_ordinals
567a9e6f
RL
1361
1362tags TAGS: FORCE
1363 rm -f TAGS tags
1364 -ctags -R .
1365 -etags `find . -name '*.[ch]' -o -name '*.pm'`
1366
a3c86ce9 1367providers/fips.checksum.new: providers/fips.module.sources.new
f3b1e348
TM
1368 @which unifdef > /dev/null || \
1369 ( echo >&2 "ERROR: unifdef not in your \$$PATH, FIPS checksums not calculated"; \
1370 false )
91a05d65 1371 ( sources=`pwd`/providers/fips.module.sources.new; \
f3b1e348
TM
1372 cd $(SRCDIR) \
1373 && cat $$sources \
1374 | xargs ./util/fips-checksums.sh ) \
91a05d65
TM
1375 > providers/fips-sources.checksums.new \
1376 && sha256sum providers/fips-sources.checksums.new \
8f3683cd
TM
1377 | sed -e 's|\.new||' > providers/fips.checksum.new
1378
1379fips-checksums: providers/fips.checksum.new
f3b1e348 1380
91a05d65
TM
1381$(SRCDIR)/providers/fips.checksum: providers/fips.checksum.new
1382 cp -p providers/fips.module.sources.new $(SRCDIR)/providers/fips.module.sources
1383 cp -p providers/fips-sources.checksums.new $(SRCDIR)/providers/fips-sources.checksums
1384 cp -p providers/fips.checksum.new $(SRCDIR)/providers/fips.checksum
f3b1e348
TM
1385
1386update-fips-checksums: $(SRCDIR)/providers/fips.checksum
be223152 1387
8e782e8b 1388diff-fips-checksums: fips-checksums
91a05d65
TM
1389 diff -u $(SRCDIR)/providers/fips.module.sources providers/fips.module.sources.new
1390 diff -u $(SRCDIR)/providers/fips-sources.checksums providers/fips-sources.checksums.new
1391 diff -u $(SRCDIR)/providers/fips.checksum providers/fips.checksum.new
8e782e8b 1392
567a9e6f
RL
1393# Release targets (note: only available on Unix) #####################
1394
1395tar:
b741f153 1396 (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
567a9e6f
RL
1397
1398# Helper targets #####################################################
1399
0eed845c 1400link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/apps/openssl.cnf
567a9e6f 1401
468d1517 1402$(BLDDIR)/util/opensslwrap.sh: Makefile
567a9e6f
RL
1403 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
1404 mkdir -p "$(BLDDIR)/util"; \
c3845ceb 1405 ln -sf "../$(SRCDIR)/util/`basename "$@"`" "$(BLDDIR)/util"; \
567a9e6f 1406 fi
342a1a23 1407
468d1517 1408$(BLDDIR)/apps/openssl.cnf: Makefile
3ab736ac
DMSP
1409 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
1410 mkdir -p "$(BLDDIR)/apps"; \
1411 ln -sf "../$(SRCDIR)/apps/`basename "$@"`" "$(BLDDIR)/apps"; \
1412 fi
1413
c058fcd7 1414FORCE:
567a9e6f
RL
1415
1416# Building targets ###################################################
1417
468d1517
RL
1418libcrypto.pc libssl.pc openssl.pc: Makefile $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // platform->sharedlib_import($_) // platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
1419
567a9e6f
RL
1420libcrypto.pc:
1421 @ ( echo 'prefix=$(INSTALLTOP)'; \
1422 echo 'exec_prefix=$${prefix}'; \
e454f3ad
RL
1423 if [ -n "$(LIBDIR)" ]; then \
1424 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
1425 else \
1426 echo 'libdir=$(libdir)'; \
1427 fi; \
567a9e6f 1428 echo 'includedir=$${prefix}/include'; \
d4453024 1429 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
7fde39de 1430 echo 'modulesdir=$${libdir}/ossl-modules'; \
567a9e6f
RL
1431 echo ''; \
1432 echo 'Name: OpenSSL-libcrypto'; \
1433 echo 'Description: OpenSSL cryptography library'; \
1434 echo 'Version: '$(VERSION); \
1435 echo 'Libs: -L$${libdir} -lcrypto'; \
abe256e7 1436 echo 'Libs.private: $(LIB_EX_LIBS)'; \
567a9e6f
RL
1437 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
1438
1439libssl.pc:
1440 @ ( echo 'prefix=$(INSTALLTOP)'; \
1441 echo 'exec_prefix=$${prefix}'; \
e454f3ad
RL
1442 if [ -n "$(LIBDIR)" ]; then \
1443 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
1444 else \
1445 echo 'libdir=$(libdir)'; \
1446 fi; \
567a9e6f
RL
1447 echo 'includedir=$${prefix}/include'; \
1448 echo ''; \
1449 echo 'Name: OpenSSL-libssl'; \
1450 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
1451 echo 'Version: '$(VERSION); \
1452 echo 'Requires.private: libcrypto'; \
1453 echo 'Libs: -L$${libdir} -lssl'; \
567a9e6f
RL
1454 echo 'Cflags: -I$${includedir}' ) > libssl.pc
1455
1456openssl.pc:
1457 @ ( echo 'prefix=$(INSTALLTOP)'; \
1458 echo 'exec_prefix=$${prefix}'; \
e454f3ad
RL
1459 if [ -n "$(LIBDIR)" ]; then \
1460 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
1461 else \
1462 echo 'libdir=$(libdir)'; \
1463 fi; \
567a9e6f
RL
1464 echo 'includedir=$${prefix}/include'; \
1465 echo ''; \
1466 echo 'Name: OpenSSL'; \
1467 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
1468 echo 'Version: '$(VERSION); \
1469 echo 'Requires: libssl libcrypto' ) > openssl.pc
1470
468d1517
RL
1471Makefile: configdata.pm \
1472 {- join(" \\\n" . ' ' x 10,
1473 fill_lines(" ", $COLUMNS - 10,
1474 @{$config{build_file_templates}})) -}
1475 @echo "Detected changed: $?"
1476 $(PERL) configdata.pm
1477 @echo "**************************************************"
1478 @echo "*** ***"
1479 @echo "*** Please run the same make command again ***"
1480 @echo "*** ***"
1481 @echo "**************************************************"
1482 @false
1483
c00d9311
RL
1484configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config \
1485 {- join(" \\\n" . ' ' x 15,
1486 fill_lines(" ", $COLUMNS - 15,
c00d9311
RL
1487 @{$config{build_infos}},
1488 @{$config{conf_files}})) -}
27f42b46 1489 @echo "Detected changed: $?"
a1b6933e 1490 $(PERL) configdata.pm -r
567a9e6f
RL
1491 @echo "**************************************************"
1492 @echo "*** ***"
1493 @echo "*** Please run the same make command again ***"
1494 @echo "*** ***"
1495 @echo "**************************************************"
1496 @false
1497
bf01fbbf 1498reconfigure reconf:
a1b6933e 1499 $(PERL) configdata.pm -r
bf01fbbf 1500
567a9e6f
RL
1501{-
1502 use File::Basename;
1503 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
cedbb146 1504
6dd07a93
RL
1505 # Helper function to convert dependencies in platform agnostic form to
1506 # dependencies in platform form.
1507 sub compute_platform_depends {
1508 map { my $x = $_;
1509
1510 grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x)
1511 or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x)
1512 or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x)
1513 or platform->convertext($x); } @_;
1514 }
1515
cedbb146
RL
1516 # Helper function to figure out dependencies on libraries
1517 # It takes a list of library names and outputs a list of dependencies
1518 sub compute_lib_depends {
cedbb146
RL
1519 # Depending on shared libraries:
1520 # On Windows POSIX layers, we depend on {libname}.dll.a
1521 # On Unix platforms, we depend on {shlibname}.so
ef161e7b
RL
1522 return map { platform->sharedlib_simple($_)
1523 // platform->sharedlib_import($_)
f159b83a 1524 // platform->sharedlib($_)
ef161e7b
RL
1525 // platform->staticlib($_)
1526 } @_;
cedbb146
RL
1527 }
1528
3f399e37
RL
1529 sub generatetarget {
1530 my %args = @_;
6dd07a93 1531 my $deps = join(" ", compute_platform_depends(@{$args{deps}}));
3f399e37
RL
1532 return <<"EOF";
1533$args{target}: $deps
1534EOF
1535 }
1536
66ddf178
RL
1537 sub generatesrc {
1538 my %args = @_;
79f47ef5
RL
1539 my $gen0 = $args{generator}->[0];
1540 my $gen_args = join('', map { " $_" }
1541 @{$args{generator}}[1..$#{$args{generator}}]);
1542 my $gen_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
d4605727 1543 my $incs = join("", map { " -I".$_ } @{$args{incs}});
25628ab2 1544 my $defs = join("", map { " -D".$_ } @{$args{defs}});
6dd07a93
RL
1545 my $deps = join(" ", compute_platform_depends(@{$args{generator_deps}},
1546 @{$args{deps}}));
66ddf178 1547
b0940b33 1548 if ($args{src} =~ /\.html$/) {
79f47ef5
RL
1549 #
1550 # HTML generator
1551 #
1552 my $title = basename($args{src}, ".html");
1553 my $pod = $gen0;
1554 return <<"EOF";
98706c5a 1555$args{src}: $pod
1ec45fab 1556 \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
b0940b33
RL
1557EOF
1558 } elsif ($args{src} =~ /\.(\d)$/) {
79f47ef5
RL
1559 #
1560 # Man-page generator
1561 #
1562 my $section = $1;
1563 my $name = uc basename($args{src}, ".$section");
1564 my $pod = $gen0;
1565 return <<"EOF";
98706c5a 1566$args{src}: $pod
ae6f65ae 1567 pod2man --name=$name --section=$section\$(MANSUFFIX) --center=OpenSSL \\
1ec45fab 1568 --release=\$(VERSION) $pod >\$\@
b0940b33
RL
1569EOF
1570 } elsif (platform->isdef($args{src})) {
79f47ef5
RL
1571 #
1572 # Linker script-ish generator
1573 #
9dd4ed28 1574 my $target = platform->def($args{src});
ef2dfc99 1575 (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
435981cb 1576 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
9dd4ed28 1577 my $ord_name = $args{generator}->[1] || $args{product};
ef2dfc99 1578 return <<"EOF";
79f47ef5 1579$target: $gen0 $deps \$(SRCDIR)/util/mkdef.pl
e5f831a0 1580 \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --type $args{intent} --ordinals $gen0 --name $ord_name --OS $mkdef_os > $target
7cae3864 1581EOF
79f47ef5
RL
1582 } elsif (platform->isasm($args{src})) {
1583 #
1584 # Assembler generator
1585 #
593d5c2f
RL
1586 my $cppflags = {
1587 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1588 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1589 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1590 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1591 } -> {$args{intent}};
1592
79f47ef5
RL
1593 my $generator;
1594 if ($gen0 =~ /\.pl$/) {
1595 $generator = 'CC="$(CC)" $(PERL)'.$gen_incs.' '.$gen0.$gen_args
cf076a3f 1596 .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSOR)';
79f47ef5
RL
1597 } elsif ($gen0 =~ /\.m4$/) {
1598 $generator = 'm4 -B 8192'.$gen_incs.' '.$gen0.$gen_args.' >'
1599 } elsif ($gen0 =~ /\.S$/) {
8458f1bf
RL
1600 $generator = undef;
1601 } else {
79f47ef5 1602 die "Generator type for $args{src} unknown: $gen0\n";
8458f1bf
RL
1603 }
1604
1605 if (defined($generator)) {
66ddf178 1606 return <<"EOF";
79f47ef5 1607$args{src}: $gen0 $deps
8458f1bf 1608 $generator \$@
66ddf178 1609EOF
66ddf178 1610 }
8458f1bf 1611 return <<"EOF";
79f47ef5
RL
1612$args{src}: $gen0 $deps
1613 \$(CC) $incs $cppflags $defs -E $gen0 | \\
39199fb3 1614 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
79f47ef5
RL
1615EOF
1616 } elsif ($gen0 =~ m|^.*\.in$|) {
1617 #
1618 # "dofile" generator (file.in -> file)
1619 #
1620 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1621 "util", "dofile.pl")),
1622 rel2abs($config{builddir}));
6dd07a93
RL
1623 my @perlmodules = ( 'configdata.pm',
1624 grep { $_ =~ m|\.pm$| } @{$args{deps}} );
1625 my %perlmoduleincs = map { '"-I'.dirname($_).'"' => 1 } @perlmodules;
1626 $deps = join(' ', $deps, compute_platform_depends(@perlmodules));
1627 @perlmodules = map { "-M".basename($_, '.pm') } @perlmodules;
1628 my $perlmodules = join(' ', '', sort keys %perlmoduleincs, @perlmodules);
79f47ef5
RL
1629 return <<"EOF";
1630$args{src}: $gen0 $deps
6dd07a93 1631 \$(PERL)$perlmodules "$dofile" "-o$target{build_file}" $gen0$gen_args > \$@
79f47ef5
RL
1632EOF
1633 } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
1634 #
1635 # Generic generator using OpenSSL programs
1636 #
1637
6dd07a93 1638 # Redo $gen0, to ensure that we have the proper extension where
79f47ef5
RL
1639 # necessary.
1640 $gen0 = platform->bin($gen0);
92a979b4 1641 # Use $(PERL) to execute wrap.pl directly to avoid calling env
79f47ef5
RL
1642 return <<"EOF";
1643$args{src}: $gen0 $deps \$(BLDDIR)/util/wrap.pl
92a979b4 1644 \$(PERL) \$(BLDDIR)/util/wrap.pl $gen0$gen_args > \$@
79f47ef5
RL
1645EOF
1646 } else {
1647 #
1648 # Generic generator using Perl
1649 #
1650 return <<"EOF";
1651$args{src}: $gen0 $deps
1652 \$(PERL)$gen_incs $gen0$gen_args > \$@
8458f1bf 1653EOF
66ddf178
RL
1654 }
1655 }
1656
bb26842d
RL
1657 # Should one wonder about the end of the Perl snippet, it's because this
1658 # second regexp eats up line endings as well, if the removed path is the
1659 # last in the line. We may therefore need to put back a line ending.
88297284 1660 sub src2obj {
567a9e6f 1661 my %args = @_;
e805c2d6 1662 my $obj = platform->convertext($args{obj});
9dd4ed28 1663 my $dep = platform->dep($args{obj});
a23f0316 1664 my @srcs = @{$args{srcs}};
8458f1bf
RL
1665 my $srcs = join(" ", @srcs);
1666 my $deps = join(" ", @srcs, @{$args{deps}});
45502bfe 1667 my $incs = join("", map { " -I".$_ } @{$args{incs}});
25628ab2 1668 my $defs = join("", map { " -D".$_ } @{$args{defs}});
722c9762
RL
1669 my $cmd;
1670 my $cmdflags;
1671 my $cmdcompile;
81183680
RL
1672 if (grep /\.rc$/, @srcs) {
1673 $cmd = '$(RC)';
1674 $cmdflags = '$(RCFLAGS)';
8c3bc594 1675 $cmdcompile = '';
81183680
RL
1676 } elsif (grep /\.(cc|cpp)$/, @srcs) {
1677 $cmd = '$(CXX)';
722c9762
RL
1678 $cmdcompile = ' -c';
1679 $cmdflags = {
9dfc8680 1680 shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
722c9762
RL
1681 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1682 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
1683 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
1684 } -> {$args{intent}};
7763472f 1685 } else {
722c9762
RL
1686 $cmd = '$(CC)';
1687 $cmdcompile = ' -c';
1688 $cmdflags = {
9dfc8680 1689 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
722c9762
RL
1690 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1691 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1692 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1693 } -> {$args{intent}};
7763472f 1694 }
a23f0316
AP
1695 my $recipe;
1696 # extension-specific rules
1697 if (grep /\.s$/, @srcs) {
1698 $recipe .= <<"EOF";
9dd4ed28 1699$obj: $deps
a23f0316 1700 $cmd $cmdflags -c -o \$\@ $srcs
7e5b8b93 1701EOF
a23f0316 1702 } elsif (grep /\.S$/, @srcs) {
f691578b 1703 # Originally there was multi-step rule with $(CC) -E file.S
18d15882
AP
1704 # followed by $(CC) -c file.s. It compensated for one of
1705 # legacy platform compiler's inability to handle .S files.
1706 # The platform is long discontinued by vendor so there is
1707 # hardly a point to drag it along...
29eed3dd 1708 $recipe .= <<"EOF";
9dd4ed28 1709$obj: $deps
25628ab2 1710 $cmd $incs $defs $cmdflags -c -o \$\@ $srcs
a23f0316 1711EOF
2e535eb5 1712 } elsif ($makedep_scheme eq 'gcc' && !grep /\.rc$/, @srcs) {
a23f0316 1713 $recipe .= <<"EOF";
9dd4ed28
RL
1714$obj: $deps
1715 $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -MT \$\@ -c -o \$\@ $srcs
1716 \@touch $dep.tmp
1717 \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\
1718 rm -f $dep.tmp; \\
29b28eee 1719 else \\
9dd4ed28 1720 mv $dep.tmp $dep; \\
987dbc7f 1721 fi
29eed3dd 1722EOF
7e5b8b93 1723 } else {
29eed3dd 1724 $recipe .= <<"EOF";
9dd4ed28 1725$obj: $deps
25628ab2 1726 $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
567a9e6f 1727EOF
2e535eb5 1728 if ($makedep_scheme eq 'makedepend') {
7e5b8b93 1729 $recipe .= <<"EOF";
c39785d4 1730 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
9dd4ed28 1731 > $dep
567a9e6f 1732EOF
7e5b8b93 1733 }
29eed3dd
RL
1734 }
1735 return $recipe;
567a9e6f 1736 }
d8cac50b 1737 # We *know* this routine is only called when we've configure 'shared'.
f6196227 1738 sub obj2shlib {
567a9e6f 1739 my %args = @_;
47eeaf45 1740 my @linkdirs = ();
e805c2d6
RL
1741 my @linklibs = ();
1742 foreach (@{$args{deps}}) {
1743 if (platform->isstaticlib($_)) {
1744 push @linklibs, platform->convertext($_);
1745 } else {
1746 my $d = "-L" . dirname($_);
1747 my $l = basename($_);
1748 $l =~ s/^lib//;
1749 $l = "-l" . $l;
1750 push @linklibs, $l;
1751 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1752 }
47eeaf45 1753 }
e805c2d6
RL
1754 my $linkflags = join("", map { $_." " } @linkdirs);
1755 my $linklibs = join("", map { $_." " } @linklibs);
1756 my @objs = map { platform->convertext($_) }
9dd4ed28 1757 grep { !platform->isdef($_) }
ef2dfc99 1758 @{$args{objs}};
9dd4ed28
RL
1759 my @defs = map { platform->def($_) }
1760 grep { platform->isdef($_) }
81183680 1761 @{$args{objs}};
81183680
RL
1762 my @deps = compute_lib_depends(@{$args{deps}});
1763 die "More than one exported symbol map" if scalar @defs > 1;
c00d9311 1764
9dd4ed28 1765 my $full = platform->sharedlib($args{lib});
ef161e7b
RL
1766 # $import is for Windows and subsystems thereof, where static import
1767 # libraries for DLLs are a thing. On platforms that have this mechanism,
1768 # $import has the name of this import library. On platforms that don't
1769 # have this mechanism, $import will be |undef|.
1770 my $import = platform->sharedlib_import($args{lib});
1771 # $simple is for platforms where full shared library names include the
1772 # shared library version, and there's a simpler name that doesn't include
1773 # that version. On such platforms, $simple has the simpler name. On
1774 # other platforms, it will be |undef|.
1775 my $simple = platform->sharedlib_simple($args{lib});
1776
e07a7892 1777 my $argfile = defined $target{shared_argfileflag} ? $full.".args" : undef;
81183680 1778 my $shared_soname = "";
d8cac50b 1779 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
81183680
RL
1780 if defined $target{shared_sonameflag};
1781 my $shared_imp = "";
ef161e7b
RL
1782 $shared_imp .= ' '.$target{shared_impflag}.basename($import)
1783 if defined $target{shared_impflag} && defined $import;
81183680 1784 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
c00d9311 1785
e07a7892
RL
1786 # There is at least one platform where the compiler-as-linker needs to
1787 # have one object file directly on the command line. That won't hurt
1788 # any other platform, so we do that for everyone when there's an argfile
1789 # to be had. This depends heavily on splice, which removes elements from
1790 # the given array, and returns them so they can be captured.
1791 my @argfileobjs = $argfile
1792 ? splice(@objs, 1)
1793 : ();
1794 my $argfilecmds = $argfile
1795 ? join("\n\t", map { "echo $_ >> $argfile" } @argfileobjs)
1796 : undef;
1797 my $argfiledeps = $argfile
1798 ? join(" \\\n" . ' ' x (length($argfile) + 2),
1799 fill_lines(' ', $COLUMNS - length($full) - 2, @argfileobjs))
1800 : undef;
1801 my @fulldeps = (@objs, ($argfile ? $argfile : ()), @defs, @deps);
1802 my @fullobjs = (
1803 @objs,
1804 ($argfile ? $target{shared_argfileflag}.$argfile : ())
1805 );
1806 my $fulldeps =
1807 join(" \\\n" . ' ' x (length($full) + 2),
1808 fill_lines(' ', $COLUMNS - length($full) - 2, @fulldeps));
1809 my $fullobjs =
1810 join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @fullobjs));
c00d9311 1811
294e3802
RL
1812 my $recipe = '';
1813
3bf7c3a1 1814 if (defined $simple && $simple ne $full) {
294e3802
RL
1815 if (sharedaix()) {
1816 $recipe .= <<"EOF";
9dd4ed28 1817$simple: $full
9dd4ed28
RL
1818 rm -f $simple && \\
1819 \$(AR) r $simple $full
cff89b17 1820EOF
294e3802
RL
1821 } else {
1822 $recipe .= <<"EOF";
1823$simple: $full
d8cac50b 1824 rm -f $simple && \\
9dd4ed28 1825 ln -s $full $simple
81183680 1826EOF
294e3802 1827 }
9dd4ed28 1828 }
ef161e7b
RL
1829 if (defined $import) {
1830 $recipe .= <<"EOF";
1831$import: $full
1832EOF
1833 }
9dd4ed28 1834 $recipe .= <<"EOF";
e07a7892 1835$full: $fulldeps
9dd4ed28 1836 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
c00d9311 1837 -o $full$shared_def \\
e07a7892 1838 $fullobjs \\
c00d9311 1839 $linklibs \$(LIB_EX_LIBS)
9dd4ed28
RL
1840EOF
1841 if (windowsdll()) {
81183680 1842 $recipe .= <<"EOF";
9dd4ed28 1843 rm -f apps/$full
9dd4ed28
RL
1844 rm -f fuzz/$full
1845 cp -p $full apps/
9dd4ed28 1846 cp -p $full fuzz/
567a9e6f 1847EOF
f16f363a
MC
1848 if (!$disabled{tests}) {
1849 $recipe .= <<"EOF";
1850 rm -f test/$full
1851 cp -p $full test/
1852EOF
1853 }
81183680 1854 }
e07a7892
RL
1855 $recipe .= <<"EOF" if defined $argfile;
1856$argfile: $argfiledeps
1857 \$(RM) $argfile
1858 $argfilecmds
1859EOF
9dd4ed28 1860 return $recipe;
567a9e6f 1861 }
5386287c 1862 sub obj2dso {
567a9e6f 1863 my %args = @_;
285daccd 1864 my $dso = platform->dso($args{module});
47eeaf45 1865 my @linkdirs = ();
e805c2d6
RL
1866 my @linklibs = ();
1867 foreach (@{$args{deps}}) {
1868 next unless defined $_;
1869 if (platform->isstaticlib($_)) {
1870 push @linklibs, platform->convertext($_);
1871 } else {
1872 my $d = "-L" . dirname($_);
1873 my $l = basename($_);
1874 $l =~ s/^lib//;
1875 $l = "-l" . $l;
1876 push @linklibs, $l;
1877 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1878 }
47eeaf45 1879 }
e805c2d6
RL
1880 my $linkflags = join("", map { $_." " } @linkdirs);
1881 my $linklibs = join("", map { $_." " } @linklibs);
1882 my @objs = map { platform->convertext($_) }
9dd4ed28 1883 grep { !platform->isdef($_) }
29f3cfdd 1884 @{$args{objs}};
9dd4ed28
RL
1885 my @defs = map { platform->def($_) }
1886 grep { platform->isdef($_) }
66a24ab8 1887 @{$args{objs}};
81183680 1888 my @deps = compute_lib_depends(@{$args{deps}});
66a24ab8 1889 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
21d1994f 1890 # Next line needs to become "less magic" (see PR #11950)
69e0f8cc 1891 $shared_def .= ' '.$target{shared_fipsflag} if (defined $target{shared_fipsflag} && $shared_def =~ m/providers\/fips/);
c00d9311
RL
1892 my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
1893 my $deps = join(" \\\n" . ' ' x (length($dso) + 2),
1894 fill_lines(' ', $COLUMNS - length($dso) - 2,
1895 @objs, @defs, @deps));
1896
567a9e6f 1897 return <<"EOF";
9dd4ed28 1898$dso: $deps
722c9762 1899 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
c00d9311
RL
1900 -o $dso$shared_def \\
1901 $objs \\
1902 $linklibs\$(DSO_EX_LIBS)
567a9e6f
RL
1903EOF
1904 }
1905 sub obj2lib {
1906 my %args = @_;
9dd4ed28
RL
1907 my $lib = platform->staticlib($args{lib});
1908 my @objs = map { platform->obj($_) } @{$args{objs}};
385deae7 1909 my $deps = join(" \\\n" . ' ' x (length($lib) + 2),
c00d9311 1910 fill_lines(' ', $COLUMNS - length($lib) - 2, @objs));
0e60ce63 1911 my $max_per_call = 500;
385deae7
RL
1912 my @objs_grouped;
1913 push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs;
1914 my $fill_lib =
1915 join("\n\t", (map { "\$(AR) \$(ARFLAGS) $lib $_" } @objs_grouped));
567a9e6f 1916 return <<"EOF";
385deae7 1917$lib: $deps
0e60ce63 1918 \$(RM) $lib
385deae7 1919 $fill_lib
567a9e6f
RL
1920 \$(RANLIB) \$\@ || echo Never mind.
1921EOF
1922 }
1923 sub obj2bin {
1924 my %args = @_;
9dd4ed28 1925 my $bin = platform->bin($args{bin});
c00d9311
RL
1926 my @objs = map { platform->obj($_) } @{$args{objs}};
1927 my @deps = compute_lib_depends(@{$args{deps}});
1928 my $objs = join(" \\\n" . ' ' x (length($bin) + 2),
1929 fill_lines(' ', $COLUMNS - length($bin) - 2, @objs));
47eeaf45 1930 my @linkdirs = ();
e805c2d6
RL
1931 my @linklibs = ();
1932 foreach (@{$args{deps}}) {
1933 next unless defined $_;
1934 if (platform->isstaticlib($_)) {
1935 push @linklibs, platform->convertext($_);
1936 } else {
1937 my $d = "-L" . dirname($_);
1938 my $l = basename($_);
1939 $l =~ s/^lib//;
1940 $l = "-l" . $l;
1941 push @linklibs, $l;
1942 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1943 }
47eeaf45 1944 }
e805c2d6
RL
1945 my $linkflags = join("", map { $_." " } @linkdirs);
1946 my $linklibs = join("", map { $_." " } @linklibs);
81183680 1947 my $cmd = '$(CC)';
722c9762 1948 my $cmdflags = '$(BIN_CFLAGS)';
81183680
RL
1949 if (grep /_cc\.o$/, @{$args{objs}}) {
1950 $cmd = '$(CXX)';
722c9762 1951 $cmdflags = '$(BIN_CXXFLAGS)';
7763472f 1952 }
c00d9311
RL
1953
1954 my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
1955 my $deps = join(" \\\n" . ' ' x (length($bin) + 2),
1956 fill_lines(' ', $COLUMNS - length($bin) - 2,
1957 @objs, @deps));
1958
567a9e6f 1959 return <<"EOF";
c00d9311 1960$bin: $deps
9dd4ed28 1961 rm -f $bin
722c9762 1962 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
c00d9311
RL
1963 -o $bin \\
1964 $objs \\
e805c2d6 1965 $linklibs\$(BIN_EX_LIBS)
567a9e6f
RL
1966EOF
1967 }
1968 sub in2script {
1969 my %args = @_;
1970 my $script = $args{script};
1971 my $sources = join(" ", @{$args{sources}});
1972 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1973 "util", "dofile.pl")),
1974 rel2abs($config{builddir}));
1975 return <<"EOF";
079f8d36 1976$script: $sources configdata.pm
0eed845c 1977 \$(RM) "$script"
4b799cea 1978 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
ba327ade 1979 "-o$target{build_file}" $sources > "$script"
567a9e6f 1980 chmod a+x $script
0ad1d94d
RL
1981EOF
1982 }
1983 sub generatedir {
1984 my %args = @_;
1985 my $dir = $args{dir};
6dd07a93 1986 my @deps = compute_platform_depends(@{$args{deps}});
c00d9311 1987 my @comments = ();
0ad1d94d 1988
b6e66075
RL
1989 # We already have a 'test' target, and the top directory is just plain
1990 # silly
1991 return if $dir eq "test" || $dir eq ".";
1992
0ad1d94d
RL
1993 foreach my $type (("dso", "lib", "bin", "script")) {
1994 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
850000aa
RL
1995 # For lib object files, we could update the library. However, it
1996 # was decided that it's enough to build the directory local object
1997 # files, so we don't need to add any actions, and the dependencies
1998 # are already taken care of.
1999 if ($type ne "lib") {
0ad1d94d
RL
2000 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
2001 if (dirname($prod) eq $dir) {
6dd07a93 2002 push @deps, compute_platform_depends($prod);
0ad1d94d 2003 } else {
c00d9311 2004 push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
0ad1d94d
RL
2005 }
2006 }
2007 }
2008 }
2009
c00d9311
RL
2010 my $target = "$dir $dir/";
2011 my $deps = join(" \\\n\t",
2012 fill_lines(' ', $COLUMNS - 8, @deps));
2013 my $comments = join("\n", "", @comments);
0ad1d94d 2014 return <<"EOF";
c00d9311
RL
2015$target: \\
2016 $deps$comments
567a9e6f
RL
2017EOF
2018 }
2019 "" # Important! This becomes part of the template result.
2020-}