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