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