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