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