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