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