]> git.ipfire.org Git - thirdparty/openssl.git/blame - Configurations/unix-Makefile.tmpl
d2i_X509.pod: clarify usage of the 'pp' function parameter
[thirdparty/openssl.git] / Configurations / unix-Makefile.tmpl
CommitLineData
567a9e6f
RL
1##
2## Makefile for OpenSSL
3##
4## {- join("\n## ", @autowarntext) -}
5{-
834aae2a
BL
6 our $objext = $target{obj_extension} || ".o";
7 our $depext = $target{dep_extension} || ".d";
8 our $exeext = $target{exe_extension} || "";
9 our $libext = $target{lib_extension} || ".a";
10 our $shlibext = $target{shared_extension} || ".so";
822b5e26 11 our $shlibvariant = $target{shlib_variant} || "";
834aae2a
BL
12 our $shlibextsimple = $target{shared_extension_simple} || ".so";
13 our $shlibextimport = $target{shared_import_extension} || "";
14 our $dsoext = $target{dso_extension} || ".so";
15
567a9e6f 16 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
f5c174ff 17
d4453024
RL
18 our $sover_dirname = $config{shlib_version_number};
19 $sover_dirname =~ s|\.|_|g
20 if $config{target} =~ /^mingw/;
b2de11c5 21
f5c174ff
RL
22 # shlib and shlib_simple both take a static library name and figure
23 # out what the shlib name should be.
24 #
25 # When OpenSSL is configured "no-shared", these functions will just
26 # return empty lists, making them suitable to join().
27 #
28 # With Windows DLL producers, shlib($libname) will return the shared
29 # library name (which usually is different from the static library
30 # name) with the default shared extension appended to it, while
31 # shlib_simple($libname) will return the static library name with
32 # the shared extension followed by ".a" appended to it. The former
33 # result is used as the runtime shared library while the latter is
34 # used as the DLL import library.
35 #
36 # On all Unix systems, shlib($libname) will return the library name
37 # with the default shared extension, while shlib_simple($libname)
38 # will return the name from shlib($libname) with any SO version number
39 # removed. On some systems, they may therefore return the exact same
40 # string.
41 sub shlib {
f5c174ff 42 my $lib = shift;
33105818 43 return () if $disabled{shared} || $lib =~ /\.a$/;
822b5e26 44 return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)';
f5c174ff
RL
45 }
46 sub shlib_simple {
f5c174ff 47 my $lib = shift;
33105818
RL
48 return () if $disabled{shared} || $lib =~ /\.a$/;
49
f5c174ff 50 if (windowsdll()) {
d4453024 51 return $lib . '$(SHLIB_EXT_IMPORT)';
f5c174ff 52 }
d4453024 53 return $lib . '$(SHLIB_EXT_SIMPLE)';
f5c174ff
RL
54 }
55
33105818
RL
56 # Easy fixing of static library names
57 sub lib {
58 (my $lib = shift) =~ s/\.a$//;
59 return $lib . $libext;
60 }
61
f5c174ff
RL
62 # dso is a complement to shlib / shlib_simple that returns the
63 # given libname with the simple shared extension (possible SO version
64 # removed). This differs from shlib_simple() by being unconditional.
65 sub dso {
f5c174ff
RL
66 my $engine = shift;
67
834aae2a 68 return $engine . $dsoext;
f5c174ff 69 }
27c40a93
BL
70 # This makes sure things get built in the order they need
71 # to. You're welcome.
72 sub dependmagic {
73 my $target = shift;
74
75 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
76 }
834aae2a 77 '';
567a9e6f
RL
78-}
79PLATFORM={- $config{target} -}
80OPTIONS={- $config{options} -}
81CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
82SRCDIR={- $config{sourcedir} -}
83BLDDIR={- $config{builddir} -}
84
85VERSION={- $config{version} -}
86MAJOR={- $config{major} -}
87MINOR={- $config{minor} -}
88SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
89SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
90SHLIB_MAJOR={- $config{shlib_major} -}
91SHLIB_MINOR={- $config{shlib_minor} -}
92SHLIB_TARGET={- $target{shared_target} -}
d4453024
RL
93SHLIB_EXT={- $shlibext -}
94SHLIB_EXT_SIMPLE={- $shlibextsimple -}
95SHLIB_EXT_IMPORT={- $shlibextimport -}
567a9e6f 96
33105818 97LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
f5c174ff 98SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
0f01b7bc 99SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
f5c174ff 100ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
1e3d16b0 101PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
567a9e6f 102SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
29eed3dd 103{- output_off() if $disabled{makedepend}; "" -}
834aae2a 104DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
c058fcd7
RL
105 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
106 keys %{$unified_info{sources}}); -}
29eed3dd 107{- output_on() if $disabled{makedepend}; "" -}
7cae3864 108GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
05a7aee0
RL
109GENERATED={- join(" ",
110 ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
111 grep { defined $unified_info{generate}->{$_} }
112 map { @{$unified_info{sources}->{$_}} }
113 grep { /\.o$/ } keys %{$unified_info{sources}} ),
114 ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -}
c058fcd7 115
33105818 116INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
0f01b7bc
RL
117INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
118INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
119INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
120INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
df653379 121{- output_off() if $disabled{apps}; "" -}
567a9e6f 122BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
b8a9af68 123MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
df653379 124{- output_on() if $disabled{apps}; "" -}
567a9e6f 125
6a74806e
RL
126APPS_OPENSSL={- use File::Spec::Functions;
127 catfile("apps","openssl") -}
128
3c65577f
RL
129# DESTDIR is for package builders so that they can configure for, say,
130# /usr/ and yet have everything installed to /tmp/somedir/usr/.
567a9e6f 131# Normally it is left empty.
3c65577f 132DESTDIR=
567a9e6f
RL
133
134# Do not edit these manually. Use Configure with --prefix or --openssldir
135# to change this! Short explanation in the top comment in Configure
136INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
137 #
138 our $prefix = $config{prefix} || "/usr/local";
139 $prefix -}
140OPENSSLDIR={- #
141 # The logic here is that if no --openssldir was given,
142 # OPENSSLDIR will get the value from $prefix plus "/ssl".
143 # If --openssldir was given and the value is an absolute
144 # path, OPENSSLDIR will get its value without change.
145 # If the value from --openssldir is a relative path,
146 # OPENSSLDIR will get $prefix with the --openssldir
147 # value appended as a subdirectory.
148 #
149 use File::Spec::Functions;
150 our $openssldir =
151 $config{openssldir} ?
152 (file_name_is_absolute($config{openssldir}) ?
153 $config{openssldir}
154 : catdir($prefix, $config{openssldir}))
155 : catdir($prefix, "ssl");
156 $openssldir -}
157LIBDIR={- #
158 # if $prefix/lib$target{multilib} is not an existing
159 # directory, then assume that it's not searched by linker
160 # automatically, in which case adding $target{multilib} suffix
161 # causes more grief than we're ready to tolerate, so don't...
162 our $multilib =
163 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
164 our $libdir = $config{libdir} || "lib$multilib";
165 $libdir -}
166ENGINESDIR={- use File::Spec::Functions;
d4453024 167 catdir($prefix,$libdir,"engines-$sover_dirname") -}
567a9e6f 168
fad599f7
RL
169# Convenience variable for those who want to set the rpath in shared
170# libraries and applications
171LIBRPATH=$(INSTALLTOP)/$(LIBDIR)
172
dde10ab4 173MANDIR=$(INSTALLTOP)/share/man
8be7bdb5
RL
174DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
175HTMLDIR=$(DOCDIR)/html
567a9e6f 176
3544091a
RL
177# MANSUFFIX is for the benefit of anyone who may want to have a suffix
178# appended after the manpage file section number. "ssl" is popular,
179# resulting in files such as config.5ssl rather than config.5.
180MANSUFFIX=
567a9e6f
RL
181HTMLSUFFIX=html
182
5407338a
RS
183# For "optional" echo messages, to get "real" silence
184ECHO = echo
567a9e6f
RL
185
186CROSS_COMPILE= {- $config{cross_compile_prefix} -}
8c3bc594 187CPPFLAGS={- our $cppflags = join(" ",
5b18235a
RL
188 (map { "-D".$_} @{$config{defines}}),
189 (map { "-I".$_} @{$config{includes}}),
190 @{$config{cppflags}}) -}
8c3bc594 191CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -}
5b18235a
RL
192CC= $(CROSS_COMPILE){- $config{cc} -}
193CFLAGS={- join(' ', @{$config{cflags}}) -}
194CXX= $(CROSS_COMPILE){- $config{cxx} -}
fa153b57 195CXXFLAGS={- join(' ', @{$config{cxxflags}}) -}
5b18235a
RL
196LDFLAGS= {- join(' ', @{$config{lflags}}) -}
197PLIB_LDFLAGS= {- join(' ', @{$config{plib_lflags}}) -}
198EX_LIBS= {- join(' ', @{$config{ex_libs}}) -}
199LIB_CPPFLAGS={- join(' ',
200 (map { '-D'.$_ }
201 ('OPENSSLDIR="\"$(OPENSSLDIR)\""',
202 'ENGINESDIR="\"$(ENGINESDIR)\""')),
203 $target{shared_cppflag}) || "" -}
bbd9a50f 204LIB_CFLAGS={- $target{shared_cflag} || "" -}
7763472f 205LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -}
075f7e2c 206LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -}
8c3bc594 207DSO_CPPFLAGS={- $target{dso_cppflags} || "" -}
793077d0
RL
208DSO_CFLAGS={- $target{dso_cflags} || "" -}
209DSO_CXXFLAGS={- $target{dso_cxxflags} || "" -}
210DSO_LDFLAGS={- $target{dso_lflags} || "" -}
8c3bc594 211BIN_CPPFLAGS={- $target{bin_cppflags} || "" -}
793077d0
RL
212BIN_CFLAGS={- $target{bin_cflags} || "" -}
213BIN_CXXFLAGS={- $target{bin_cxxflags} || "" -}
214BIN_LDFLAGS={- $target{bin_lflags} || "" -}
567a9e6f
RL
215
216PERL={- $config{perl} -}
217
5b18235a
RL
218AR=$(CROSS_COMPILE){- $config{ar} -}
219ARFLAGS= {- join(' ', @{$config{arflags}}) -}
220RANLIB= {- $config{ranlib} -}
8f41ff2d 221RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
5b18235a 222RCFLAGS={- join(' ', @{$config{rcflags}}) -} {- $target{shared_rcflag} -}
567a9e6f 223RM= rm -f
98e5534e 224RMDIR= rmdir
567a9e6f
RL
225TAR= {- $target{tar} || "tar" -}
226TARFLAGS= {- $target{tarflags} -}
29eed3dd 227MAKEDEPEND={- $config{makedepprog} -}
567a9e6f
RL
228
229BASENAME= openssl
230NAME= $(BASENAME)-$(VERSION)
231TARFILE= ../$(NAME).tar
232
233# We let the C compiler driver to take care of .s files. This is done in
234# order to be excused from maintaining a separate set of architecture
235# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
236# gcc, then the driver will automatically translate it to -xarch=v8plus
237# and pass it down to assembler.
5b18235a
RL
238AS={- $config{as} || '$(CC) -c' -}
239ASFLAGS={- join(' ', @{$config{asflags}}) || '$(CFLAGS)' -}
567a9e6f
RL
240PERLASM_SCHEME= {- $target{perlasm_scheme} -}
241
242# For x86 assembler: Set PROCESSOR to 386 if you want to support
243# the 80386.
244PROCESSOR= {- $config{processor} -}
245
9c7ce40b
AP
246# We want error [and other] messages in English. Trouble is that make(1)
247# doesn't pass macros down as environment variables unless there already
248# was corresponding variable originally set. In other words we can only
249# reassign environment variables, but not set new ones, not in portable
250# manner that is. That's why we reassign several, just to be sure...
251LC_ALL=C
252LC_MESSAGES=C
253LANG=C
254
567a9e6f
RL
255# The main targets ###################################################
256
1e3d16b0 257{- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
27c40a93
BL
258{- dependmagic('build_libs'); -}: build_libs_nodep
259{- dependmagic('build_engines'); -}: build_engines_nodep
1e3d16b0 260{- dependmagic('build_programs'); -}: build_programs_nodep
567a9e6f 261
27c40a93 262build_generated: $(GENERATED_MANDATORY)
c058fcd7 263build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
c058fcd7 264build_engines_nodep: $(ENGINES)
1e3d16b0
RL
265build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
266
267# Kept around for backward compatibility
268build_apps build_tests: build_programs
68a5f1a2 269
9b03b91b
RL
270# Convenience target to prebuild all generated files, not just the mandatory
271# ones
272build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
273
1b741653 274test: tests
1e3d16b0 275{- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
d90a6beb 276 @ : {- output_off() if $disabled{tests}; "" -}
567a9e6f 277 ( cd test; \
41f571e1 278 mkdir -p test-runs; \
567a9e6f
RL
279 SRCTOP=../$(SRCDIR) \
280 BLDTOP=../$(BLDDIR) \
41f571e1 281 RESULT_D=test-runs \
cbece220 282 PERL="$(PERL)" \
834aae2a 283 EXE_EXT={- $exeext -} \
41f571e1 284 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines; pwd` \
6d4bc8a3 285 OPENSSL_DEBUG_MEMORY=on \
567a9e6f 286 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
d90a6beb
MC
287 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
288 @echo "Tests are not supported with your chosen Configure options"
289 @ : {- output_on() if !$disabled{tests}; "" -}
567a9e6f
RL
290
291list-tests:
4813ad2d
RL
292 @ : {- output_off() if $disabled{tests}; "" -}
293 @SRCTOP="$(SRCDIR)" \
294 $(PERL) $(SRCDIR)/test/run_tests.pl list
295 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
296 @echo "Tests are not supported with your chosen Configure options"
297 @ : {- output_on() if !$disabled{tests}; "" -}
298
299install: install_sw install_ssldirs install_docs
300
301uninstall: uninstall_docs uninstall_sw
567a9e6f
RL
302
303libclean:
f99f91f1
RL
304 @set -e; for s in $(SHLIB_INFO); do \
305 s1=`echo "$$s" | cut -f1 -d";"`; \
306 s2=`echo "$$s" | cut -f2 -d";"`; \
5407338a 307 $(ECHO) $(RM) $$s1; \
f99f91f1
RL
308 $(RM) $$s1; \
309 if [ "$$s1" != "$$s2" ]; then \
5407338a 310 $(ECHO) $(RM) $$s2; \
f99f91f1
RL
311 $(RM) $$s2; \
312 fi; \
313 done
314 $(RM) $(LIBS)
4813ad2d 315 $(RM) *.map
567a9e6f
RL
316
317clean: libclean
4813ad2d
RL
318 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
319 $(RM) $(GENERATED)
320 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
321 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
322 $(RM) core
9e183d22 323 $(RM) tags TAGS doc-nits
d016d1ec 324 $(RM) -r test/test-runs
4813ad2d
RL
325 $(RM) openssl.pc libcrypto.pc libssl.pc
326 -$(RM) `find . -type l -a \! -path "./.git/*"`
327 $(RM) $(TARFILE)
567a9e6f 328
7cae3864 329distclean: clean
4813ad2d
RL
330 $(RM) configdata.pm
331 $(RM) Makefile
7cae3864 332
f8d9d6e4 333# We check if any depfile is newer than Makefile and decide to
a6adf099 334# concatenate only if that is true.
ea80a25e 335depend:
29eed3dd 336 @: {- output_off() if $disabled{makedepend}; "" -}
d423c5ad 337 @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
ebca7961 338 ( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
f8d9d6e4
RL
339 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
340 echo; \
a6adf099
RL
341 for f in $(DEPS); do \
342 if [ -f $$f ]; then cat $$f; fi; \
f8d9d6e4 343 done ) > Makefile.new; \
29b28eee 344 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
f8d9d6e4 345 rm -f Makefile.new; \
29b28eee
RL
346 else \
347 mv -f Makefile.new Makefile; \
f8d9d6e4 348 fi; \
c058fcd7 349 fi
29eed3dd 350 @: {- output_on() if $disabled{makedepend}; "" -}
567a9e6f
RL
351
352# Install helper targets #############################################
353
354install_sw: all install_dev install_engines install_runtime
355
f99f91f1 356uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
567a9e6f
RL
357
358install_docs: install_man_docs install_html_docs
359
360uninstall_docs: uninstall_man_docs uninstall_html_docs
8be7bdb5 361 $(RM) -r -v $(DESTDIR)$(DOCDIR)
567a9e6f 362
dde10ab4
RL
363install_ssldirs:
364 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
365 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
66c2eb8b 366 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
4813ad2d
RL
367 @set -e; for x in dummy $(MISC_SCRIPTS); do \
368 if [ "$$x" = "dummy" ]; then continue; fi; \
369 fn=`basename $$x`; \
5407338a 370 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
4813ad2d
RL
371 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
372 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
373 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
374 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
375 done
5407338a 376 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
4813ad2d
RL
377 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
378 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
cb926df2 379 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
c7af65c7 380 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
5407338a 381 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
cb926df2
RL
382 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
383 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
384 fi
5407338a 385 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
c7af65c7
RS
386 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
387 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
388 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
389 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
5407338a 390 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
c7af65c7
RS
391 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
392 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
393 fi
dde10ab4 394
567a9e6f
RL
395install_dev:
396 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 397 @$(ECHO) "*** Installing development files"
3c65577f 398 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
24c4f736 399 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
5407338a 400 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
24c4f736
RL
401 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
402 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
403 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
567a9e6f
RL
404 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
405 $(BLDDIR)/include/openssl/*.h; do \
406 fn=`basename $$i`; \
5407338a 407 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
3c65577f
RL
408 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
409 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 410 done
3c65577f 411 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
0f01b7bc 412 @set -e; for l in $(INSTALL_LIBS); do \
567a9e6f 413 fn=`basename $$l`; \
5407338a 414 $(ECHO) "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
3c65577f
RL
415 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
416 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
417 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
418 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
419 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
567a9e6f 420 done
84af1bae 421 @ : {- output_off() if $disabled{shared}; "" -}
0f01b7bc 422 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
c8c2b779
RL
423 s1=`echo "$$s" | cut -f1 -d";"`; \
424 s2=`echo "$$s" | cut -f2 -d";"`; \
425 fn1=`basename $$s1`; \
426 fn2=`basename $$s2`; \
427 : {- output_off() if windowsdll(); "" -}; \
5407338a 428 $(ECHO) "install $$s1 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
c8c2b779 429 cp $$s1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
3503549e 430 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
c8c2b779
RL
431 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new \
432 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
433 if [ "$$fn1" != "$$fn2" ]; then \
5407338a 434 $(ECHO) "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
c8c2b779 435 ln -sf $$fn1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
567a9e6f 436 fi; \
c8c2b779 437 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
5407338a 438 $(ECHO) "install $$s2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
c8c2b779 439 cp $$s2 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
3503549e 440 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
c8c2b779
RL
441 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new \
442 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
ce5ed82f 443 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 444 done
84af1bae 445 @ : {- output_on() if $disabled{shared}; "" -}
3c65577f 446 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
5407338a 447 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
3c65577f
RL
448 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
449 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
5407338a 450 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
3c65577f
RL
451 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
452 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
5407338a 453 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
3c65577f
RL
454 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
455 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
567a9e6f
RL
456
457uninstall_dev:
5407338a 458 @$(ECHO) "*** Uninstalling development files"
24c4f736 459 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
5407338a 460 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
24c4f736
RL
461 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
462 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
567a9e6f
RL
463 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
464 $(BLDDIR)/include/openssl/*.h; do \
465 fn=`basename $$i`; \
5407338a 466 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
3c65577f 467 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 468 done
98e5534e
RL
469 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
470 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
0f01b7bc 471 @set -e; for l in $(INSTALL_LIBS); do \
567a9e6f 472 fn=`basename $$l`; \
5407338a 473 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
3c65577f 474 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
567a9e6f 475 done
84af1bae 476 @ : {- output_off() if $disabled{shared}; "" -}
0f01b7bc 477 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
c8c2b779
RL
478 s1=`echo "$$s" | cut -f1 -d";"`; \
479 s2=`echo "$$s" | cut -f2 -d";"`; \
480 fn1=`basename $$s1`; \
481 fn2=`basename $$s2`; \
482 : {- output_off() if windowsdll(); "" -}; \
5407338a 483 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
c8c2b779
RL
484 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
485 if [ "$$fn1" != "$$fn2" ]; then \
5407338a 486 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
3c65577f 487 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
567a9e6f 488 fi; \
c8c2b779 489 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
5407338a 490 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
c8c2b779 491 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
ce5ed82f 492 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 493 done
c8cca980 494 @ : {- output_on() if $disabled{shared}; "" -}
b894054e
RL
495 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
496 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
497 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
498 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
499 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
567a9e6f
RL
500
501install_engines:
502 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
b2de11c5 503 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
5407338a 504 @$(ECHO) "*** Installing engines"
0f01b7bc 505 @set -e; for e in dummy $(INSTALL_ENGINES); do \
2b364f61 506 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 507 fn=`basename $$e`; \
5407338a 508 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
b2de11c5
RL
509 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
510 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
511 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
512 $(DESTDIR)$(ENGINESDIR)/$$fn; \
567a9e6f
RL
513 done
514
515uninstall_engines:
5407338a 516 @$(ECHO) "*** Uninstalling engines"
0f01b7bc 517 @set -e; for e in dummy $(INSTALL_ENGINES); do \
2b364f61 518 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 519 fn=`basename $$e`; \
f0c93a85
RL
520 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
521 continue; \
522 fi; \
5407338a 523 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
b2de11c5 524 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
567a9e6f 525 done
b2de11c5 526 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
567a9e6f
RL
527
528install_runtime:
529 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
3c65577f 530 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
36b53720
RL
531 @ : {- output_off() if windowsdll(); "" -}
532 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
533 @ : {- output_on() if windowsdll(); "" -}
5407338a 534 @$(ECHO) "*** Installing runtime files"
0f01b7bc 535 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
2b364f61 536 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 537 fn=`basename $$s`; \
36b53720 538 : {- output_off() unless windowsdll(); "" -}; \
5407338a 539 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
540 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
541 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
542 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
543 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
36b53720 544 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
5407338a 545 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
36b53720
RL
546 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
547 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
548 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
549 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
550 : {- output_on() if windowsdll(); "" -}; \
fcf80c46 551 done
0f01b7bc 552 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
2b364f61 553 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 554 fn=`basename $$x`; \
5407338a 555 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
556 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
557 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
558 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
559 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 560 done
2b364f61
RL
561 @set -e; for x in dummy $(BIN_SCRIPTS); do \
562 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 563 fn=`basename $$x`; \
5407338a 564 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
565 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
566 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
567 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
568 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 569 done
567a9e6f
RL
570
571uninstall_runtime:
5407338a 572 @$(ECHO) "*** Uninstalling runtime files"
0f01b7bc 573 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
567a9e6f 574 do \
2b364f61 575 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 576 fn=`basename $$x`; \
5407338a 577 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 578 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 579 done;
2b364f61 580 @set -e; for x in dummy $(BIN_SCRIPTS); \
567a9e6f 581 do \
2b364f61 582 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 583 fn=`basename $$x`; \
5407338a 584 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 585 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 586 done
b1837abd 587 @ : {- output_off() unless windowsdll(); "" -}
0f01b7bc 588 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
2b364f61 589 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 590 fn=`basename $$s`; \
5407338a 591 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 592 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
fcf80c46 593 done
b1837abd 594 @ : {- output_on() unless windowsdll(); "" -}
b894054e 595 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
567a9e6f 596
567a9e6f
RL
597
598install_man_docs:
599 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 600 @$(ECHO) "*** Installing manpages"
cadb015b
RL
601 $(PERL) $(SRCDIR)/util/process_docs.pl \
602 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
567a9e6f
RL
603
604uninstall_man_docs:
5407338a 605 @$(ECHO) "*** Uninstalling manpages"
cadb015b
RL
606 $(PERL) $(SRCDIR)/util/process_docs.pl \
607 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
608 --remove
567a9e6f
RL
609
610install_html_docs:
611 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 612 @$(ECHO) "*** Installing HTML manpages"
cadb015b
RL
613 $(PERL) $(SRCDIR)/util/process_docs.pl \
614 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
567a9e6f
RL
615
616uninstall_html_docs:
5407338a 617 @$(ECHO) "*** Uninstalling manpages"
cadb015b
RL
618 $(PERL) $(SRCDIR)/util/process_docs.pl \
619 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
567a9e6f
RL
620
621
622# Developer targets (note: these are only available on Unix) #########
623
6bb2106e
RL
624update: generate errors ordinals
625
b7650c67 626generate: generate_apps generate_crypto_bn generate_crypto_objects \
8e32e1ab 627 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
567a9e6f 628
65c1f979 629doc-nits:
1722496f 630 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
9e183d22 631 if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
65c1f979 632
567a9e6f
RL
633# Test coverage is a good idea for the future
634#coverage: $(PROGRAMS) $(TESTPROGRAMS)
635# ...
636
567a9e6f
RL
637lint:
638 lint -DLINT $(INCLUDES) $(SRCS)
639
9a9f8ee7
RL
640generate_apps:
641 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
642 < apps/openssl.cnf > apps/openssl-vms.cnf )
9a9f8ee7
RL
643
644generate_crypto_bn:
645 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
646
647generate_crypto_objects:
9a9f8ee7
RL
648 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
649 crypto/objects/objects.txt \
650 crypto/objects/obj_mac.num \
651 include/openssl/obj_mac.h )
e6f2bb66
KM
652 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
653 include/openssl/obj_mac.h \
654 crypto/objects/obj_dat.h )
9a9f8ee7
RL
655 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
656 crypto/objects/obj_mac.num \
657 crypto/objects/obj_xref.txt \
658 > crypto/objects/obj_xref.h )
6bb2106e 659
b7650c67
RL
660generate_crypto_conf:
661 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
662 > crypto/conf/conf_def.h )
663
664generate_crypto_asn1:
665 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
666 > crypto/asn1/charmap.h )
667
8e32e1ab
RL
668generate_fuzz_oids:
669 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
670 crypto/objects/obj_dat.h \
671 > fuzz/oids.txt )
672
52df25cf
RS
673# Set to -force to force a rebuild
674ERROR_REBUILD=
567a9e6f
RL
675errors:
676 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
cb7b7275
RL
677 ( b=`pwd`; cd $(SRCDIR); \
678 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
679 ( b=`pwd`; cd $(SRCDIR)/engines; \
52df25cf 680 for E in *.ec ; do \
cb7b7275 681 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
52df25cf
RS
682 -conf $$E `basename $$E .ec`.c ; \
683 done )
567a9e6f
RL
684
685ordinals:
686 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
687 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
688
689test_ordinals:
690 ( cd test; \
691 SRCTOP=../$(SRCDIR) \
692 BLDTOP=../$(BLDDIR) \
693 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
694
695tags TAGS: FORCE
696 rm -f TAGS tags
697 -ctags -R .
698 -etags `find . -name '*.[ch]' -o -name '*.pm'`
699
700# Release targets (note: only available on Unix) #####################
701
77a9c26e
RL
702# If your tar command doesn't support --owner and --group, make sure to
703# use one that does, for example GNU tar
a1bce642 704TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
54bb8f74 705PREPARE_CMD=:
567a9e6f 706tar:
34a5b7d7 707 set -e; \
567a9e6f 708 TMPDIR=/var/tmp/openssl-copy.$$$$; \
54bb8f74 709 DISTDIR=$(NAME); \
567a9e6f
RL
710 mkdir -p $$TMPDIR/$$DISTDIR; \
711 (cd $(SRCDIR); \
5b7b0115
RL
712 excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
713 excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
714 echo "$$excl_re"; \
567a9e6f 715 git ls-tree -r --name-only --full-tree HEAD \
17c84aa7 716 | egrep -v "$$excl_re" \
567a9e6f
RL
717 | while read F; do \
718 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
719 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
720 done); \
17c84aa7 721 (cd $$TMPDIR/$$DISTDIR; \
54bb8f74 722 $(PREPARE_CMD); \
17c84aa7
RL
723 find . -type d -print | xargs chmod 755; \
724 find . -type f -print | xargs chmod a+r; \
725 find . -type f -perm -0100 -print | xargs chmod a+x); \
726 (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
567a9e6f
RL
727 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
728 rm -rf $$TMPDIR
729 cd $(SRCDIR); ls -l $(TARFILE).gz
730
731dist:
bffa1ff8 732 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
567a9e6f
RL
733
734# Helper targets #####################################################
735
342a1a23 736link-utils: $(BLDDIR)/util/opensslwrap.sh
567a9e6f 737
27f42b46 738$(BLDDIR)/util/opensslwrap.sh: configdata.pm
567a9e6f
RL
739 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
740 mkdir -p "$(BLDDIR)/util"; \
741 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
742 fi
342a1a23 743
c058fcd7 744FORCE:
567a9e6f
RL
745
746# Building targets ###################################################
747
8478a703 748libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
567a9e6f
RL
749libcrypto.pc:
750 @ ( echo 'prefix=$(INSTALLTOP)'; \
751 echo 'exec_prefix=$${prefix}'; \
752 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
753 echo 'includedir=$${prefix}/include'; \
d4453024 754 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
567a9e6f
RL
755 echo ''; \
756 echo 'Name: OpenSSL-libcrypto'; \
757 echo 'Description: OpenSSL cryptography library'; \
758 echo 'Version: '$(VERSION); \
759 echo 'Libs: -L$${libdir} -lcrypto'; \
760 echo 'Libs.private: $(EX_LIBS)'; \
761 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
762
763libssl.pc:
764 @ ( echo 'prefix=$(INSTALLTOP)'; \
765 echo 'exec_prefix=$${prefix}'; \
766 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
767 echo 'includedir=$${prefix}/include'; \
768 echo ''; \
769 echo 'Name: OpenSSL-libssl'; \
770 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
771 echo 'Version: '$(VERSION); \
772 echo 'Requires.private: libcrypto'; \
773 echo 'Libs: -L$${libdir} -lssl'; \
567a9e6f
RL
774 echo 'Cflags: -I$${includedir}' ) > libssl.pc
775
776openssl.pc:
777 @ ( echo 'prefix=$(INSTALLTOP)'; \
778 echo 'exec_prefix=$${prefix}'; \
779 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
780 echo 'includedir=$${prefix}/include'; \
781 echo ''; \
782 echo 'Name: OpenSSL'; \
783 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
784 echo 'Version: '$(VERSION); \
785 echo 'Requires: libssl libcrypto' ) > openssl.pc
786
41240e68 787configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
27f42b46 788 @echo "Detected changed: $?"
f9856cc5 789 $(PERL) configdata.pm -r -v
567a9e6f
RL
790 @echo "**************************************************"
791 @echo "*** ***"
792 @echo "*** Please run the same make command again ***"
793 @echo "*** ***"
794 @echo "**************************************************"
795 @false
796
bf01fbbf
RL
797reconfigure reconf:
798 $(PERL) configdata.pm -r -v
799
567a9e6f
RL
800{-
801 use File::Basename;
802 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
cedbb146
RL
803
804 # Helper function to figure out dependencies on libraries
805 # It takes a list of library names and outputs a list of dependencies
806 sub compute_lib_depends {
84af1bae 807 if ($disabled{shared}) {
33105818 808 return map { lib($_) } @_;
cedbb146
RL
809 }
810
811 # Depending on shared libraries:
812 # On Windows POSIX layers, we depend on {libname}.dll.a
813 # On Unix platforms, we depend on {shlibname}.so
186a31e5 814 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
cedbb146
RL
815 }
816
66ddf178
RL
817 sub generatesrc {
818 my %args = @_;
819 my $generator = join(" ", @{$args{generator}});
8d34daf0 820 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
d4605727 821 my $incs = join("", map { " -I".$_ } @{$args{incs}});
8d34daf0 822 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
66ddf178
RL
823
824 if ($args{src} !~ /\.[sS]$/) {
7cae3864
RL
825 if ($args{generator}->[0] =~ m|^.*\.in$|) {
826 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
827 "util", "dofile.pl")),
828 rel2abs($config{builddir}));
829 return <<"EOF";
830$args{src}: $args{generator}->[0] $deps
831 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
832 "-o$target{build_file}" $generator > \$@
833EOF
834 } else {
835 return <<"EOF";
769777b0 836$args{src}: $args{generator}->[0] $deps
8d34daf0 837 \$(PERL)$generator_incs $generator > \$@
66ddf178 838EOF
7cae3864 839 }
66ddf178 840 } else {
8458f1bf 841 if ($args{generator}->[0] =~ /\.pl$/) {
8d34daf0 842 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
8458f1bf 843 } elsif ($args{generator}->[0] =~ /\.m4$/) {
8d34daf0 844 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
8458f1bf
RL
845 } elsif ($args{generator}->[0] =~ /\.S$/) {
846 $generator = undef;
847 } else {
848 die "Generator type for $args{src} unknown: $generator\n";
849 }
850
851 if (defined($generator)) {
852 # If the target is named foo.S in build.info, we want to
853 # end up generating foo.s in two steps.
854 if ($args{src} =~ /\.S$/) {
855 (my $target = $args{src}) =~ s|\.S$|.s|;
856 return <<"EOF";
769777b0 857$target: $args{generator}->[0] $deps
0218fc37 858 ( trap "rm -f \$@.*" INT 0; \\
8458f1bf 859 $generator \$@.S; \\
d8e2b4f9 860 \$(CPP) $incs $cppflags \$@.S | \\
39199fb3
AP
861 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
862 mv -f \$@.i \$@ )
66ddf178 863EOF
8458f1bf
RL
864 }
865 # Otherwise....
66ddf178 866 return <<"EOF";
769777b0 867$args{src}: $args{generator}->[0] $deps
8458f1bf 868 $generator \$@
66ddf178 869EOF
66ddf178 870 }
8458f1bf 871 return <<"EOF";
769777b0 872$args{src}: $args{generator}->[0] $deps
d8e2b4f9 873 \$(CPP) $incs $cppflags $args{generator}->[0] | \\
39199fb3 874 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
8458f1bf 875EOF
66ddf178
RL
876 }
877 }
878
bb26842d
RL
879 # Should one wonder about the end of the Perl snippet, it's because this
880 # second regexp eats up line endings as well, if the removed path is the
881 # last in the line. We may therefore need to put back a line ending.
88297284 882 sub src2obj {
567a9e6f 883 my %args = @_;
81183680 884 (my $obj = $args{obj}) =~ s|\.o$||;
674d5858
RL
885 my @srcs = map { if ($unified_info{generate}->{$_}) {
886 (my $x = $_) =~ s/\.S$/.s/; $x
887 } else {
888 $_
889 }
890 } ( @{$args{srcs}} );
8458f1bf
RL
891 my $srcs = join(" ", @srcs);
892 my $deps = join(" ", @srcs, @{$args{deps}});
45502bfe 893 my $incs = join("", map { " -I".$_ } @{$args{incs}});
81183680 894 my $cmd = '$(CC)';
8c3bc594
RL
895 my $cmdflags = '$(CFLAGS)';
896 my $cmdcompile = ' -c';
81183680
RL
897 my $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
898 if (grep /\.rc$/, @srcs) {
899 $cmd = '$(RC)';
900 $cmdflags = '$(RCFLAGS)';
8c3bc594 901 $cmdcompile = '';
81183680
RL
902 $makedepprog = undef;
903 } elsif (grep /\.(cc|cpp)$/, @srcs) {
904 $cmd = '$(CXX)';
8c3bc594 905 $cmdflags = '$(CXXFLAGS)';
81183680
RL
906 $cmdflags .= ' ' . { lib => '$(LIB_CXXFLAGS)',
907 dso => '$(DSO_CXXFLAGS)',
908 bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}};
8c3bc594
RL
909 $cmdflags .= ' $(CPPFLAGS)';
910 $cmdflags .= ' ' . { lib => '$(LIB_CPPFLAGS)',
911 dso => '$(DSO_CPPFLAGS)',
912 bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
7763472f 913 } else {
81183680
RL
914 $cmdflags .= ' ' . { lib => '$(LIB_CFLAGS)',
915 dso => '$(DSO_CFLAGS)',
916 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
8c3bc594
RL
917 $cmdflags .= ' $(CPPFLAGS)';
918 $cmdflags .= ' ' . { lib => '$(LIB_CPPFLAGS)',
919 dso => '$(DSO_CPPFLAGS)',
920 bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
7763472f 921 }
8c3bc594 922 $cmdflags .= $cmdcompile;
7e5b8b93
RL
923 my $recipe = <<"EOF";
924$obj$objext: $deps
925EOF
81183680 926 if (defined $makedepprog && $makedepprog !~ /\/makedepend/) {
29eed3dd 927 $recipe .= <<"EOF";
81183680 928 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
7e5b8b93
RL
929 \@touch $obj$depext.tmp
930 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
931 rm -f $obj$depext.tmp; \\
29b28eee 932 else \\
7e5b8b93 933 mv $obj$depext.tmp $obj$depext; \\
987dbc7f 934 fi
29eed3dd 935EOF
7e5b8b93 936 } else {
29eed3dd 937 $recipe .= <<"EOF";
81183680 938 $cmd $incs $cmdflags -o \$\@ $srcs
567a9e6f 939EOF
81183680 940 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
7e5b8b93 941 $recipe .= <<"EOF";
81183680 942 -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cmdflags -- $srcs \\
7e5b8b93
RL
943 >$obj$depext.tmp 2>/dev/null
944 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
29b28eee 945 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
987dbc7f 946 rm -f $obj$depext.tmp; \\
29b28eee
RL
947 else \\
948 mv $obj$depext.tmp $obj$depext; \\
340da949 949 fi
567a9e6f 950EOF
7e5b8b93 951 }
29eed3dd
RL
952 }
953 return $recipe;
567a9e6f
RL
954 }
955 # On Unix, we build shlibs from static libs, so we're ignoring the
956 # object file array. We *know* this routine is only called when we've
957 # configure 'shared'.
958 sub libobj2shlib {
959 my %args = @_;
960 my $lib = $args{lib};
961 my $shlib = $args{shlib};
962 my $libd = dirname($lib);
963 my $libn = basename($lib);
964 (my $libname = $libn) =~ s/^lib//;
47eeaf45
RL
965 my @linkdirs = ();
966 foreach (@{args{deps}}) {
967 my $d = dirname($_);
968 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
969 }
970 my $linkflags = join("", map { "-L$_ " } @linkdirs);
971 my $linklibs = join("", map { my $f = basename($_);
cedbb146 972 (my $l = $f) =~ s/^lib//;
47eeaf45 973 " -l$l" } @{$args{deps}});
81183680
RL
974 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
975 grep { $_ =~ m|\.o$| }
976 @{$args{objs}};
977 my @defs = grep { $_ =~ /\.(def|map)$/ } @{$args{objs}};
978 my @deps = compute_lib_depends(@{$args{deps}});
979 die "More than one exported symbol map" if scalar @defs > 1;
980 my $objs = join(" ", @objs);
981 my $deps = join(" ", @objs, @defs, @deps);
f5c174ff 982 my $target = shlib_simple($lib);
d07abe13 983 my $target_full = shlib($lib);
81183680
RL
984 my $shared_soname = "";
985 $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
986 if defined $target{shared_sonameflag};
987 my $shared_imp = "";
988 $shared_imp .= ' '.$target{shared_impflag}.basename($target)
989 if defined $target{shared_impflag};
990 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
991 my $recipe = <<"EOF";
992# When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
cedbb146
RL
993# that two files get produced, {shlibname}.dll and {libname}.dll.a.
994# With all other Unix platforms, we often build a shared library with the
995# SO version built into the file name and a symlink without the SO version
996# It's not necessary to have both as targets. The choice falls on the
d4453024
RL
997# simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
998# {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
81183680 999$target: $deps
47eeaf45 1000 \$(CC) \$(CFLAGS) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
81183680
RL
1001 -o $target_full$shared_def $objs \\
1002 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
fcf80c46 1003EOF
81183680
RL
1004 if (windowsdll()) {
1005 $recipe .= <<"EOF";
d4453024
RL
1006 rm -f apps/$shlib'\$(SHLIB_EXT)'
1007 rm -f test/$shlib'\$(SHLIB_EXT)'
81183680 1008 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
d4453024
RL
1009 cp -p $shlib'\$(SHLIB_EXT)' apps/
1010 cp -p $shlib'\$(SHLIB_EXT)' test/
81183680
RL
1011 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1012EOF
1013 } else {
1014 $recipe .= <<"EOF";
50625bf5
RL
1015 if [ '$target' != '$target_full' ]; then \\
1016 rm -f $target; \\
1017 ln -s $target_full $target; \\
1018 fi
567a9e6f 1019EOF
81183680 1020 }
567a9e6f 1021 }
5386287c 1022 sub obj2dso {
567a9e6f 1023 my %args = @_;
d07abe13
RL
1024 my $dso = $args{lib};
1025 my $dsod = dirname($dso);
1026 my $dson = basename($dso);
47eeaf45
RL
1027 my @linkdirs = ();
1028 foreach (@{args{deps}}) {
1029 my $d = dirname($_);
1030 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1031 }
1032 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1033 my $linklibs = join("", map { my $f = basename($_);
81183680 1034 (my $l = $f) =~ s/^lib//;
47eeaf45 1035 " -l$l" } @{$args{deps}});
81183680
RL
1036 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1037 my @deps = compute_lib_depends(@{$args{deps}});
1038 my $objs = join(" ", @objs);
1039 my $deps = join(" ", @deps);
d07abe13 1040 my $target = dso($dso);
567a9e6f 1041 return <<"EOF";
f5c174ff 1042$target: $objs $deps
47eeaf45 1043 \$(CC) \$(CFLAGS) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
81183680
RL
1044 -o $target $objs \\
1045 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
567a9e6f
RL
1046EOF
1047 }
1048 sub obj2lib {
1049 my %args = @_;
33105818 1050 (my $lib = $args{lib}) =~ s/\.a$//;
81183680
RL
1051 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1052 my $objs = join(" ", @objs);
567a9e6f 1053 return <<"EOF";
834aae2a 1054$lib$libext: $objs
5b18235a 1055 \$(AR) \$(ARFLAGS) \$\@ \$\?
567a9e6f
RL
1056 \$(RANLIB) \$\@ || echo Never mind.
1057EOF
1058 }
1059 sub obj2bin {
1060 my %args = @_;
1061 my $bin = $args{bin};
1062 my $bind = dirname($bin);
1063 my $binn = basename($bin);
81183680
RL
1064 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$|$objext|; $x }
1065 @{$args{objs}});
cedbb146 1066 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
47eeaf45
RL
1067 my @linkdirs = ();
1068 foreach (@{args{deps}}) {
1069 next if $_ =~ /\.a$/;
1070 my $d = dirname($_);
1071 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1072 }
1073 my $linkflags = join("", map { "-L$_ " } @linkdirs);
186a31e5
RL
1074 my $linklibs = join("", map { if ($_ =~ /\.a$/) {
1075 " $_";
1076 } else {
186a31e5 1077 my $f = basename($_);
186a31e5 1078 (my $l = $f) =~ s/^lib//;
47eeaf45 1079 " -l$l"
186a31e5
RL
1080 }
1081 } @{$args{deps}});
81183680
RL
1082 my $cmd = '$(CC)';
1083 my $cmdflags = '$(CFLAGS) $(BIN_CFLAGS)';
1084 if (grep /_cc\.o$/, @{$args{objs}}) {
1085 $cmd = '$(CXX)';
1086 $cmdflags = '$(CXXFLAGS) $(BIN_CXXFLAGS)';
7763472f 1087 }
567a9e6f 1088 return <<"EOF";
834aae2a 1089$bin$exeext: $objs $deps
81183680 1090 rm -f $bin$exeext
47eeaf45
RL
1091 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(LDFLAGS) \$(BIN_LDFLAGS) \\
1092 -o $bin$exeext $objs \\
81183680 1093 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
567a9e6f
RL
1094EOF
1095 }
1096 sub in2script {
1097 my %args = @_;
1098 my $script = $args{script};
1099 my $sources = join(" ", @{$args{sources}});
1100 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1101 "util", "dofile.pl")),
1102 rel2abs($config{builddir}));
1103 return <<"EOF";
88297284 1104$script: $sources
4b799cea 1105 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
ba327ade 1106 "-o$target{build_file}" $sources > "$script"
567a9e6f 1107 chmod a+x $script
0ad1d94d
RL
1108EOF
1109 }
1110 sub generatedir {
1111 my %args = @_;
1112 my $dir = $args{dir};
1113 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1114 my @actions = ();
1115 my %extinfo = ( dso => $dsoext,
1116 lib => $libext,
1117 bin => $exeext );
1118
1119 foreach my $type (("dso", "lib", "bin", "script")) {
1120 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
850000aa
RL
1121 # For lib object files, we could update the library. However, it
1122 # was decided that it's enough to build the directory local object
1123 # files, so we don't need to add any actions, and the dependencies
1124 # are already taken care of.
1125 if ($type ne "lib") {
0ad1d94d
RL
1126 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1127 if (dirname($prod) eq $dir) {
1128 push @deps, $prod.$extinfo{$type};
1129 } else {
1130 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1131 }
1132 }
1133 }
1134 }
1135
1136 my $deps = join(" ", @deps);
1137 my $actions = join("\n", "", @actions);
1138 return <<"EOF";
1139$args{dir} $args{dir}/: $deps$actions
567a9e6f
RL
1140EOF
1141 }
1142 "" # Important! This becomes part of the template result.
1143-}