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