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