blob: fbe7e9a712b6f5a317b948ddb1b2ccb1aefc9327 [file] [log] [blame]
Richard Levitte567a9e62016-01-30 03:25:40 +01001##
2## Makefile for OpenSSL
3##
4## {- join("\n## ", @autowarntext) -}
5{-
Ben Laurie834aae22016-02-20 15:27:27 +00006 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";
11 our $shlibextsimple = $target{shared_extension_simple} || ".so";
12 our $shlibextimport = $target{shared_import_extension} || "";
13 our $dsoext = $target{dso_extension} || ".so";
14
Richard Levitte567a9e62016-01-30 03:25:40 +010015 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
Richard Levittef5c174f2016-02-15 17:42:14 +010016
Richard Levitted4453022017-07-19 10:13:41 +020017 our $sover_dirname = $config{shlib_version_number};
18 $sover_dirname =~ s|\.|_|g
19 if $config{target} =~ /^mingw/;
Richard Levitteb2de11c2016-07-06 18:50:47 +020020
Richard Levittef5c174f2016-02-15 17:42:14 +010021 # shlib and shlib_simple both take a static library name and figure
22 # out what the shlib name should be.
23 #
24 # When OpenSSL is configured "no-shared", these functions will just
25 # return empty lists, making them suitable to join().
26 #
27 # With Windows DLL producers, shlib($libname) will return the shared
28 # library name (which usually is different from the static library
29 # name) with the default shared extension appended to it, while
30 # shlib_simple($libname) will return the static library name with
31 # the shared extension followed by ".a" appended to it. The former
32 # result is used as the runtime shared library while the latter is
33 # used as the DLL import library.
34 #
35 # On all Unix systems, shlib($libname) will return the library name
36 # with the default shared extension, while shlib_simple($libname)
37 # will return the name from shlib($libname) with any SO version number
38 # removed. On some systems, they may therefore return the exact same
39 # string.
40 sub shlib {
Richard Levittef5c174f2016-02-15 17:42:14 +010041 my $lib = shift;
Richard Levitte33105812017-04-18 16:24:23 +020042 return () if $disabled{shared} || $lib =~ /\.a$/;
Richard Levitted4453022017-07-19 10:13:41 +020043 return $unified_info{sharednames}->{$lib} . '$(SHLIB_EXT)';
Richard Levittef5c174f2016-02-15 17:42:14 +010044 }
45 sub shlib_simple {
Richard Levittef5c174f2016-02-15 17:42:14 +010046 my $lib = shift;
Richard Levitte33105812017-04-18 16:24:23 +020047 return () if $disabled{shared} || $lib =~ /\.a$/;
48
Richard Levittef5c174f2016-02-15 17:42:14 +010049 if (windowsdll()) {
Richard Levitted4453022017-07-19 10:13:41 +020050 return $lib . '$(SHLIB_EXT_IMPORT)';
Richard Levittef5c174f2016-02-15 17:42:14 +010051 }
Richard Levitted4453022017-07-19 10:13:41 +020052 return $lib . '$(SHLIB_EXT_SIMPLE)';
Richard Levittef5c174f2016-02-15 17:42:14 +010053 }
54
Richard Levitte33105812017-04-18 16:24:23 +020055 # Easy fixing of static library names
56 sub lib {
57 (my $lib = shift) =~ s/\.a$//;
58 return $lib . $libext;
59 }
60
Richard Levittef5c174f2016-02-15 17:42:14 +010061 # dso is a complement to shlib / shlib_simple that returns the
62 # given libname with the simple shared extension (possible SO version
63 # removed). This differs from shlib_simple() by being unconditional.
64 sub dso {
Richard Levittef5c174f2016-02-15 17:42:14 +010065 my $engine = shift;
66
Ben Laurie834aae22016-02-20 15:27:27 +000067 return $engine . $dsoext;
Richard Levittef5c174f2016-02-15 17:42:14 +010068 }
Ben Laurie27c40a92016-06-26 13:09:23 +010069 # This makes sure things get built in the order they need
70 # to. You're welcome.
71 sub dependmagic {
72 my $target = shift;
73
74 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
75 }
Ben Laurie834aae22016-02-20 15:27:27 +000076 '';
Richard Levitte567a9e62016-01-30 03:25:40 +010077-}
78PLATFORM={- $config{target} -}
79OPTIONS={- $config{options} -}
80CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
81SRCDIR={- $config{sourcedir} -}
82BLDDIR={- $config{builddir} -}
83
84VERSION={- $config{version} -}
85MAJOR={- $config{major} -}
86MINOR={- $config{minor} -}
87SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
88SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
89SHLIB_MAJOR={- $config{shlib_major} -}
90SHLIB_MINOR={- $config{shlib_minor} -}
91SHLIB_TARGET={- $target{shared_target} -}
Richard Levitted4453022017-07-19 10:13:41 +020092SHLIB_EXT={- $shlibext -}
93SHLIB_EXT_SIMPLE={- $shlibextsimple -}
94SHLIB_EXT_IMPORT={- $shlibextimport -}
Richard Levitte567a9e62016-01-30 03:25:40 +010095
Richard Levitte33105812017-04-18 16:24:23 +020096LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
Richard Levittef5c174f2016-02-15 17:42:14 +010097SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
Richard Levitte0f01b7b2016-07-08 14:52:09 +020098SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
Richard Levittef5c174f2016-02-15 17:42:14 +010099ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
Richard Levitte1e3d16b2016-07-08 17:58:36 +0200100PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100101SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
Richard Levitte29eed3d2016-03-09 01:17:27 +0100102{- output_off() if $disabled{makedepend}; "" -}
Ben Laurie834aae22016-02-20 15:27:27 +0000103DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
Richard Levittec058fcd2016-02-18 19:41:57 +0100104 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
105 keys %{$unified_info{sources}}); -}
Richard Levitte29eed3d2016-03-09 01:17:27 +0100106{- output_on() if $disabled{makedepend}; "" -}
Richard Levitte7cae3862016-06-13 22:02:11 +0200107GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
Richard Levitte05a7aee2016-05-16 14:54:39 +0200108GENERATED={- join(" ",
109 ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
110 grep { defined $unified_info{generate}->{$_} }
111 map { @{$unified_info{sources}->{$_}} }
112 grep { /\.o$/ } keys %{$unified_info{sources}} ),
113 ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -}
Richard Levittec058fcd2016-02-18 19:41:57 +0100114
Richard Levitte33105812017-04-18 16:24:23 +0200115INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200116INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
117INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
118INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
119INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
Richard Levittedf653372016-04-14 16:04:56 +0100120{- output_off() if $disabled{apps}; "" -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100121BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
Rich Salzb8a9af62016-05-20 16:16:07 -0400122MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
Richard Levittedf653372016-04-14 16:04:56 +0100123{- output_on() if $disabled{apps}; "" -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100124
Richard Levitte6a748062017-06-15 19:31:01 +0200125APPS_OPENSSL={- use File::Spec::Functions;
126 catfile("apps","openssl") -}
127
Richard Levitte3c655772016-02-12 21:14:03 +0100128# DESTDIR is for package builders so that they can configure for, say,
129# /usr/ and yet have everything installed to /tmp/somedir/usr/.
Richard Levitte567a9e62016-01-30 03:25:40 +0100130# Normally it is left empty.
Richard Levitte3c655772016-02-12 21:14:03 +0100131DESTDIR=
Richard Levitte567a9e62016-01-30 03:25:40 +0100132
133# Do not edit these manually. Use Configure with --prefix or --openssldir
134# to change this! Short explanation in the top comment in Configure
135INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
136 #
137 our $prefix = $config{prefix} || "/usr/local";
138 $prefix -}
139OPENSSLDIR={- #
140 # The logic here is that if no --openssldir was given,
141 # OPENSSLDIR will get the value from $prefix plus "/ssl".
142 # If --openssldir was given and the value is an absolute
143 # path, OPENSSLDIR will get its value without change.
144 # If the value from --openssldir is a relative path,
145 # OPENSSLDIR will get $prefix with the --openssldir
146 # value appended as a subdirectory.
147 #
148 use File::Spec::Functions;
149 our $openssldir =
150 $config{openssldir} ?
151 (file_name_is_absolute($config{openssldir}) ?
152 $config{openssldir}
153 : catdir($prefix, $config{openssldir}))
154 : catdir($prefix, "ssl");
155 $openssldir -}
156LIBDIR={- #
157 # if $prefix/lib$target{multilib} is not an existing
158 # directory, then assume that it's not searched by linker
159 # automatically, in which case adding $target{multilib} suffix
160 # causes more grief than we're ready to tolerate, so don't...
161 our $multilib =
162 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
163 our $libdir = $config{libdir} || "lib$multilib";
164 $libdir -}
165ENGINESDIR={- use File::Spec::Functions;
Richard Levitted4453022017-07-19 10:13:41 +0200166 catdir($prefix,$libdir,"engines-$sover_dirname") -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100167
Richard Levittefad599f2016-10-12 17:05:35 +0200168# Convenience variable for those who want to set the rpath in shared
169# libraries and applications
170LIBRPATH=$(INSTALLTOP)/$(LIBDIR)
171
Richard Levittedde10ab2016-02-13 17:55:48 +0100172MANDIR=$(INSTALLTOP)/share/man
Richard Levitte8be7bdb2016-02-19 10:38:15 +0100173DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
174HTMLDIR=$(DOCDIR)/html
Richard Levitte567a9e62016-01-30 03:25:40 +0100175
Richard Levitte35440912016-02-15 13:37:17 +0100176# MANSUFFIX is for the benefit of anyone who may want to have a suffix
177# appended after the manpage file section number. "ssl" is popular,
178# resulting in files such as config.5ssl rather than config.5.
179MANSUFFIX=
Richard Levitte567a9e62016-01-30 03:25:40 +0100180HTMLSUFFIX=html
181
Rich Salz54073382017-06-29 11:40:19 -0400182# For "optional" echo messages, to get "real" silence
183ECHO = echo
Richard Levitte567a9e62016-01-30 03:25:40 +0100184
185CROSS_COMPILE= {- $config{cross_compile_prefix} -}
186CC= $(CROSS_COMPILE){- $target{cc} -}
Richard Levitte2952b9b2016-03-02 10:57:05 +0100187CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -}
Richard Levitte076e5962016-02-10 19:09:05 +0100188CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
Richard Levitte77634722016-10-12 15:30:43 +0200189CXX= $(CROSS_COMPILE){- $target{cxx} -}
Matt Caswella60150e2016-10-14 20:32:18 +0100190CXXFLAGS={- our $cxxflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cxxflags} -} {- $config{cxxflags} -} -std=c++11
Richard Levitte940a09b2016-02-27 11:42:13 +0100191LDFLAGS= {- $target{lflags} -}
192PLIB_LDFLAGS= {- $target{plib_lflags} -}
Richard Levitte2952b9b2016-03-02 10:57:05 +0100193EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
Richard Levittebbd9a502016-03-12 09:38:20 +0100194LIB_CFLAGS={- $target{shared_cflag} || "" -}
Richard Levitte77634722016-10-12 15:30:43 +0200195LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -}
Richard Levitte075f7e22016-10-12 17:18:11 +0200196LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -}
Richard Levitte45502bf2016-02-19 22:02:41 +0100197DSO_CFLAGS={- $target{shared_cflag} || "" -}
Richard Levitte77634722016-10-12 15:30:43 +0200198DSO_CXXFLAGS={- $target{shared_cxxflag} || "" -}
Richard Levittebbd9a502016-03-12 09:38:20 +0100199DSO_LDFLAGS=$(LIB_LDFLAGS)
Andy Polyakovcba792a2016-05-01 13:35:31 +0200200BIN_CFLAGS={- $target{bin_cflags} -}
Richard Levitte77634722016-10-12 15:30:43 +0200201BIN_CXXFLAGS={- $target{bin_cxxflag} || "" -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100202
203PERL={- $config{perl} -}
204
205ARFLAGS= {- $target{arflags} -}
206AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
207RANLIB= {- $target{ranlib} -}
208NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
Richard Levitte8f41ff22016-05-16 17:08:13 +0200209RCFLAGS={- $target{shared_rcflag} -}
210RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100211RM= rm -f
Richard Levitte98e55342016-02-15 22:12:24 +0100212RMDIR= rmdir
Richard Levitte567a9e62016-01-30 03:25:40 +0100213TAR= {- $target{tar} || "tar" -}
214TARFLAGS= {- $target{tarflags} -}
Richard Levitte29eed3d2016-03-09 01:17:27 +0100215MAKEDEPEND={- $config{makedepprog} -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100216
217BASENAME= openssl
218NAME= $(BASENAME)-$(VERSION)
219TARFILE= ../$(NAME).tar
220
221# We let the C compiler driver to take care of .s files. This is done in
222# order to be excused from maintaining a separate set of architecture
223# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
224# gcc, then the driver will automatically translate it to -xarch=v8plus
225# and pass it down to assembler.
226AS=$(CC) -c
227ASFLAG=$(CFLAGS)
228PERLASM_SCHEME= {- $target{perlasm_scheme} -}
229
230# For x86 assembler: Set PROCESSOR to 386 if you want to support
231# the 80386.
232PROCESSOR= {- $config{processor} -}
233
Andy Polyakov9c7ce402016-07-28 23:05:32 +0200234# We want error [and other] messages in English. Trouble is that make(1)
235# doesn't pass macros down as environment variables unless there already
236# was corresponding variable originally set. In other words we can only
237# reassign environment variables, but not set new ones, not in portable
238# manner that is. That's why we reassign several, just to be sure...
239LC_ALL=C
240LC_MESSAGES=C
241LANG=C
242
Richard Levitte567a9e62016-01-30 03:25:40 +0100243# The main targets ###################################################
244
Richard Levitte1e3d16b2016-07-08 17:58:36 +0200245{- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
Ben Laurie27c40a92016-06-26 13:09:23 +0100246{- dependmagic('build_libs'); -}: build_libs_nodep
247{- dependmagic('build_engines'); -}: build_engines_nodep
Richard Levitte1e3d16b2016-07-08 17:58:36 +0200248{- dependmagic('build_programs'); -}: build_programs_nodep
Richard Levitte68a5f1a2016-02-13 18:15:51 +0100249
Richard Levitte932eaf02016-06-14 21:39:13 +0200250build_generated: $(GENERATED_MANDATORY)
Ben Laurie27c40a92016-06-26 13:09:23 +0100251build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
252build_engines_nodep: $(ENGINES)
Richard Levitte1e3d16b2016-07-08 17:58:36 +0200253build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
254
255# Kept around for backward compatibility
256build_apps build_tests: build_programs
Richard Levitte932eaf02016-06-14 21:39:13 +0200257
Richard Levitte9b03b912017-06-16 03:46:41 +0200258# Convenience target to prebuild all generated files, not just the mandatory
259# ones
260build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
261
Richard Levitte1b741652016-04-18 14:09:36 +0200262test: tests
Richard Levitte1e3d16b2016-07-08 17:58:36 +0200263{- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
Matt Caswelld90a6be2016-04-14 13:44:15 +0100264 @ : {- output_off() if $disabled{tests}; "" -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100265 ( cd test; \
266 SRCTOP=../$(SRCDIR) \
267 BLDTOP=../$(BLDDIR) \
Richard Levittecbece222016-05-27 17:18:57 +0200268 PERL="$(PERL)" \
Ben Laurie834aae22016-02-20 15:27:27 +0000269 EXE_EXT={- $exeext -} \
Richard Levittea7177382016-03-05 13:11:37 +0100270 OPENSSL_ENGINES=../$(BLDDIR)/engines \
Richard Levitte6d4bc8a2016-11-03 17:08:10 +0100271 OPENSSL_DEBUG_MEMORY=on \
Richard Levitte567a9e62016-01-30 03:25:40 +0100272 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
Matt Caswelld90a6be2016-04-14 13:44:15 +0100273 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
274 @echo "Tests are not supported with your chosen Configure options"
275 @ : {- output_on() if !$disabled{tests}; "" -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100276
277list-tests:
Richard Levitte4813ad22016-06-17 00:23:43 +0200278 @ : {- output_off() if $disabled{tests}; "" -}
279 @SRCTOP="$(SRCDIR)" \
280 $(PERL) $(SRCDIR)/test/run_tests.pl list
281 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
282 @echo "Tests are not supported with your chosen Configure options"
283 @ : {- output_on() if !$disabled{tests}; "" -}
284
285install: install_sw install_ssldirs install_docs
286
287uninstall: uninstall_docs uninstall_sw
Richard Levitte567a9e62016-01-30 03:25:40 +0100288
289libclean:
Richard Levittef99f91f2016-02-15 22:13:41 +0100290 @set -e; for s in $(SHLIB_INFO); do \
291 s1=`echo "$$s" | cut -f1 -d";"`; \
292 s2=`echo "$$s" | cut -f2 -d";"`; \
Rich Salz54073382017-06-29 11:40:19 -0400293 $(ECHO) $(RM) $$s1; \
Richard Levittef99f91f2016-02-15 22:13:41 +0100294 $(RM) $$s1; \
295 if [ "$$s1" != "$$s2" ]; then \
Rich Salz54073382017-06-29 11:40:19 -0400296 $(ECHO) $(RM) $$s2; \
Richard Levittef99f91f2016-02-15 22:13:41 +0100297 $(RM) $$s2; \
298 fi; \
299 done
300 $(RM) $(LIBS)
Richard Levitte4813ad22016-06-17 00:23:43 +0200301 $(RM) *.map
Richard Levitte567a9e62016-01-30 03:25:40 +0100302
303clean: libclean
Richard Levitte4813ad22016-06-17 00:23:43 +0200304 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
305 $(RM) $(GENERATED)
306 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
307 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
308 $(RM) core
Rich Salz9e183d22017-03-11 08:56:44 -0500309 $(RM) tags TAGS doc-nits
Bernd Edlinger122fa082017-02-01 19:10:03 +0100310 $(RM) test/.rnd
Richard Levitte4813ad22016-06-17 00:23:43 +0200311 $(RM) openssl.pc libcrypto.pc libssl.pc
312 -$(RM) `find . -type l -a \! -path "./.git/*"`
313 $(RM) $(TARFILE)
Richard Levitte567a9e62016-01-30 03:25:40 +0100314
Richard Levitte7cae3862016-06-13 22:02:11 +0200315distclean: clean
Richard Levitte4813ad22016-06-17 00:23:43 +0200316 $(RM) configdata.pm
317 $(RM) Makefile
Richard Levitte7cae3862016-06-13 22:02:11 +0200318
Richard Levittef8d9d6e2016-02-21 16:09:36 +0100319# We check if any depfile is newer than Makefile and decide to
Richard Levittea6adf092016-03-18 20:52:29 +0100320# concatenate only if that is true.
Richard Levitteea80a252016-02-20 17:29:23 +0100321depend:
Richard Levitte29eed3d2016-03-09 01:17:27 +0100322 @: {- output_off() if $disabled{makedepend}; "" -}
Ben Lauried423c5a2016-10-01 12:40:58 +0100323 @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
Richard Levitteebca7962016-10-31 17:38:36 +0100324 ( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
Richard Levittef8d9d6e2016-02-21 16:09:36 +0100325 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
326 echo; \
Richard Levittea6adf092016-03-18 20:52:29 +0100327 for f in $(DEPS); do \
328 if [ -f $$f ]; then cat $$f; fi; \
Richard Levittef8d9d6e2016-02-21 16:09:36 +0100329 done ) > Makefile.new; \
Richard Levitte29b28ee2016-03-15 09:05:20 +0100330 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
Richard Levittef8d9d6e2016-02-21 16:09:36 +0100331 rm -f Makefile.new; \
Richard Levitte29b28ee2016-03-15 09:05:20 +0100332 else \
333 mv -f Makefile.new Makefile; \
Richard Levittef8d9d6e2016-02-21 16:09:36 +0100334 fi; \
Richard Levittec058fcd2016-02-18 19:41:57 +0100335 fi
Richard Levitte29eed3d2016-03-09 01:17:27 +0100336 @: {- output_on() if $disabled{makedepend}; "" -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100337
338# Install helper targets #############################################
339
340install_sw: all install_dev install_engines install_runtime
341
Richard Levittef99f91f2016-02-15 22:13:41 +0100342uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
Richard Levitte567a9e62016-01-30 03:25:40 +0100343
344install_docs: install_man_docs install_html_docs
345
346uninstall_docs: uninstall_man_docs uninstall_html_docs
Richard Levitte8be7bdb2016-02-19 10:38:15 +0100347 $(RM) -r -v $(DESTDIR)$(DOCDIR)
Richard Levitte567a9e62016-01-30 03:25:40 +0100348
Richard Levittedde10ab2016-02-13 17:55:48 +0100349install_ssldirs:
350 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
351 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
Richard Levitte66c2eb82016-08-01 23:15:50 +0200352 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
Richard Levitte4813ad22016-06-17 00:23:43 +0200353 @set -e; for x in dummy $(MISC_SCRIPTS); do \
354 if [ "$$x" = "dummy" ]; then continue; fi; \
355 fn=`basename $$x`; \
Rich Salz54073382017-06-29 11:40:19 -0400356 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
Richard Levitte4813ad22016-06-17 00:23:43 +0200357 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
358 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
359 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
360 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
361 done
Rich Salz54073382017-06-29 11:40:19 -0400362 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
Richard Levitte4813ad22016-06-17 00:23:43 +0200363 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
364 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
Richard Levittecb926df2016-08-01 23:18:25 +0200365 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
Rich Salzc7af65c2016-09-09 18:05:41 -0400366 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
Rich Salz54073382017-06-29 11:40:19 -0400367 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
Richard Levittecb926df2016-08-01 23:18:25 +0200368 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
369 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
370 fi
Rich Salz54073382017-06-29 11:40:19 -0400371 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
Rich Salzc7af65c2016-09-09 18:05:41 -0400372 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
373 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
374 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
375 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
Rich Salz54073382017-06-29 11:40:19 -0400376 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
Rich Salzc7af65c2016-09-09 18:05:41 -0400377 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
378 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
379 fi
Richard Levittedde10ab2016-02-13 17:55:48 +0100380
Richard Levitte567a9e62016-01-30 03:25:40 +0100381install_dev:
382 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
Rich Salz54073382017-06-29 11:40:19 -0400383 @$(ECHO) "*** Installing development files"
Richard Levitte3c655772016-02-12 21:14:03 +0100384 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
Richard Levitte24c4f732016-07-14 21:11:46 +0200385 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
Rich Salz54073382017-06-29 11:40:19 -0400386 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
Richard Levitte24c4f732016-07-14 21:11:46 +0200387 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
388 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
389 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100390 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
391 $(BLDDIR)/include/openssl/*.h; do \
392 fn=`basename $$i`; \
Rich Salz54073382017-06-29 11:40:19 -0400393 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100394 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
395 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100396 done
Richard Levitte3c655772016-02-12 21:14:03 +0100397 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200398 @set -e; for l in $(INSTALL_LIBS); do \
Richard Levitte567a9e62016-01-30 03:25:40 +0100399 fn=`basename $$l`; \
Rich Salz54073382017-06-29 11:40:19 -0400400 $(ECHO) "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100401 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
402 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
403 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
404 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
405 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100406 done
Richard Levitte84af1ba2016-02-22 13:52:46 +0100407 @ : {- output_off() if $disabled{shared}; "" -}
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200408 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
Richard Levittec8c2b772016-02-15 18:39:49 +0100409 s1=`echo "$$s" | cut -f1 -d";"`; \
410 s2=`echo "$$s" | cut -f2 -d";"`; \
411 fn1=`basename $$s1`; \
412 fn2=`basename $$s2`; \
413 : {- output_off() if windowsdll(); "" -}; \
Rich Salz54073382017-06-29 11:40:19 -0400414 $(ECHO) "install $$s1 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
Richard Levittec8c2b772016-02-15 18:39:49 +0100415 cp $$s1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
Richard Levitte35035492016-07-08 13:33:27 +0200416 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
Richard Levittec8c2b772016-02-15 18:39:49 +0100417 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new \
418 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
419 if [ "$$fn1" != "$$fn2" ]; then \
Rich Salz54073382017-06-29 11:40:19 -0400420 $(ECHO) "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
Richard Levittec8c2b772016-02-15 18:39:49 +0100421 ln -sf $$fn1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100422 fi; \
Richard Levittec8c2b772016-02-15 18:39:49 +0100423 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
Rich Salz54073382017-06-29 11:40:19 -0400424 $(ECHO) "install $$s2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
Richard Levittec8c2b772016-02-15 18:39:49 +0100425 cp $$s2 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
Richard Levitte35035492016-07-08 13:33:27 +0200426 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
Richard Levittec8c2b772016-02-15 18:39:49 +0100427 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new \
428 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
Richard Levittece5ed822016-02-19 22:23:28 +0100429 : {- output_on() unless windowsdll(); "" -}; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100430 done
Richard Levitte84af1ba2016-02-22 13:52:46 +0100431 @ : {- output_on() if $disabled{shared}; "" -}
Richard Levitte3c655772016-02-12 21:14:03 +0100432 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
Rich Salz54073382017-06-29 11:40:19 -0400433 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
Richard Levitte3c655772016-02-12 21:14:03 +0100434 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
435 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
Rich Salz54073382017-06-29 11:40:19 -0400436 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
Richard Levitte3c655772016-02-12 21:14:03 +0100437 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
438 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
Rich Salz54073382017-06-29 11:40:19 -0400439 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
Richard Levitte3c655772016-02-12 21:14:03 +0100440 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
441 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
Richard Levitte567a9e62016-01-30 03:25:40 +0100442
443uninstall_dev:
Rich Salz54073382017-06-29 11:40:19 -0400444 @$(ECHO) "*** Uninstalling development files"
Richard Levitte24c4f732016-07-14 21:11:46 +0200445 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
Rich Salz54073382017-06-29 11:40:19 -0400446 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
Richard Levitte24c4f732016-07-14 21:11:46 +0200447 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
448 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100449 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
450 $(BLDDIR)/include/openssl/*.h; do \
451 fn=`basename $$i`; \
Rich Salz54073382017-06-29 11:40:19 -0400452 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100453 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100454 done
Richard Levitte98e55342016-02-15 22:12:24 +0100455 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
456 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200457 @set -e; for l in $(INSTALL_LIBS); do \
Richard Levitte567a9e62016-01-30 03:25:40 +0100458 fn=`basename $$l`; \
Rich Salz54073382017-06-29 11:40:19 -0400459 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100460 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100461 done
Richard Levitte84af1ba2016-02-22 13:52:46 +0100462 @ : {- output_off() if $disabled{shared}; "" -}
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200463 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
Richard Levittec8c2b772016-02-15 18:39:49 +0100464 s1=`echo "$$s" | cut -f1 -d";"`; \
465 s2=`echo "$$s" | cut -f2 -d";"`; \
466 fn1=`basename $$s1`; \
467 fn2=`basename $$s2`; \
468 : {- output_off() if windowsdll(); "" -}; \
Rich Salz54073382017-06-29 11:40:19 -0400469 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
Richard Levittec8c2b772016-02-15 18:39:49 +0100470 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
471 if [ "$$fn1" != "$$fn2" ]; then \
Rich Salz54073382017-06-29 11:40:19 -0400472 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100473 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100474 fi; \
Richard Levittec8c2b772016-02-15 18:39:49 +0100475 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
Rich Salz54073382017-06-29 11:40:19 -0400476 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
Richard Levittec8c2b772016-02-15 18:39:49 +0100477 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
Richard Levittece5ed822016-02-19 22:23:28 +0100478 : {- output_on() unless windowsdll(); "" -}; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100479 done
Richard Levittec8cca982016-03-04 05:43:15 +0100480 @ : {- output_on() if $disabled{shared}; "" -}
Richard Levitteb8940542016-03-03 17:45:14 +0100481 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
482 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
483 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
484 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
485 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
Richard Levitte567a9e62016-01-30 03:25:40 +0100486
487install_engines:
488 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
Richard Levitteb2de11c2016-07-06 18:50:47 +0200489 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
Rich Salz54073382017-06-29 11:40:19 -0400490 @$(ECHO) "*** Installing engines"
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200491 @set -e; for e in dummy $(INSTALL_ENGINES); do \
Richard Levitte2b364f62016-03-21 08:11:14 +0100492 if [ "$$e" = "dummy" ]; then continue; fi; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100493 fn=`basename $$e`; \
Rich Salz54073382017-06-29 11:40:19 -0400494 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
Richard Levitteb2de11c2016-07-06 18:50:47 +0200495 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
496 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
497 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
498 $(DESTDIR)$(ENGINESDIR)/$$fn; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100499 done
500
501uninstall_engines:
Rich Salz54073382017-06-29 11:40:19 -0400502 @$(ECHO) "*** Uninstalling engines"
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200503 @set -e; for e in dummy $(INSTALL_ENGINES); do \
Richard Levitte2b364f62016-03-21 08:11:14 +0100504 if [ "$$e" = "dummy" ]; then continue; fi; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100505 fn=`basename $$e`; \
Richard Levittef0c93a82016-02-19 10:39:12 +0100506 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
507 continue; \
508 fi; \
Rich Salz54073382017-06-29 11:40:19 -0400509 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
Richard Levitteb2de11c2016-07-06 18:50:47 +0200510 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100511 done
Richard Levitteb2de11c2016-07-06 18:50:47 +0200512 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
Richard Levitte567a9e62016-01-30 03:25:40 +0100513
514install_runtime:
515 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
Richard Levitte3c655772016-02-12 21:14:03 +0100516 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
Richard Levitte36b53722016-07-19 13:24:57 +0200517 @ : {- output_off() if windowsdll(); "" -}
518 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
519 @ : {- output_on() if windowsdll(); "" -}
Rich Salz54073382017-06-29 11:40:19 -0400520 @$(ECHO) "*** Installing runtime files"
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200521 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
Richard Levitte2b364f62016-03-21 08:11:14 +0100522 if [ "$$s" = "dummy" ]; then continue; fi; \
Richard Levittef99f91f2016-02-15 22:13:41 +0100523 fn=`basename $$s`; \
Richard Levitte36b53722016-07-19 13:24:57 +0200524 : {- output_off() unless windowsdll(); "" -}; \
Rich Salz54073382017-06-29 11:40:19 -0400525 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100526 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
527 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
528 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
529 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
Richard Levitte36b53722016-07-19 13:24:57 +0200530 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
Rich Salz54073382017-06-29 11:40:19 -0400531 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
Richard Levitte36b53722016-07-19 13:24:57 +0200532 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
533 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
534 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
535 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
536 : {- output_on() if windowsdll(); "" -}; \
Richard Levittefcf80c42016-01-30 05:45:29 +0100537 done
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200538 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
Richard Levitte2b364f62016-03-21 08:11:14 +0100539 if [ "$$x" = "dummy" ]; then continue; fi; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100540 fn=`basename $$x`; \
Rich Salz54073382017-06-29 11:40:19 -0400541 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100542 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
543 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
544 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
545 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100546 done
Richard Levitte2b364f62016-03-21 08:11:14 +0100547 @set -e; for x in dummy $(BIN_SCRIPTS); do \
548 if [ "$$x" = "dummy" ]; then continue; fi; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100549 fn=`basename $$x`; \
Rich Salz54073382017-06-29 11:40:19 -0400550 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100551 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
552 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
553 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
554 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100555 done
Richard Levitte567a9e62016-01-30 03:25:40 +0100556
557uninstall_runtime:
Rich Salz54073382017-06-29 11:40:19 -0400558 @$(ECHO) "*** Uninstalling runtime files"
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200559 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
Richard Levitte567a9e62016-01-30 03:25:40 +0100560 do \
Richard Levitte2b364f62016-03-21 08:11:14 +0100561 if [ "$$x" = "dummy" ]; then continue; fi; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100562 fn=`basename $$x`; \
Rich Salz54073382017-06-29 11:40:19 -0400563 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100564 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100565 done;
Richard Levitte2b364f62016-03-21 08:11:14 +0100566 @set -e; for x in dummy $(BIN_SCRIPTS); \
Richard Levitte567a9e62016-01-30 03:25:40 +0100567 do \
Richard Levitte2b364f62016-03-21 08:11:14 +0100568 if [ "$$x" = "dummy" ]; then continue; fi; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100569 fn=`basename $$x`; \
Rich Salz54073382017-06-29 11:40:19 -0400570 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100571 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100572 done
Richard Levitteb1837ab2016-07-14 21:13:24 +0200573 @ : {- output_off() unless windowsdll(); "" -}
Richard Levitte0f01b7b2016-07-08 14:52:09 +0200574 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
Richard Levitte2b364f62016-03-21 08:11:14 +0100575 if [ "$$s" = "dummy" ]; then continue; fi; \
Richard Levittef99f91f2016-02-15 22:13:41 +0100576 fn=`basename $$s`; \
Rich Salz54073382017-06-29 11:40:19 -0400577 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
Richard Levitte3c655772016-02-12 21:14:03 +0100578 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
Richard Levittefcf80c42016-01-30 05:45:29 +0100579 done
Richard Levitteb1837ab2016-07-14 21:13:24 +0200580 @ : {- output_on() unless windowsdll(); "" -}
Richard Levitteb8940542016-03-03 17:45:14 +0100581 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
Richard Levitte567a9e62016-01-30 03:25:40 +0100582
Richard Levitte567a9e62016-01-30 03:25:40 +0100583
584install_man_docs:
585 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
Rich Salz54073382017-06-29 11:40:19 -0400586 @$(ECHO) "*** Installing manpages"
Richard Levittecadb0152017-03-06 21:17:32 +0100587 $(PERL) $(SRCDIR)/util/process_docs.pl \
588 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
Richard Levitte567a9e62016-01-30 03:25:40 +0100589
590uninstall_man_docs:
Rich Salz54073382017-06-29 11:40:19 -0400591 @$(ECHO) "*** Uninstalling manpages"
Richard Levittecadb0152017-03-06 21:17:32 +0100592 $(PERL) $(SRCDIR)/util/process_docs.pl \
593 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
594 --remove
Richard Levitte567a9e62016-01-30 03:25:40 +0100595
596install_html_docs:
597 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
Rich Salz54073382017-06-29 11:40:19 -0400598 @$(ECHO) "*** Installing HTML manpages"
Richard Levittecadb0152017-03-06 21:17:32 +0100599 $(PERL) $(SRCDIR)/util/process_docs.pl \
600 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
Richard Levitte567a9e62016-01-30 03:25:40 +0100601
602uninstall_html_docs:
Rich Salz54073382017-06-29 11:40:19 -0400603 @$(ECHO) "*** Uninstalling manpages"
Richard Levittecadb0152017-03-06 21:17:32 +0100604 $(PERL) $(SRCDIR)/util/process_docs.pl \
605 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
Richard Levitte567a9e62016-01-30 03:25:40 +0100606
607
608# Developer targets (note: these are only available on Unix) #########
609
Richard Levitte6bb21062016-02-11 20:00:57 +0100610update: generate errors ordinals
611
Richard Levitteb7650c62016-05-01 15:09:20 +0200612generate: generate_apps generate_crypto_bn generate_crypto_objects \
613 generate_crypto_conf generate_crypto_asn1
Richard Levitte567a9e62016-01-30 03:25:40 +0100614
Rich Salz65c1f972017-01-12 08:20:54 -0500615doc-nits:
Rich Salz17224962017-06-08 15:18:38 -0400616 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
Rich Salz9e183d22017-03-11 08:56:44 -0500617 if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
Rich Salz65c1f972017-01-12 08:20:54 -0500618
Richard Levitte567a9e62016-01-30 03:25:40 +0100619# Test coverage is a good idea for the future
620#coverage: $(PROGRAMS) $(TESTPROGRAMS)
621# ...
622
Richard Levitte567a9e62016-01-30 03:25:40 +0100623lint:
624 lint -DLINT $(INCLUDES) $(SRCS)
625
Richard Levitte9a9f8ee2016-03-19 20:04:51 +0100626generate_apps:
627 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
628 < apps/openssl.cnf > apps/openssl-vms.cnf )
Richard Levitte6bb21062016-02-11 20:00:57 +0100629
Richard Levitte9a9f8ee2016-03-19 20:04:51 +0100630generate_crypto_bn:
631 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
Richard Levitte6bb21062016-02-11 20:00:57 +0100632
Richard Levitte9a9f8ee2016-03-19 20:04:51 +0100633generate_crypto_objects:
Richard Levitte9a9f8ee2016-03-19 20:04:51 +0100634 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
635 crypto/objects/objects.txt \
636 crypto/objects/obj_mac.num \
637 include/openssl/obj_mac.h )
Kirill Marinushkine6f2bb62016-04-24 02:01:25 +0200638 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
639 include/openssl/obj_mac.h \
640 crypto/objects/obj_dat.h )
Richard Levitte9a9f8ee2016-03-19 20:04:51 +0100641 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
642 crypto/objects/obj_mac.num \
643 crypto/objects/obj_xref.txt \
644 > crypto/objects/obj_xref.h )
Richard Levitte6bb21062016-02-11 20:00:57 +0100645
Richard Levitteb7650c62016-05-01 15:09:20 +0200646generate_crypto_conf:
647 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
648 > crypto/conf/conf_def.h )
649
650generate_crypto_asn1:
651 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
652 > crypto/asn1/charmap.h )
653
Rich Salz52df25c2017-06-07 15:12:03 -0400654# Set to -force to force a rebuild
655ERROR_REBUILD=
Richard Levitte567a9e62016-01-30 03:25:40 +0100656errors:
657 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
Rich Salz52df25c2017-06-07 15:12:03 -0400658 ( cd $(SRCDIR); $(PERL) util/mkerr.pl $(ERROR_REBUILD) -internal )
Richard Levitte567a9e62016-01-30 03:25:40 +0100659 ( cd $(SRCDIR)/engines; \
Rich Salz52df25c2017-06-07 15:12:03 -0400660 for E in *.ec ; do \
661 $(PERL) ../util/mkerr.pl $(ERROR_REBUILD) -static \
662 -conf $$E `basename $$E .ec`.c ; \
663 done )
Richard Levitte567a9e62016-01-30 03:25:40 +0100664
665ordinals:
666 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
667 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
668
669test_ordinals:
670 ( cd test; \
671 SRCTOP=../$(SRCDIR) \
672 BLDTOP=../$(BLDDIR) \
673 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
674
675tags TAGS: FORCE
676 rm -f TAGS tags
677 -ctags -R .
678 -etags `find . -name '*.[ch]' -o -name '*.pm'`
679
680# Release targets (note: only available on Unix) #####################
681
Richard Levitte77a9c262017-08-17 14:08:43 +0200682# If your tar command doesn't support --owner and --group, make sure to
683# use one that does, for example GNU tar
Ben Lauriea1bce642016-06-10 12:07:32 +0100684TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
Richard Levitte54bb8f72016-03-08 11:49:26 +0100685PREPARE_CMD=:
Richard Levitte567a9e62016-01-30 03:25:40 +0100686tar:
Richard Levitte34a5b7d2017-08-17 14:04:18 +0200687 set -e; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100688 TMPDIR=/var/tmp/openssl-copy.$$$$; \
Richard Levitte54bb8f72016-03-08 11:49:26 +0100689 DISTDIR=$(NAME); \
Richard Levitte567a9e62016-01-30 03:25:40 +0100690 mkdir -p $$TMPDIR/$$DISTDIR; \
691 (cd $(SRCDIR); \
Richard Levitte5b7b0112017-08-17 09:38:02 +0200692 excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
693 excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
694 echo "$$excl_re"; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100695 git ls-tree -r --name-only --full-tree HEAD \
Richard Levitte17c84aa2017-08-17 14:04:36 +0200696 | egrep -v "$$excl_re" \
Richard Levitte567a9e62016-01-30 03:25:40 +0100697 | while read F; do \
698 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
699 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
700 done); \
Richard Levitte17c84aa2017-08-17 14:04:36 +0200701 (cd $$TMPDIR/$$DISTDIR; \
Richard Levitte54bb8f72016-03-08 11:49:26 +0100702 $(PREPARE_CMD); \
Richard Levitte17c84aa2017-08-17 14:04:36 +0200703 find . -type d -print | xargs chmod 755; \
704 find . -type f -print | xargs chmod a+r; \
705 find . -type f -perm -0100 -print | xargs chmod a+x); \
706 (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
Richard Levitte567a9e62016-01-30 03:25:40 +0100707 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
708 rm -rf $$TMPDIR
709 cd $(SRCDIR); ls -l $(TARFILE).gz
710
711dist:
Richard Levitte12ccb022016-11-09 00:14:56 +0100712 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' tar
Richard Levitte567a9e62016-01-30 03:25:40 +0100713
714# Helper targets #####################################################
715
Richard Levitte342a1a22016-09-07 20:56:20 +0200716link-utils: $(BLDDIR)/util/opensslwrap.sh
Richard Levitte567a9e62016-01-30 03:25:40 +0100717
Richard Levitte27f42b42016-02-19 02:30:51 +0100718$(BLDDIR)/util/opensslwrap.sh: configdata.pm
Richard Levitte567a9e62016-01-30 03:25:40 +0100719 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
720 mkdir -p "$(BLDDIR)/util"; \
721 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
722 fi
Richard Levitte342a1a22016-09-07 20:56:20 +0200723
Richard Levittec058fcd2016-02-18 19:41:57 +0100724FORCE:
Richard Levitte567a9e62016-01-30 03:25:40 +0100725
726# Building targets ###################################################
727
Richard Levitte8478a702016-07-06 03:07:16 +0200728libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
Richard Levitte567a9e62016-01-30 03:25:40 +0100729libcrypto.pc:
730 @ ( echo 'prefix=$(INSTALLTOP)'; \
731 echo 'exec_prefix=$${prefix}'; \
732 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
733 echo 'includedir=$${prefix}/include'; \
Richard Levitted4453022017-07-19 10:13:41 +0200734 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
Richard Levitte567a9e62016-01-30 03:25:40 +0100735 echo ''; \
736 echo 'Name: OpenSSL-libcrypto'; \
737 echo 'Description: OpenSSL cryptography library'; \
738 echo 'Version: '$(VERSION); \
739 echo 'Libs: -L$${libdir} -lcrypto'; \
740 echo 'Libs.private: $(EX_LIBS)'; \
741 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
742
743libssl.pc:
744 @ ( echo 'prefix=$(INSTALLTOP)'; \
745 echo 'exec_prefix=$${prefix}'; \
746 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
747 echo 'includedir=$${prefix}/include'; \
748 echo ''; \
749 echo 'Name: OpenSSL-libssl'; \
750 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
751 echo 'Version: '$(VERSION); \
752 echo 'Requires.private: libcrypto'; \
753 echo 'Libs: -L$${libdir} -lssl'; \
754 echo 'Libs.private: $(EX_LIBS)'; \
755 echo 'Cflags: -I$${includedir}' ) > libssl.pc
756
757openssl.pc:
758 @ ( echo 'prefix=$(INSTALLTOP)'; \
759 echo 'exec_prefix=$${prefix}'; \
760 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
761 echo 'includedir=$${prefix}/include'; \
762 echo ''; \
763 echo 'Name: OpenSSL'; \
764 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
765 echo 'Version: '$(VERSION); \
766 echo 'Requires: libssl libcrypto' ) > openssl.pc
767
Richard Levitte41240e62016-09-17 20:50:56 +0200768configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
Richard Levitte27f42b42016-02-19 02:30:51 +0100769 @echo "Detected changed: $?"
Richard Levitte567a9e62016-01-30 03:25:40 +0100770 @echo "Reconfiguring..."
Richard Levitte12ccb022016-11-09 00:14:56 +0100771 $(PERL) $(SRCDIR)/Configure reconf
Richard Levitte567a9e62016-01-30 03:25:40 +0100772 @echo "**************************************************"
773 @echo "*** ***"
774 @echo "*** Please run the same make command again ***"
775 @echo "*** ***"
776 @echo "**************************************************"
777 @false
778
779{-
780 use File::Basename;
781 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
Richard Levittecedbb142016-02-11 13:10:11 +0100782
783 # Helper function to figure out dependencies on libraries
784 # It takes a list of library names and outputs a list of dependencies
785 sub compute_lib_depends {
Richard Levitte84af1ba2016-02-22 13:52:46 +0100786 if ($disabled{shared}) {
Richard Levitte33105812017-04-18 16:24:23 +0200787 return map { lib($_) } @_;
Richard Levittecedbb142016-02-11 13:10:11 +0100788 }
789
790 # Depending on shared libraries:
791 # On Windows POSIX layers, we depend on {libname}.dll.a
792 # On Unix platforms, we depend on {shlibname}.so
Richard Levitte186a31e2016-11-09 20:01:51 +0100793 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
Richard Levittecedbb142016-02-11 13:10:11 +0100794 }
795
Richard Levitte66ddf172016-03-07 14:38:54 +0100796 sub generatesrc {
797 my %args = @_;
798 my $generator = join(" ", @{$args{generator}});
Richard Levitte8d34daf2016-04-21 14:30:08 +0200799 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
Richard Levitted4605722016-03-10 09:04:09 +0100800 my $incs = join("", map { " -I".$_ } @{$args{incs}});
Richard Levitte8d34daf2016-04-21 14:30:08 +0200801 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
Richard Levitte66ddf172016-03-07 14:38:54 +0100802
803 if ($args{src} !~ /\.[sS]$/) {
Richard Levitte7cae3862016-06-13 22:02:11 +0200804 if ($args{generator}->[0] =~ m|^.*\.in$|) {
805 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
806 "util", "dofile.pl")),
807 rel2abs($config{builddir}));
808 return <<"EOF";
809$args{src}: $args{generator}->[0] $deps
810 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
811 "-o$target{build_file}" $generator > \$@
812EOF
813 } else {
814 return <<"EOF";
Richard Levitte769777b2016-03-19 00:57:35 +0100815$args{src}: $args{generator}->[0] $deps
Richard Levitte8d34daf2016-04-21 14:30:08 +0200816 \$(PERL)$generator_incs $generator > \$@
Richard Levitte66ddf172016-03-07 14:38:54 +0100817EOF
Richard Levitte7cae3862016-06-13 22:02:11 +0200818 }
Richard Levitte66ddf172016-03-07 14:38:54 +0100819 } else {
Richard Levitte8458f1b2016-03-08 19:19:53 +0100820 if ($args{generator}->[0] =~ /\.pl$/) {
Richard Levitte8d34daf2016-04-21 14:30:08 +0200821 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
Richard Levitte66ddf172016-03-07 14:38:54 +0100822 } elsif ($args{generator}->[0] =~ /\.m4$/) {
Richard Levitte8d34daf2016-04-21 14:30:08 +0200823 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
Richard Levitte8458f1b2016-03-08 19:19:53 +0100824 } elsif ($args{generator}->[0] =~ /\.S$/) {
825 $generator = undef;
826 } else {
827 die "Generator type for $args{src} unknown: $generator\n";
828 }
829
830 if (defined($generator)) {
831 # If the target is named foo.S in build.info, we want to
832 # end up generating foo.s in two steps.
833 if ($args{src} =~ /\.S$/) {
834 (my $target = $args{src}) =~ s|\.S$|.s|;
835 return <<"EOF";
Richard Levitte769777b2016-03-19 00:57:35 +0100836$target: $args{generator}->[0] $deps
Andy Polyakov0218fc32016-03-11 11:55:44 +0100837 ( trap "rm -f \$@.*" INT 0; \\
Richard Levitte8458f1b2016-03-08 19:19:53 +0100838 $generator \$@.S; \\
Roumen Petrov57ade572016-06-27 21:24:07 +0200839 \$(CC) $incs \$(CFLAGS) -E \$@.S | \\
Andy Polyakov39199fb2016-05-02 23:38:11 +0200840 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
841 mv -f \$@.i \$@ )
Richard Levitte8458f1b2016-03-08 19:19:53 +0100842EOF
843 }
844 # Otherwise....
Richard Levitte66ddf172016-03-07 14:38:54 +0100845 return <<"EOF";
Richard Levitte769777b2016-03-19 00:57:35 +0100846$args{src}: $args{generator}->[0] $deps
Richard Levitte8458f1b2016-03-08 19:19:53 +0100847 $generator \$@
Richard Levitte66ddf172016-03-07 14:38:54 +0100848EOF
Richard Levitte66ddf172016-03-07 14:38:54 +0100849 }
Richard Levitte8458f1b2016-03-08 19:19:53 +0100850 return <<"EOF";
Richard Levitte769777b2016-03-19 00:57:35 +0100851$args{src}: $args{generator}->[0] $deps
Roumen Petrov57ade572016-06-27 21:24:07 +0200852 \$(CC) $incs \$(CFLAGS) -E \$< | \\
Andy Polyakov39199fb2016-05-02 23:38:11 +0200853 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
Richard Levitte8458f1b2016-03-08 19:19:53 +0100854EOF
Richard Levitte66ddf172016-03-07 14:38:54 +0100855 }
856 }
857
Richard Levittebb268422016-03-11 13:25:48 +0100858 # Should one wonder about the end of the Perl snippet, it's because this
859 # second regexp eats up line endings as well, if the removed path is the
860 # last in the line. We may therefore need to put back a line ending.
Richard Levitte88297282016-02-18 13:04:05 +0100861 sub src2obj {
Richard Levitte567a9e62016-01-30 03:25:40 +0100862 my %args = @_;
Richard Levitte88297282016-02-18 13:04:05 +0100863 my $obj = $args{obj};
Richard Levitte674d5852016-03-19 18:59:48 +0100864 my @srcs = map { if ($unified_info{generate}->{$_}) {
865 (my $x = $_) =~ s/\.S$/.s/; $x
866 } else {
867 $_
868 }
869 } ( @{$args{srcs}} );
Richard Levitte8458f1b2016-03-08 19:19:53 +0100870 my $srcs = join(" ", @srcs);
871 my $deps = join(" ", @srcs, @{$args{deps}});
Richard Levitte45502bf2016-02-19 22:02:41 +0100872 my $incs = join("", map { " -I".$_ } @{$args{incs}});
Richard Levitteda430a52016-04-12 16:35:32 +0200873 unless ($disabled{zlib}) {
874 if ($withargs{zlib_include}) {
875 $incs .= " -I".$withargs{zlib_include};
876 }
877 }
Richard Levitte77634722016-10-12 15:30:43 +0200878 my $cc = '$(CC)';
879 my $cflags = '$(CFLAGS)';
880 if (grep /\.(cc|cpp)$/, @srcs) {
881 $cc = '$(CXX)';
882 $cflags = '$(CXXFLAGS)';
883 $cflags .= ' ' . { lib => '$(LIB_CXXFLAGS)',
884 dso => '$(DSO_CXXFLAGS)',
885 bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}};
886 } else {
887 $cflags .= ' ' . { lib => '$(LIB_CFLAGS)',
888 dso => '$(DSO_CFLAGS)',
889 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
890 }
Richard Levitte567a9e62016-01-30 03:25:40 +0100891 my $makedepprog = $config{makedepprog};
Richard Levitte7e5b8b92016-09-04 08:10:22 +0200892 my $recipe = <<"EOF";
Richard Levitte29eed3d2016-03-09 01:17:27 +0100893$obj$objext: $deps
Richard Levitte567a9e62016-01-30 03:25:40 +0100894EOF
Richard Levitte29eed3d2016-03-09 01:17:27 +0100895 if (!$disabled{makedepend} && $makedepprog !~ /\/makedepend/) {
896 $recipe .= <<"EOF";
Richard Levitte77634722016-10-12 15:30:43 +0200897 $cc $incs $cflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
Richard Levitte340da942016-02-28 00:20:50 +0100898 \@touch $obj$depext.tmp
Richard Levitte29b28ee2016-03-15 09:05:20 +0100899 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
Richard Levitte987dbc72016-03-11 09:26:49 +0100900 rm -f $obj$depext.tmp; \\
Richard Levitte29b28ee2016-03-15 09:05:20 +0100901 else \\
902 mv $obj$depext.tmp $obj$depext; \\
Richard Levitte340da942016-02-28 00:20:50 +0100903 fi
Richard Levitte567a9e62016-01-30 03:25:40 +0100904EOF
Richard Levitte7e5b8b92016-09-04 08:10:22 +0200905 } else {
906 $recipe .= <<"EOF";
Richard Levitte77634722016-10-12 15:30:43 +0200907 $cc $incs $cflags -c -o \$\@ $srcs
Richard Levitte7e5b8b92016-09-04 08:10:22 +0200908EOF
909 if (!$disabled{makedepend} && $makedepprog =~ /\/makedepend/) {
910 $recipe .= <<"EOF";
Richard Levitte77634722016-10-12 15:30:43 +0200911 -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cflags -- $srcs \\
Richard Levitte7e5b8b92016-09-04 08:10:22 +0200912 >$obj$depext.tmp 2>/dev/null
913 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
914 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
915 rm -f $obj$depext.tmp; \\
916 else \\
917 mv $obj$depext.tmp $obj$depext; \\
918 fi
919EOF
920 }
Richard Levitte29eed3d2016-03-09 01:17:27 +0100921 }
922 return $recipe;
Richard Levitte567a9e62016-01-30 03:25:40 +0100923 }
924 # On Unix, we build shlibs from static libs, so we're ignoring the
925 # object file array. We *know* this routine is only called when we've
926 # configure 'shared'.
927 sub libobj2shlib {
928 my %args = @_;
929 my $lib = $args{lib};
930 my $shlib = $args{shlib};
931 my $libd = dirname($lib);
932 my $libn = basename($lib);
933 (my $libname = $libn) =~ s/^lib//;
Richard Levittecedbb142016-02-11 13:10:11 +0100934 my $linklibs = join("", map { my $d = dirname($_);
935 my $f = basename($_);
936 (my $l = $f) =~ s/^lib//;
937 " -L$d -l$l" } @{$args{deps}});
938 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
Richard Levitte567a9e62016-01-30 03:25:40 +0100939 my $shlib_target = $target{shared_target};
940 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
Richard Levittef5c174f2016-02-15 17:42:14 +0100941 my $target = shlib_simple($lib);
Richard Levitted07abe12017-07-21 18:04:51 +0200942 my $target_full = shlib($lib);
Richard Levitte567a9e62016-01-30 03:25:40 +0100943 return <<"EOF"
Richard Levittecedbb142016-02-11 13:10:11 +0100944# With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
945# that two files get produced, {shlibname}.dll and {libname}.dll.a.
946# With all other Unix platforms, we often build a shared library with the
947# SO version built into the file name and a symlink without the SO version
948# It's not necessary to have both as targets. The choice falls on the
Richard Levitted4453022017-07-19 10:13:41 +0200949# simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
950# {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
Ben Laurie834aae22016-02-20 15:27:27 +0000951$target: $lib$libext $deps $ordinalsfile
Richard Levitte567a9e62016-01-30 03:25:40 +0100952 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
Rich Salz54073382017-06-29 11:40:19 -0400953 ECHO=\$(ECHO) \\
Richard Levittecedbb142016-02-11 13:10:11 +0100954 PLATFORM=\$(PLATFORM) \\
Richard Levittecbece222016-05-27 17:18:57 +0200955 PERL="\$(PERL)" SRCDIR='\$(SRCDIR)' DSTDIR="$libd" \\
Richard Levitte8a0a3d22016-03-12 10:46:14 +0100956 INSTALLTOP='\$(INSTALLTOP)' LIBDIR='\$(LIBDIR)' \\
957 LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
Richard Levitted4453022017-07-19 10:13:41 +0200958 LIBNAME=$libname SHLIBVERSION=\$(SHLIB_VERSION_NUMBER) \\
Richard Levitted07abe12017-07-21 18:04:51 +0200959 STLIBNAME=$lib$libext \\
960 SHLIBNAME=$target SHLIBNAME_FULL=$target_full \\
Richard Levitte8a0a3d22016-03-12 10:46:14 +0100961 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(LIB_CFLAGS)' \\
Richard Levitted07abe12017-07-21 18:04:51 +0200962 LDFLAGS='\$(LDFLAGS)' SHARED_LDFLAGS='\$(LIB_LDFLAGS)' \\
Richard Levitte8f41ff22016-05-16 17:08:13 +0200963 RC='\$(RC)' SHARED_RCFLAGS='\$(RCFLAGS)' \\
Richard Levittee048fd52016-02-15 18:02:52 +0100964 link_shlib.$shlib_target
Richard Levitte567a9e62016-01-30 03:25:40 +0100965EOF
Richard Levittefcf80c42016-01-30 05:45:29 +0100966 . (windowsdll() ? <<"EOF" : "");
Richard Levitted4453022017-07-19 10:13:41 +0200967 rm -f apps/$shlib'\$(SHLIB_EXT)'
968 rm -f test/$shlib'\$(SHLIB_EXT)'
969 cp -p $shlib'\$(SHLIB_EXT)' apps/
970 cp -p $shlib'\$(SHLIB_EXT)' test/
Richard Levittefcf80c42016-01-30 05:45:29 +0100971EOF
Richard Levitte567a9e62016-01-30 03:25:40 +0100972 }
Richard Levitte53862872016-02-15 18:45:54 +0100973 sub obj2dso {
Richard Levitte567a9e62016-01-30 03:25:40 +0100974 my %args = @_;
Richard Levitted07abe12017-07-21 18:04:51 +0200975 my $dso = $args{lib};
976 my $dsod = dirname($dso);
977 my $dson = basename($dso);
Richard Levitte567a9e62016-01-30 03:25:40 +0100978 my $shlibdeps = join("", map { my $d = dirname($_);
979 my $f = basename($_);
980 (my $l = $f) =~ s/^lib//;
981 " -L$d -l$l" } @{$args{deps}});
Richard Levittecedbb142016-02-11 13:10:11 +0100982 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
Richard Levitte567a9e62016-01-30 03:25:40 +0100983 my $shlib_target = $target{shared_target};
Ben Laurie834aae22016-02-20 15:27:27 +0000984 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
Richard Levitted07abe12017-07-21 18:04:51 +0200985 my $target = dso($dso);
Richard Levitte567a9e62016-01-30 03:25:40 +0100986 return <<"EOF";
Richard Levittef5c174f2016-02-15 17:42:14 +0100987$target: $objs $deps
Richard Levitte567a9e62016-01-30 03:25:40 +0100988 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
Richard Levittecedbb142016-02-11 13:10:11 +0100989 PLATFORM=\$(PLATFORM) \\
Richard Levitted07abe12017-07-21 18:04:51 +0200990 PERL="\$(PERL)" SRCDIR='\$(SRCDIR)' DSTDIR="$dsod" \\
Richard Levitte8a0a3d22016-03-12 10:46:14 +0100991 LIBDEPS='\$(PLIB_LDFLAGS) '"$shlibdeps"' \$(EX_LIBS)' \\
Richard Levitted07abe12017-07-21 18:04:51 +0200992 SHLIBNAME_FULL=$target LDFLAGS='\$(LDFLAGS)' \\
Richard Levitte8a0a3d22016-03-12 10:46:14 +0100993 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(DSO_CFLAGS)' \\
994 SHARED_LDFLAGS='\$(DSO_LDFLAGS)' \\
Richard Levitte567a9e62016-01-30 03:25:40 +0100995 LIBEXTRAS="$objs" \\
Richard Levittee048fd52016-02-15 18:02:52 +0100996 link_dso.$shlib_target
Richard Levitte567a9e62016-01-30 03:25:40 +0100997EOF
998 }
999 sub obj2lib {
1000 my %args = @_;
Richard Levitte33105812017-04-18 16:24:23 +02001001 (my $lib = $args{lib}) =~ s/\.a$//;
Ben Laurie834aae22016-02-20 15:27:27 +00001002 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
Richard Levitte567a9e62016-01-30 03:25:40 +01001003 return <<"EOF";
Ben Laurie834aae22016-02-20 15:27:27 +00001004$lib$libext: $objs
Richard Levitte68cd4e32016-04-03 14:11:12 +02001005 \$(AR) \$\@ \$\?
Richard Levitte567a9e62016-01-30 03:25:40 +01001006 \$(RANLIB) \$\@ || echo Never mind.
1007EOF
1008 }
1009 sub obj2bin {
1010 my %args = @_;
1011 my $bin = $args{bin};
1012 my $bind = dirname($bin);
1013 my $binn = basename($bin);
Ben Laurie834aae22016-02-20 15:27:27 +00001014 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
Richard Levittecedbb142016-02-11 13:10:11 +01001015 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
Richard Levitte186a31e2016-11-09 20:01:51 +01001016 my $linklibs = join("", map { if ($_ =~ /\.a$/) {
1017 " $_";
1018 } else {
1019 my $d = dirname($_);
1020 my $f = basename($_);
1021 $d = "." if $d eq $f;
1022 (my $l = $f) =~ s/^lib//;
1023 " -L$d -l$l"
1024 }
1025 } @{$args{deps}});
Richard Levitte84af1ba2016-02-22 13:52:46 +01001026 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
Richard Levitte77634722016-10-12 15:30:43 +02001027 my $cc = '$(CC)';
1028 my $cflags = '$(CFLAGS) $(BIN_CFLAGS)';
1029 if (grep /_cc$/, @{$args{objs}}) {
1030 $cc = '$(CXX)';
1031 $cflags = '$(CXXFLAGS) $(BIN_CXXFLAGS)';
1032 }
Richard Levitte567a9e62016-01-30 03:25:40 +01001033 return <<"EOF";
Ben Laurie834aae22016-02-20 15:27:27 +00001034$bin$exeext: $objs $deps
1035 \$(RM) $bin$exeext
Richard Levitte567a9e62016-01-30 03:25:40 +01001036 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
Richard Levittecbece222016-05-27 17:18:57 +02001037 PERL="\$(PERL)" SRCDIR=\$(SRCDIR) \\
Ben Laurie834aae22016-02-20 15:27:27 +00001038 APPNAME=$bin$exeext OBJECTS="$objs" \\
Richard Levitte8a0a3d22016-03-12 10:46:14 +01001039 LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
Richard Levitte77634722016-10-12 15:30:43 +02001040 CC='$cc' CFLAGS='$cflags' \\
Richard Levittefad599f2016-10-12 17:05:35 +02001041 LDFLAGS='\$(LDFLAGS)' \\
Richard Levitte567a9e62016-01-30 03:25:40 +01001042 link_app.$shlib_target
1043EOF
1044 }
1045 sub in2script {
1046 my %args = @_;
1047 my $script = $args{script};
1048 my $sources = join(" ", @{$args{sources}});
1049 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1050 "util", "dofile.pl")),
1051 rel2abs($config{builddir}));
1052 return <<"EOF";
Richard Levitte88297282016-02-18 13:04:05 +01001053$script: $sources
Richard Levitte4b799ce2016-02-14 06:55:45 +01001054 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
Richard Levitteba327ad2016-02-14 08:47:47 +01001055 "-o$target{build_file}" $sources > "$script"
Richard Levitte567a9e62016-01-30 03:25:40 +01001056 chmod a+x $script
1057EOF
1058 }
Richard Levitte0ad1d942016-04-02 22:26:38 +02001059 sub generatedir {
1060 my %args = @_;
1061 my $dir = $args{dir};
1062 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1063 my @actions = ();
1064 my %extinfo = ( dso => $dsoext,
1065 lib => $libext,
1066 bin => $exeext );
1067
1068 foreach my $type (("dso", "lib", "bin", "script")) {
1069 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
Richard Levitte850000a2016-06-28 14:02:44 +02001070 # For lib object files, we could update the library. However, it
1071 # was decided that it's enough to build the directory local object
1072 # files, so we don't need to add any actions, and the dependencies
1073 # are already taken care of.
1074 if ($type ne "lib") {
Richard Levitte0ad1d942016-04-02 22:26:38 +02001075 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1076 if (dirname($prod) eq $dir) {
1077 push @deps, $prod.$extinfo{$type};
1078 } else {
1079 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1080 }
1081 }
1082 }
1083 }
1084
1085 my $deps = join(" ", @deps);
1086 my $actions = join("\n", "", @actions);
1087 return <<"EOF";
1088$args{dir} $args{dir}/: $deps$actions
1089EOF
1090 }
Richard Levitte567a9e62016-01-30 03:25:40 +01001091 "" # Important! This becomes part of the template result.
1092-}