]> git.ipfire.org Git - thirdparty/openssl.git/blame - Configurations/unix-Makefile.tmpl
Processing GNU-style "make variables" - separate CPP flags from C flags
[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
RL
187CPPFLAGS={- our $cppflags = join(" ",
188 (map { "-D".$_}
189 @{$target{defines}}, @{$config{defines}}),
190 (map { "-I".$_}
191 @{$target{includes}}, @{$config{includes}}),
192 $target{cppflags}, $config{cppflags}) -}
193CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -}
567a9e6f 194CC= $(CROSS_COMPILE){- $target{cc} -}
8c3bc594 195CFLAGS={- $target{cflags} -} {- $config{cflags} -}
7763472f 196CXX= $(CROSS_COMPILE){- $target{cxx} -}
8c3bc594 197CXXFLAGS={- $target{cxxflags} -} {- $config{cxxflags} -} -std=c++11
47eeaf45 198LDFLAGS= {- $config{lflags} -} {- $target{lflags} -}
940a09ba 199PLIB_LDFLAGS= {- $target{plib_lflags} -}
2952b9b8 200EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
8c3bc594
RL
201LIB_CPPFLAGS={- join(" ",
202 (map { "-D".$_}
203 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
204 'ENGINESDIR="\"$(ENGINESDIR)\""'),
205 $target{shared_cppflag} || "") -}
bbd9a50f 206LIB_CFLAGS={- $target{shared_cflag} || "" -}
7763472f 207LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -}
075f7e2c 208LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -}
8c3bc594 209DSO_CPPFLAGS={- $target{dso_cppflags} || "" -}
793077d0
RL
210DSO_CFLAGS={- $target{dso_cflags} || "" -}
211DSO_CXXFLAGS={- $target{dso_cxxflags} || "" -}
212DSO_LDFLAGS={- $target{dso_lflags} || "" -}
8c3bc594 213BIN_CPPFLAGS={- $target{bin_cppflags} || "" -}
793077d0
RL
214BIN_CFLAGS={- $target{bin_cflags} || "" -}
215BIN_CXXFLAGS={- $target{bin_cxxflags} || "" -}
216BIN_LDFLAGS={- $target{bin_lflags} || "" -}
567a9e6f
RL
217
218PERL={- $config{perl} -}
219
220ARFLAGS= {- $target{arflags} -}
221AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
222RANLIB= {- $target{ranlib} -}
223NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
8f41ff2d
RL
224RCFLAGS={- $target{shared_rcflag} -}
225RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
567a9e6f 226RM= rm -f
98e5534e 227RMDIR= rmdir
567a9e6f
RL
228TAR= {- $target{tar} || "tar" -}
229TARFLAGS= {- $target{tarflags} -}
29eed3dd 230MAKEDEPEND={- $config{makedepprog} -}
567a9e6f
RL
231
232BASENAME= openssl
233NAME= $(BASENAME)-$(VERSION)
234TARFILE= ../$(NAME).tar
235
236# We let the C compiler driver to take care of .s files. This is done in
237# order to be excused from maintaining a separate set of architecture
238# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
239# gcc, then the driver will automatically translate it to -xarch=v8plus
240# and pass it down to assembler.
241AS=$(CC) -c
242ASFLAG=$(CFLAGS)
243PERLASM_SCHEME= {- $target{perlasm_scheme} -}
244
245# For x86 assembler: Set PROCESSOR to 386 if you want to support
246# the 80386.
247PROCESSOR= {- $config{processor} -}
248
9c7ce40b
AP
249# We want error [and other] messages in English. Trouble is that make(1)
250# doesn't pass macros down as environment variables unless there already
251# was corresponding variable originally set. In other words we can only
252# reassign environment variables, but not set new ones, not in portable
253# manner that is. That's why we reassign several, just to be sure...
254LC_ALL=C
255LC_MESSAGES=C
256LANG=C
257
567a9e6f
RL
258# The main targets ###################################################
259
1e3d16b0 260{- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
27c40a93
BL
261{- dependmagic('build_libs'); -}: build_libs_nodep
262{- dependmagic('build_engines'); -}: build_engines_nodep
1e3d16b0 263{- dependmagic('build_programs'); -}: build_programs_nodep
567a9e6f 264
27c40a93 265build_generated: $(GENERATED_MANDATORY)
c058fcd7 266build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
c058fcd7 267build_engines_nodep: $(ENGINES)
1e3d16b0
RL
268build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
269
270# Kept around for backward compatibility
271build_apps build_tests: build_programs
68a5f1a2 272
9b03b91b
RL
273# Convenience target to prebuild all generated files, not just the mandatory
274# ones
275build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
276
1b741653 277test: tests
1e3d16b0 278{- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
d90a6beb 279 @ : {- output_off() if $disabled{tests}; "" -}
567a9e6f 280 ( cd test; \
41f571e1 281 mkdir -p test-runs; \
567a9e6f
RL
282 SRCTOP=../$(SRCDIR) \
283 BLDTOP=../$(BLDDIR) \
41f571e1 284 RESULT_D=test-runs \
cbece220 285 PERL="$(PERL)" \
834aae2a 286 EXE_EXT={- $exeext -} \
41f571e1 287 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines; pwd` \
6d4bc8a3 288 OPENSSL_DEBUG_MEMORY=on \
567a9e6f 289 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
d90a6beb
MC
290 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
291 @echo "Tests are not supported with your chosen Configure options"
292 @ : {- output_on() if !$disabled{tests}; "" -}
567a9e6f
RL
293
294list-tests:
4813ad2d
RL
295 @ : {- output_off() if $disabled{tests}; "" -}
296 @SRCTOP="$(SRCDIR)" \
297 $(PERL) $(SRCDIR)/test/run_tests.pl list
298 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
299 @echo "Tests are not supported with your chosen Configure options"
300 @ : {- output_on() if !$disabled{tests}; "" -}
301
302install: install_sw install_ssldirs install_docs
303
304uninstall: uninstall_docs uninstall_sw
567a9e6f
RL
305
306libclean:
f99f91f1
RL
307 @set -e; for s in $(SHLIB_INFO); do \
308 s1=`echo "$$s" | cut -f1 -d";"`; \
309 s2=`echo "$$s" | cut -f2 -d";"`; \
5407338a 310 $(ECHO) $(RM) $$s1; \
f99f91f1
RL
311 $(RM) $$s1; \
312 if [ "$$s1" != "$$s2" ]; then \
5407338a 313 $(ECHO) $(RM) $$s2; \
f99f91f1
RL
314 $(RM) $$s2; \
315 fi; \
316 done
317 $(RM) $(LIBS)
4813ad2d 318 $(RM) *.map
567a9e6f
RL
319
320clean: libclean
4813ad2d
RL
321 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
322 $(RM) $(GENERATED)
323 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
324 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
325 $(RM) core
9e183d22 326 $(RM) tags TAGS doc-nits
d016d1ec 327 $(RM) -r test/test-runs
4813ad2d
RL
328 $(RM) openssl.pc libcrypto.pc libssl.pc
329 -$(RM) `find . -type l -a \! -path "./.git/*"`
330 $(RM) $(TARFILE)
567a9e6f 331
7cae3864 332distclean: clean
4813ad2d
RL
333 $(RM) configdata.pm
334 $(RM) Makefile
7cae3864 335
f8d9d6e4 336# We check if any depfile is newer than Makefile and decide to
a6adf099 337# concatenate only if that is true.
ea80a25e 338depend:
29eed3dd 339 @: {- output_off() if $disabled{makedepend}; "" -}
d423c5ad 340 @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
ebca7961 341 ( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
f8d9d6e4
RL
342 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
343 echo; \
a6adf099
RL
344 for f in $(DEPS); do \
345 if [ -f $$f ]; then cat $$f; fi; \
f8d9d6e4 346 done ) > Makefile.new; \
29b28eee 347 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
f8d9d6e4 348 rm -f Makefile.new; \
29b28eee
RL
349 else \
350 mv -f Makefile.new Makefile; \
f8d9d6e4 351 fi; \
c058fcd7 352 fi
29eed3dd 353 @: {- output_on() if $disabled{makedepend}; "" -}
567a9e6f
RL
354
355# Install helper targets #############################################
356
357install_sw: all install_dev install_engines install_runtime
358
f99f91f1 359uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
567a9e6f
RL
360
361install_docs: install_man_docs install_html_docs
362
363uninstall_docs: uninstall_man_docs uninstall_html_docs
8be7bdb5 364 $(RM) -r -v $(DESTDIR)$(DOCDIR)
567a9e6f 365
dde10ab4
RL
366install_ssldirs:
367 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
368 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
66c2eb8b 369 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
4813ad2d
RL
370 @set -e; for x in dummy $(MISC_SCRIPTS); do \
371 if [ "$$x" = "dummy" ]; then continue; fi; \
372 fn=`basename $$x`; \
5407338a 373 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
4813ad2d
RL
374 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
375 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
376 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
377 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
378 done
5407338a 379 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
4813ad2d
RL
380 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
381 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
cb926df2 382 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
c7af65c7 383 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
5407338a 384 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
cb926df2
RL
385 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
386 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
387 fi
5407338a 388 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
c7af65c7
RS
389 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
390 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
391 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
392 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
5407338a 393 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
c7af65c7
RS
394 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
395 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
396 fi
dde10ab4 397
567a9e6f
RL
398install_dev:
399 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 400 @$(ECHO) "*** Installing development files"
3c65577f 401 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
24c4f736 402 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
5407338a 403 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
24c4f736
RL
404 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
405 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
406 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
567a9e6f
RL
407 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
408 $(BLDDIR)/include/openssl/*.h; do \
409 fn=`basename $$i`; \
5407338a 410 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
3c65577f
RL
411 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
412 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 413 done
3c65577f 414 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
0f01b7bc 415 @set -e; for l in $(INSTALL_LIBS); do \
567a9e6f 416 fn=`basename $$l`; \
5407338a 417 $(ECHO) "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
3c65577f
RL
418 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
419 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
420 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
421 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
422 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
567a9e6f 423 done
84af1bae 424 @ : {- output_off() if $disabled{shared}; "" -}
0f01b7bc 425 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
c8c2b779
RL
426 s1=`echo "$$s" | cut -f1 -d";"`; \
427 s2=`echo "$$s" | cut -f2 -d";"`; \
428 fn1=`basename $$s1`; \
429 fn2=`basename $$s2`; \
430 : {- output_off() if windowsdll(); "" -}; \
5407338a 431 $(ECHO) "install $$s1 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
c8c2b779 432 cp $$s1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
3503549e 433 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
c8c2b779
RL
434 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new \
435 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
436 if [ "$$fn1" != "$$fn2" ]; then \
5407338a 437 $(ECHO) "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
c8c2b779 438 ln -sf $$fn1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
567a9e6f 439 fi; \
c8c2b779 440 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
5407338a 441 $(ECHO) "install $$s2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
c8c2b779 442 cp $$s2 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
3503549e 443 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
c8c2b779
RL
444 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new \
445 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
ce5ed82f 446 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 447 done
84af1bae 448 @ : {- output_on() if $disabled{shared}; "" -}
3c65577f 449 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
5407338a 450 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
3c65577f
RL
451 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
452 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
5407338a 453 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
3c65577f
RL
454 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
455 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
5407338a 456 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
3c65577f
RL
457 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
458 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
567a9e6f
RL
459
460uninstall_dev:
5407338a 461 @$(ECHO) "*** Uninstalling development files"
24c4f736 462 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
5407338a 463 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
24c4f736
RL
464 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
465 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
567a9e6f
RL
466 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
467 $(BLDDIR)/include/openssl/*.h; do \
468 fn=`basename $$i`; \
5407338a 469 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
3c65577f 470 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 471 done
98e5534e
RL
472 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
473 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
0f01b7bc 474 @set -e; for l in $(INSTALL_LIBS); do \
567a9e6f 475 fn=`basename $$l`; \
5407338a 476 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
3c65577f 477 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
567a9e6f 478 done
84af1bae 479 @ : {- output_off() if $disabled{shared}; "" -}
0f01b7bc 480 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
c8c2b779
RL
481 s1=`echo "$$s" | cut -f1 -d";"`; \
482 s2=`echo "$$s" | cut -f2 -d";"`; \
483 fn1=`basename $$s1`; \
484 fn2=`basename $$s2`; \
485 : {- output_off() if windowsdll(); "" -}; \
5407338a 486 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
c8c2b779
RL
487 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
488 if [ "$$fn1" != "$$fn2" ]; then \
5407338a 489 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
3c65577f 490 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
567a9e6f 491 fi; \
c8c2b779 492 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
5407338a 493 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
c8c2b779 494 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
ce5ed82f 495 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 496 done
c8cca980 497 @ : {- output_on() if $disabled{shared}; "" -}
b894054e
RL
498 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
499 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
500 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
501 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
502 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
567a9e6f
RL
503
504install_engines:
505 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
b2de11c5 506 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
5407338a 507 @$(ECHO) "*** Installing engines"
0f01b7bc 508 @set -e; for e in dummy $(INSTALL_ENGINES); do \
2b364f61 509 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 510 fn=`basename $$e`; \
5407338a 511 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
b2de11c5
RL
512 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
513 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
514 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
515 $(DESTDIR)$(ENGINESDIR)/$$fn; \
567a9e6f
RL
516 done
517
518uninstall_engines:
5407338a 519 @$(ECHO) "*** Uninstalling engines"
0f01b7bc 520 @set -e; for e in dummy $(INSTALL_ENGINES); do \
2b364f61 521 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 522 fn=`basename $$e`; \
f0c93a85
RL
523 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
524 continue; \
525 fi; \
5407338a 526 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
b2de11c5 527 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
567a9e6f 528 done
b2de11c5 529 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
567a9e6f
RL
530
531install_runtime:
532 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
3c65577f 533 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
36b53720
RL
534 @ : {- output_off() if windowsdll(); "" -}
535 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
536 @ : {- output_on() if windowsdll(); "" -}
5407338a 537 @$(ECHO) "*** Installing runtime files"
0f01b7bc 538 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
2b364f61 539 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 540 fn=`basename $$s`; \
36b53720 541 : {- output_off() unless windowsdll(); "" -}; \
5407338a 542 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
543 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
544 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
545 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
546 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
36b53720 547 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
5407338a 548 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
36b53720
RL
549 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
550 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
551 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
552 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
553 : {- output_on() if windowsdll(); "" -}; \
fcf80c46 554 done
0f01b7bc 555 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
2b364f61 556 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 557 fn=`basename $$x`; \
5407338a 558 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
559 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
560 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
561 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
562 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 563 done
2b364f61
RL
564 @set -e; for x in dummy $(BIN_SCRIPTS); do \
565 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 566 fn=`basename $$x`; \
5407338a 567 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
568 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
569 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
570 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
571 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 572 done
567a9e6f
RL
573
574uninstall_runtime:
5407338a 575 @$(ECHO) "*** Uninstalling runtime files"
0f01b7bc 576 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
567a9e6f 577 do \
2b364f61 578 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 579 fn=`basename $$x`; \
5407338a 580 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 581 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 582 done;
2b364f61 583 @set -e; for x in dummy $(BIN_SCRIPTS); \
567a9e6f 584 do \
2b364f61 585 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 586 fn=`basename $$x`; \
5407338a 587 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 588 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 589 done
b1837abd 590 @ : {- output_off() unless windowsdll(); "" -}
0f01b7bc 591 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
2b364f61 592 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 593 fn=`basename $$s`; \
5407338a 594 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 595 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
fcf80c46 596 done
b1837abd 597 @ : {- output_on() unless windowsdll(); "" -}
b894054e 598 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
567a9e6f 599
567a9e6f
RL
600
601install_man_docs:
602 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 603 @$(ECHO) "*** Installing manpages"
cadb015b
RL
604 $(PERL) $(SRCDIR)/util/process_docs.pl \
605 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
567a9e6f
RL
606
607uninstall_man_docs:
5407338a 608 @$(ECHO) "*** Uninstalling manpages"
cadb015b
RL
609 $(PERL) $(SRCDIR)/util/process_docs.pl \
610 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
611 --remove
567a9e6f
RL
612
613install_html_docs:
614 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 615 @$(ECHO) "*** Installing HTML manpages"
cadb015b
RL
616 $(PERL) $(SRCDIR)/util/process_docs.pl \
617 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
567a9e6f
RL
618
619uninstall_html_docs:
5407338a 620 @$(ECHO) "*** Uninstalling manpages"
cadb015b
RL
621 $(PERL) $(SRCDIR)/util/process_docs.pl \
622 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
567a9e6f
RL
623
624
625# Developer targets (note: these are only available on Unix) #########
626
6bb2106e
RL
627update: generate errors ordinals
628
b7650c67 629generate: generate_apps generate_crypto_bn generate_crypto_objects \
8e32e1ab 630 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
567a9e6f 631
65c1f979 632doc-nits:
1722496f 633 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
9e183d22 634 if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
65c1f979 635
567a9e6f
RL
636# Test coverage is a good idea for the future
637#coverage: $(PROGRAMS) $(TESTPROGRAMS)
638# ...
639
567a9e6f
RL
640lint:
641 lint -DLINT $(INCLUDES) $(SRCS)
642
9a9f8ee7
RL
643generate_apps:
644 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
645 < apps/openssl.cnf > apps/openssl-vms.cnf )
9a9f8ee7
RL
646
647generate_crypto_bn:
648 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
649
650generate_crypto_objects:
9a9f8ee7
RL
651 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
652 crypto/objects/objects.txt \
653 crypto/objects/obj_mac.num \
654 include/openssl/obj_mac.h )
e6f2bb66
KM
655 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
656 include/openssl/obj_mac.h \
657 crypto/objects/obj_dat.h )
9a9f8ee7
RL
658 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
659 crypto/objects/obj_mac.num \
660 crypto/objects/obj_xref.txt \
661 > crypto/objects/obj_xref.h )
6bb2106e 662
b7650c67
RL
663generate_crypto_conf:
664 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
665 > crypto/conf/conf_def.h )
666
667generate_crypto_asn1:
668 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
669 > crypto/asn1/charmap.h )
670
8e32e1ab
RL
671generate_fuzz_oids:
672 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
673 crypto/objects/obj_dat.h \
674 > fuzz/oids.txt )
675
52df25cf
RS
676# Set to -force to force a rebuild
677ERROR_REBUILD=
567a9e6f
RL
678errors:
679 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
52df25cf 680 ( cd $(SRCDIR); $(PERL) util/mkerr.pl $(ERROR_REBUILD) -internal )
567a9e6f 681 ( cd $(SRCDIR)/engines; \
52df25cf
RS
682 for E in *.ec ; do \
683 $(PERL) ../util/mkerr.pl $(ERROR_REBUILD) -static \
684 -conf $$E `basename $$E .ec`.c ; \
685 done )
567a9e6f
RL
686
687ordinals:
688 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
689 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
690
691test_ordinals:
692 ( cd test; \
693 SRCTOP=../$(SRCDIR) \
694 BLDTOP=../$(BLDDIR) \
695 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
696
697tags TAGS: FORCE
698 rm -f TAGS tags
699 -ctags -R .
700 -etags `find . -name '*.[ch]' -o -name '*.pm'`
701
702# Release targets (note: only available on Unix) #####################
703
77a9c26e
RL
704# If your tar command doesn't support --owner and --group, make sure to
705# use one that does, for example GNU tar
a1bce642 706TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
54bb8f74 707PREPARE_CMD=:
567a9e6f 708tar:
34a5b7d7 709 set -e; \
567a9e6f 710 TMPDIR=/var/tmp/openssl-copy.$$$$; \
54bb8f74 711 DISTDIR=$(NAME); \
567a9e6f
RL
712 mkdir -p $$TMPDIR/$$DISTDIR; \
713 (cd $(SRCDIR); \
5b7b0115
RL
714 excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
715 excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
716 echo "$$excl_re"; \
567a9e6f 717 git ls-tree -r --name-only --full-tree HEAD \
17c84aa7 718 | egrep -v "$$excl_re" \
567a9e6f
RL
719 | while read F; do \
720 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
721 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
722 done); \
17c84aa7 723 (cd $$TMPDIR/$$DISTDIR; \
54bb8f74 724 $(PREPARE_CMD); \
17c84aa7
RL
725 find . -type d -print | xargs chmod 755; \
726 find . -type f -print | xargs chmod a+r; \
727 find . -type f -perm -0100 -print | xargs chmod a+x); \
728 (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
567a9e6f
RL
729 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
730 rm -rf $$TMPDIR
731 cd $(SRCDIR); ls -l $(TARFILE).gz
732
733dist:
bffa1ff8 734 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
567a9e6f
RL
735
736# Helper targets #####################################################
737
342a1a23 738link-utils: $(BLDDIR)/util/opensslwrap.sh
567a9e6f 739
27f42b46 740$(BLDDIR)/util/opensslwrap.sh: configdata.pm
567a9e6f
RL
741 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
742 mkdir -p "$(BLDDIR)/util"; \
743 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
744 fi
342a1a23 745
c058fcd7 746FORCE:
567a9e6f
RL
747
748# Building targets ###################################################
749
8478a703 750libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
567a9e6f
RL
751libcrypto.pc:
752 @ ( echo 'prefix=$(INSTALLTOP)'; \
753 echo 'exec_prefix=$${prefix}'; \
754 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
755 echo 'includedir=$${prefix}/include'; \
d4453024 756 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
567a9e6f
RL
757 echo ''; \
758 echo 'Name: OpenSSL-libcrypto'; \
759 echo 'Description: OpenSSL cryptography library'; \
760 echo 'Version: '$(VERSION); \
761 echo 'Libs: -L$${libdir} -lcrypto'; \
762 echo 'Libs.private: $(EX_LIBS)'; \
763 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
764
765libssl.pc:
766 @ ( echo 'prefix=$(INSTALLTOP)'; \
767 echo 'exec_prefix=$${prefix}'; \
768 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
769 echo 'includedir=$${prefix}/include'; \
770 echo ''; \
771 echo 'Name: OpenSSL-libssl'; \
772 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
773 echo 'Version: '$(VERSION); \
774 echo 'Requires.private: libcrypto'; \
775 echo 'Libs: -L$${libdir} -lssl'; \
567a9e6f
RL
776 echo 'Cflags: -I$${includedir}' ) > libssl.pc
777
778openssl.pc:
779 @ ( echo 'prefix=$(INSTALLTOP)'; \
780 echo 'exec_prefix=$${prefix}'; \
781 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
782 echo 'includedir=$${prefix}/include'; \
783 echo ''; \
784 echo 'Name: OpenSSL'; \
785 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
786 echo 'Version: '$(VERSION); \
787 echo 'Requires: libssl libcrypto' ) > openssl.pc
788
41240e68 789configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
27f42b46 790 @echo "Detected changed: $?"
567a9e6f 791 @echo "Reconfiguring..."
12ccb021 792 $(PERL) $(SRCDIR)/Configure reconf
567a9e6f
RL
793 @echo "**************************************************"
794 @echo "*** ***"
795 @echo "*** Please run the same make command again ***"
796 @echo "*** ***"
797 @echo "**************************************************"
798 @false
799
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; \\
8c3bc594 860 \$(CC) $incs \$(CFLAGS) \$(CPPFLAGS) -E \$@.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
8c3bc594 873 \$(CC) $incs \$(CFLAGS) \$(CPPFLAGS) -E $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}});
da430a55
RL
894 unless ($disabled{zlib}) {
895 if ($withargs{zlib_include}) {
896 $incs .= " -I".$withargs{zlib_include};
897 }
898 }
81183680 899 my $cmd = '$(CC)';
8c3bc594
RL
900 my $cmdflags = '$(CFLAGS)';
901 my $cmdcompile = ' -c';
81183680
RL
902 my $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
903 if (grep /\.rc$/, @srcs) {
904 $cmd = '$(RC)';
905 $cmdflags = '$(RCFLAGS)';
8c3bc594 906 $cmdcompile = '';
81183680
RL
907 $makedepprog = undef;
908 } elsif (grep /\.(cc|cpp)$/, @srcs) {
909 $cmd = '$(CXX)';
8c3bc594 910 $cmdflags = '$(CXXFLAGS)';
81183680
RL
911 $cmdflags .= ' ' . { lib => '$(LIB_CXXFLAGS)',
912 dso => '$(DSO_CXXFLAGS)',
913 bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}};
8c3bc594
RL
914 $cmdflags .= ' $(CPPFLAGS)';
915 $cmdflags .= ' ' . { lib => '$(LIB_CPPFLAGS)',
916 dso => '$(DSO_CPPFLAGS)',
917 bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
7763472f 918 } else {
81183680
RL
919 $cmdflags .= ' ' . { lib => '$(LIB_CFLAGS)',
920 dso => '$(DSO_CFLAGS)',
921 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
8c3bc594
RL
922 $cmdflags .= ' $(CPPFLAGS)';
923 $cmdflags .= ' ' . { lib => '$(LIB_CPPFLAGS)',
924 dso => '$(DSO_CPPFLAGS)',
925 bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
7763472f 926 }
8c3bc594 927 $cmdflags .= $cmdcompile;
7e5b8b93
RL
928 my $recipe = <<"EOF";
929$obj$objext: $deps
930EOF
81183680 931 if (defined $makedepprog && $makedepprog !~ /\/makedepend/) {
29eed3dd 932 $recipe .= <<"EOF";
81183680 933 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
7e5b8b93
RL
934 \@touch $obj$depext.tmp
935 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
936 rm -f $obj$depext.tmp; \\
29b28eee 937 else \\
7e5b8b93 938 mv $obj$depext.tmp $obj$depext; \\
987dbc7f 939 fi
29eed3dd 940EOF
7e5b8b93 941 } else {
29eed3dd 942 $recipe .= <<"EOF";
81183680 943 $cmd $incs $cmdflags -o \$\@ $srcs
567a9e6f 944EOF
81183680 945 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
7e5b8b93 946 $recipe .= <<"EOF";
81183680 947 -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cmdflags -- $srcs \\
7e5b8b93
RL
948 >$obj$depext.tmp 2>/dev/null
949 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
29b28eee 950 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
987dbc7f 951 rm -f $obj$depext.tmp; \\
29b28eee
RL
952 else \\
953 mv $obj$depext.tmp $obj$depext; \\
340da949 954 fi
567a9e6f 955EOF
7e5b8b93 956 }
29eed3dd
RL
957 }
958 return $recipe;
567a9e6f
RL
959 }
960 # On Unix, we build shlibs from static libs, so we're ignoring the
961 # object file array. We *know* this routine is only called when we've
962 # configure 'shared'.
963 sub libobj2shlib {
964 my %args = @_;
965 my $lib = $args{lib};
966 my $shlib = $args{shlib};
967 my $libd = dirname($lib);
968 my $libn = basename($lib);
969 (my $libname = $libn) =~ s/^lib//;
47eeaf45
RL
970 my @linkdirs = ();
971 foreach (@{args{deps}}) {
972 my $d = dirname($_);
973 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
974 }
975 my $linkflags = join("", map { "-L$_ " } @linkdirs);
976 my $linklibs = join("", map { my $f = basename($_);
cedbb146 977 (my $l = $f) =~ s/^lib//;
47eeaf45 978 " -l$l" } @{$args{deps}});
81183680
RL
979 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
980 grep { $_ =~ m|\.o$| }
981 @{$args{objs}};
982 my @defs = grep { $_ =~ /\.(def|map)$/ } @{$args{objs}};
983 my @deps = compute_lib_depends(@{$args{deps}});
984 die "More than one exported symbol map" if scalar @defs > 1;
985 my $objs = join(" ", @objs);
986 my $deps = join(" ", @objs, @defs, @deps);
f5c174ff 987 my $target = shlib_simple($lib);
d07abe13 988 my $target_full = shlib($lib);
81183680
RL
989 my $shared_soname = "";
990 $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
991 if defined $target{shared_sonameflag};
992 my $shared_imp = "";
993 $shared_imp .= ' '.$target{shared_impflag}.basename($target)
994 if defined $target{shared_impflag};
995 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
996 my $recipe = <<"EOF";
997# When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
cedbb146
RL
998# that two files get produced, {shlibname}.dll and {libname}.dll.a.
999# With all other Unix platforms, we often build a shared library with the
1000# SO version built into the file name and a symlink without the SO version
1001# It's not necessary to have both as targets. The choice falls on the
d4453024
RL
1002# simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
1003# {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
81183680 1004$target: $deps
47eeaf45 1005 \$(CC) \$(CFLAGS) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
81183680
RL
1006 -o $target_full$shared_def $objs \\
1007 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
fcf80c46 1008EOF
81183680
RL
1009 if (windowsdll()) {
1010 $recipe .= <<"EOF";
d4453024
RL
1011 rm -f apps/$shlib'\$(SHLIB_EXT)'
1012 rm -f test/$shlib'\$(SHLIB_EXT)'
81183680 1013 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
d4453024
RL
1014 cp -p $shlib'\$(SHLIB_EXT)' apps/
1015 cp -p $shlib'\$(SHLIB_EXT)' test/
81183680
RL
1016 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1017EOF
1018 } else {
1019 $recipe .= <<"EOF";
50625bf5
RL
1020 if [ '$target' != '$target_full' ]; then \\
1021 rm -f $target; \\
1022 ln -s $target_full $target; \\
1023 fi
567a9e6f 1024EOF
81183680 1025 }
567a9e6f 1026 }
5386287c 1027 sub obj2dso {
567a9e6f 1028 my %args = @_;
d07abe13
RL
1029 my $dso = $args{lib};
1030 my $dsod = dirname($dso);
1031 my $dson = basename($dso);
47eeaf45
RL
1032 my @linkdirs = ();
1033 foreach (@{args{deps}}) {
1034 my $d = dirname($_);
1035 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1036 }
1037 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1038 my $linklibs = join("", map { my $f = basename($_);
81183680 1039 (my $l = $f) =~ s/^lib//;
47eeaf45 1040 " -l$l" } @{$args{deps}});
81183680
RL
1041 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1042 my @deps = compute_lib_depends(@{$args{deps}});
1043 my $objs = join(" ", @objs);
1044 my $deps = join(" ", @deps);
d07abe13 1045 my $target = dso($dso);
567a9e6f 1046 return <<"EOF";
f5c174ff 1047$target: $objs $deps
47eeaf45 1048 \$(CC) \$(CFLAGS) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
81183680
RL
1049 -o $target $objs \\
1050 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
567a9e6f
RL
1051EOF
1052 }
1053 sub obj2lib {
1054 my %args = @_;
33105818 1055 (my $lib = $args{lib}) =~ s/\.a$//;
81183680
RL
1056 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1057 my $objs = join(" ", @objs);
567a9e6f 1058 return <<"EOF";
834aae2a 1059$lib$libext: $objs
68cd4e3f 1060 \$(AR) \$\@ \$\?
567a9e6f
RL
1061 \$(RANLIB) \$\@ || echo Never mind.
1062EOF
1063 }
1064 sub obj2bin {
1065 my %args = @_;
1066 my $bin = $args{bin};
1067 my $bind = dirname($bin);
1068 my $binn = basename($bin);
81183680
RL
1069 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$|$objext|; $x }
1070 @{$args{objs}});
cedbb146 1071 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
47eeaf45
RL
1072 my @linkdirs = ();
1073 foreach (@{args{deps}}) {
1074 next if $_ =~ /\.a$/;
1075 my $d = dirname($_);
1076 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1077 }
1078 my $linkflags = join("", map { "-L$_ " } @linkdirs);
186a31e5
RL
1079 my $linklibs = join("", map { if ($_ =~ /\.a$/) {
1080 " $_";
1081 } else {
186a31e5 1082 my $f = basename($_);
186a31e5 1083 (my $l = $f) =~ s/^lib//;
47eeaf45 1084 " -l$l"
186a31e5
RL
1085 }
1086 } @{$args{deps}});
81183680
RL
1087 my $cmd = '$(CC)';
1088 my $cmdflags = '$(CFLAGS) $(BIN_CFLAGS)';
1089 if (grep /_cc\.o$/, @{$args{objs}}) {
1090 $cmd = '$(CXX)';
1091 $cmdflags = '$(CXXFLAGS) $(BIN_CXXFLAGS)';
7763472f 1092 }
567a9e6f 1093 return <<"EOF";
834aae2a 1094$bin$exeext: $objs $deps
81183680 1095 rm -f $bin$exeext
47eeaf45
RL
1096 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(LDFLAGS) \$(BIN_LDFLAGS) \\
1097 -o $bin$exeext $objs \\
81183680 1098 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
567a9e6f
RL
1099EOF
1100 }
1101 sub in2script {
1102 my %args = @_;
1103 my $script = $args{script};
1104 my $sources = join(" ", @{$args{sources}});
1105 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1106 "util", "dofile.pl")),
1107 rel2abs($config{builddir}));
1108 return <<"EOF";
88297284 1109$script: $sources
4b799cea 1110 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
ba327ade 1111 "-o$target{build_file}" $sources > "$script"
567a9e6f 1112 chmod a+x $script
0ad1d94d
RL
1113EOF
1114 }
1115 sub generatedir {
1116 my %args = @_;
1117 my $dir = $args{dir};
1118 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1119 my @actions = ();
1120 my %extinfo = ( dso => $dsoext,
1121 lib => $libext,
1122 bin => $exeext );
1123
1124 foreach my $type (("dso", "lib", "bin", "script")) {
1125 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
850000aa
RL
1126 # For lib object files, we could update the library. However, it
1127 # was decided that it's enough to build the directory local object
1128 # files, so we don't need to add any actions, and the dependencies
1129 # are already taken care of.
1130 if ($type ne "lib") {
0ad1d94d
RL
1131 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1132 if (dirname($prod) eq $dir) {
1133 push @deps, $prod.$extinfo{$type};
1134 } else {
1135 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1136 }
1137 }
1138 }
1139 }
1140
1141 my $deps = join(" ", @deps);
1142 my $actions = join("\n", "", @actions);
1143 return <<"EOF";
1144$args{dir} $args{dir}/: $deps$actions
567a9e6f
RL
1145EOF
1146 }
1147 "" # Important! This becomes part of the template result.
1148-}