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