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