]> git.ipfire.org Git - thirdparty/openssl.git/blame - Configurations/unix-Makefile.tmpl
Simplify the handling of shared library version numbers
[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";
11 our $shlibextsimple = $target{shared_extension_simple} || ".so";
12 our $shlibextimport = $target{shared_import_extension} || "";
13 our $dsoext = $target{dso_extension} || ".so";
14
567a9e6f 15 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
f5c174ff 16
d4453024
RL
17 our $sover_dirname = $config{shlib_version_number};
18 $sover_dirname =~ s|\.|_|g
19 if $config{target} =~ /^mingw/;
b2de11c5 20
f5c174ff
RL
21 # 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 {
f5c174ff 41 my $lib = shift;
33105818 42 return () if $disabled{shared} || $lib =~ /\.a$/;
d4453024 43 return $unified_info{sharednames}->{$lib} . '$(SHLIB_EXT)';
f5c174ff
RL
44 }
45 sub shlib_simple {
f5c174ff 46 my $lib = shift;
33105818
RL
47 return () if $disabled{shared} || $lib =~ /\.a$/;
48
f5c174ff 49 if (windowsdll()) {
d4453024 50 return $lib . '$(SHLIB_EXT_IMPORT)';
f5c174ff 51 }
d4453024 52 return $lib . '$(SHLIB_EXT_SIMPLE)';
f5c174ff
RL
53 }
54
33105818
RL
55 # Easy fixing of static library names
56 sub lib {
57 (my $lib = shift) =~ s/\.a$//;
58 return $lib . $libext;
59 }
60
f5c174ff
RL
61 # 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 {
f5c174ff
RL
65 my $engine = shift;
66
834aae2a 67 return $engine . $dsoext;
f5c174ff 68 }
27c40a93
BL
69 # 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 }
834aae2a 76 '';
567a9e6f
RL
77-}
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} -}
d4453024
RL
92SHLIB_EXT={- $shlibext -}
93SHLIB_EXT_SIMPLE={- $shlibextsimple -}
94SHLIB_EXT_IMPORT={- $shlibextimport -}
567a9e6f 95
33105818 96LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
f5c174ff 97SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
0f01b7bc 98SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
f5c174ff 99ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
1e3d16b0 100PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
567a9e6f 101SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
29eed3dd 102{- output_off() if $disabled{makedepend}; "" -}
834aae2a 103DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
c058fcd7
RL
104 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
105 keys %{$unified_info{sources}}); -}
29eed3dd 106{- output_on() if $disabled{makedepend}; "" -}
7cae3864 107GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
05a7aee0
RL
108GENERATED={- 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}} )) -}
c058fcd7 114
33105818 115INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
0f01b7bc
RL
116INSTALL_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}}) -}
df653379 120{- output_off() if $disabled{apps}; "" -}
567a9e6f 121BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
b8a9af68 122MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
df653379 123{- output_on() if $disabled{apps}; "" -}
567a9e6f 124
6a74806e
RL
125APPS_OPENSSL={- use File::Spec::Functions;
126 catfile("apps","openssl") -}
127
3c65577f
RL
128# DESTDIR is for package builders so that they can configure for, say,
129# /usr/ and yet have everything installed to /tmp/somedir/usr/.
567a9e6f 130# Normally it is left empty.
3c65577f 131DESTDIR=
567a9e6f
RL
132
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;
d4453024 166 catdir($prefix,$libdir,"engines-$sover_dirname") -}
567a9e6f 167
fad599f7
RL
168# Convenience variable for those who want to set the rpath in shared
169# libraries and applications
170LIBRPATH=$(INSTALLTOP)/$(LIBDIR)
171
dde10ab4 172MANDIR=$(INSTALLTOP)/share/man
8be7bdb5
RL
173DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
174HTMLDIR=$(DOCDIR)/html
567a9e6f 175
3544091a
RL
176# 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=
567a9e6f
RL
180HTMLSUFFIX=html
181
5407338a
RS
182# For "optional" echo messages, to get "real" silence
183ECHO = echo
567a9e6f
RL
184
185CROSS_COMPILE= {- $config{cross_compile_prefix} -}
186CC= $(CROSS_COMPILE){- $target{cc} -}
2952b9b8 187CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -}
076e596f 188CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
7763472f 189CXX= $(CROSS_COMPILE){- $target{cxx} -}
a60150e9 190CXXFLAGS={- our $cxxflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cxxflags} -} {- $config{cxxflags} -} -std=c++11
940a09ba
RL
191LDFLAGS= {- $target{lflags} -}
192PLIB_LDFLAGS= {- $target{plib_lflags} -}
2952b9b8 193EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
bbd9a50f 194LIB_CFLAGS={- $target{shared_cflag} || "" -}
7763472f 195LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -}
075f7e2c 196LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -}
45502bfe 197DSO_CFLAGS={- $target{shared_cflag} || "" -}
7763472f 198DSO_CXXFLAGS={- $target{shared_cxxflag} || "" -}
bbd9a50f 199DSO_LDFLAGS=$(LIB_LDFLAGS)
cba792a1 200BIN_CFLAGS={- $target{bin_cflags} -}
7763472f 201BIN_CXXFLAGS={- $target{bin_cxxflag} || "" -}
567a9e6f
RL
202
203PERL={- $config{perl} -}
204
205ARFLAGS= {- $target{arflags} -}
206AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
207RANLIB= {- $target{ranlib} -}
208NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
8f41ff2d
RL
209RCFLAGS={- $target{shared_rcflag} -}
210RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
567a9e6f 211RM= rm -f
98e5534e 212RMDIR= rmdir
567a9e6f
RL
213TAR= {- $target{tar} || "tar" -}
214TARFLAGS= {- $target{tarflags} -}
29eed3dd 215MAKEDEPEND={- $config{makedepprog} -}
567a9e6f
RL
216
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
9c7ce40b
AP
234# 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
567a9e6f
RL
243# The main targets ###################################################
244
1e3d16b0 245{- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
27c40a93
BL
246{- dependmagic('build_libs'); -}: build_libs_nodep
247{- dependmagic('build_engines'); -}: build_engines_nodep
1e3d16b0 248{- dependmagic('build_programs'); -}: build_programs_nodep
567a9e6f 249
27c40a93 250build_generated: $(GENERATED_MANDATORY)
c058fcd7 251build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
c058fcd7 252build_engines_nodep: $(ENGINES)
1e3d16b0
RL
253build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
254
255# Kept around for backward compatibility
256build_apps build_tests: build_programs
68a5f1a2 257
9b03b91b
RL
258# Convenience target to prebuild all generated files, not just the mandatory
259# ones
260build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
261
1b741653 262test: tests
1e3d16b0 263{- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
d90a6beb 264 @ : {- output_off() if $disabled{tests}; "" -}
567a9e6f
RL
265 ( cd test; \
266 SRCTOP=../$(SRCDIR) \
267 BLDTOP=../$(BLDDIR) \
cbece220 268 PERL="$(PERL)" \
834aae2a 269 EXE_EXT={- $exeext -} \
a717738b 270 OPENSSL_ENGINES=../$(BLDDIR)/engines \
6d4bc8a3 271 OPENSSL_DEBUG_MEMORY=on \
567a9e6f 272 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
d90a6beb
MC
273 @ : {- 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}; "" -}
567a9e6f
RL
276
277list-tests:
4813ad2d
RL
278 @ : {- 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
567a9e6f
RL
288
289libclean:
f99f91f1
RL
290 @set -e; for s in $(SHLIB_INFO); do \
291 s1=`echo "$$s" | cut -f1 -d";"`; \
292 s2=`echo "$$s" | cut -f2 -d";"`; \
5407338a 293 $(ECHO) $(RM) $$s1; \
f99f91f1
RL
294 $(RM) $$s1; \
295 if [ "$$s1" != "$$s2" ]; then \
5407338a 296 $(ECHO) $(RM) $$s2; \
f99f91f1
RL
297 $(RM) $$s2; \
298 fi; \
299 done
300 $(RM) $(LIBS)
4813ad2d 301 $(RM) *.map
567a9e6f
RL
302
303clean: libclean
4813ad2d
RL
304 $(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
9e183d22 309 $(RM) tags TAGS doc-nits
122fa088 310 $(RM) test/.rnd
4813ad2d
RL
311 $(RM) openssl.pc libcrypto.pc libssl.pc
312 -$(RM) `find . -type l -a \! -path "./.git/*"`
313 $(RM) $(TARFILE)
567a9e6f 314
7cae3864 315distclean: clean
4813ad2d
RL
316 $(RM) configdata.pm
317 $(RM) Makefile
7cae3864 318
f8d9d6e4 319# We check if any depfile is newer than Makefile and decide to
a6adf099 320# concatenate only if that is true.
ea80a25e 321depend:
29eed3dd 322 @: {- output_off() if $disabled{makedepend}; "" -}
d423c5ad 323 @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
ebca7961 324 ( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
f8d9d6e4
RL
325 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
326 echo; \
a6adf099
RL
327 for f in $(DEPS); do \
328 if [ -f $$f ]; then cat $$f; fi; \
f8d9d6e4 329 done ) > Makefile.new; \
29b28eee 330 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
f8d9d6e4 331 rm -f Makefile.new; \
29b28eee
RL
332 else \
333 mv -f Makefile.new Makefile; \
f8d9d6e4 334 fi; \
c058fcd7 335 fi
29eed3dd 336 @: {- output_on() if $disabled{makedepend}; "" -}
567a9e6f
RL
337
338# Install helper targets #############################################
339
340install_sw: all install_dev install_engines install_runtime
341
f99f91f1 342uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
567a9e6f
RL
343
344install_docs: install_man_docs install_html_docs
345
346uninstall_docs: uninstall_man_docs uninstall_html_docs
8be7bdb5 347 $(RM) -r -v $(DESTDIR)$(DOCDIR)
567a9e6f 348
dde10ab4
RL
349install_ssldirs:
350 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
351 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
66c2eb8b 352 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
4813ad2d
RL
353 @set -e; for x in dummy $(MISC_SCRIPTS); do \
354 if [ "$$x" = "dummy" ]; then continue; fi; \
355 fn=`basename $$x`; \
5407338a 356 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
4813ad2d
RL
357 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
5407338a 362 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
4813ad2d
RL
363 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
364 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
cb926df2 365 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
c7af65c7 366 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
5407338a 367 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
cb926df2
RL
368 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
369 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
370 fi
5407338a 371 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
c7af65c7
RS
372 @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 \
5407338a 376 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
c7af65c7
RS
377 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
378 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
379 fi
dde10ab4 380
567a9e6f
RL
381install_dev:
382 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 383 @$(ECHO) "*** Installing development files"
3c65577f 384 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
24c4f736 385 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
5407338a 386 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
24c4f736
RL
387 @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}}; "" -}
567a9e6f
RL
390 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
391 $(BLDDIR)/include/openssl/*.h; do \
392 fn=`basename $$i`; \
5407338a 393 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
3c65577f
RL
394 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
395 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 396 done
3c65577f 397 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
0f01b7bc 398 @set -e; for l in $(INSTALL_LIBS); do \
567a9e6f 399 fn=`basename $$l`; \
5407338a 400 $(ECHO) "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
3c65577f
RL
401 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; \
567a9e6f 406 done
84af1bae 407 @ : {- output_off() if $disabled{shared}; "" -}
0f01b7bc 408 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
c8c2b779
RL
409 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(); "" -}; \
5407338a 414 $(ECHO) "install $$s1 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
c8c2b779 415 cp $$s1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
3503549e 416 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
c8c2b779
RL
417 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new \
418 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
419 if [ "$$fn1" != "$$fn2" ]; then \
5407338a 420 $(ECHO) "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
c8c2b779 421 ln -sf $$fn1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
567a9e6f 422 fi; \
c8c2b779 423 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
5407338a 424 $(ECHO) "install $$s2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
c8c2b779 425 cp $$s2 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
3503549e 426 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
c8c2b779
RL
427 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new \
428 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
ce5ed82f 429 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 430 done
84af1bae 431 @ : {- output_on() if $disabled{shared}; "" -}
3c65577f 432 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
5407338a 433 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
3c65577f
RL
434 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
435 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
5407338a 436 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
3c65577f
RL
437 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
438 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
5407338a 439 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
3c65577f
RL
440 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
441 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
567a9e6f
RL
442
443uninstall_dev:
5407338a 444 @$(ECHO) "*** Uninstalling development files"
24c4f736 445 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
5407338a 446 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
24c4f736
RL
447 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
448 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
567a9e6f
RL
449 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
450 $(BLDDIR)/include/openssl/*.h; do \
451 fn=`basename $$i`; \
5407338a 452 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
3c65577f 453 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 454 done
98e5534e
RL
455 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
456 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
0f01b7bc 457 @set -e; for l in $(INSTALL_LIBS); do \
567a9e6f 458 fn=`basename $$l`; \
5407338a 459 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
3c65577f 460 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
567a9e6f 461 done
84af1bae 462 @ : {- output_off() if $disabled{shared}; "" -}
0f01b7bc 463 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
c8c2b779
RL
464 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(); "" -}; \
5407338a 469 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
c8c2b779
RL
470 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
471 if [ "$$fn1" != "$$fn2" ]; then \
5407338a 472 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
3c65577f 473 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
567a9e6f 474 fi; \
c8c2b779 475 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
5407338a 476 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
c8c2b779 477 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
ce5ed82f 478 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 479 done
c8cca980 480 @ : {- output_on() if $disabled{shared}; "" -}
b894054e
RL
481 $(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)
567a9e6f
RL
486
487install_engines:
488 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
b2de11c5 489 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
5407338a 490 @$(ECHO) "*** Installing engines"
0f01b7bc 491 @set -e; for e in dummy $(INSTALL_ENGINES); do \
2b364f61 492 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 493 fn=`basename $$e`; \
5407338a 494 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
b2de11c5
RL
495 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
496 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
497 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
498 $(DESTDIR)$(ENGINESDIR)/$$fn; \
567a9e6f
RL
499 done
500
501uninstall_engines:
5407338a 502 @$(ECHO) "*** Uninstalling engines"
0f01b7bc 503 @set -e; for e in dummy $(INSTALL_ENGINES); do \
2b364f61 504 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 505 fn=`basename $$e`; \
f0c93a85
RL
506 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
507 continue; \
508 fi; \
5407338a 509 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
b2de11c5 510 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
567a9e6f 511 done
b2de11c5 512 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
567a9e6f
RL
513
514install_runtime:
515 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
3c65577f 516 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
36b53720
RL
517 @ : {- output_off() if windowsdll(); "" -}
518 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
519 @ : {- output_on() if windowsdll(); "" -}
5407338a 520 @$(ECHO) "*** Installing runtime files"
0f01b7bc 521 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
2b364f61 522 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 523 fn=`basename $$s`; \
36b53720 524 : {- output_off() unless windowsdll(); "" -}; \
5407338a 525 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
526 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; \
36b53720 530 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
5407338a 531 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
36b53720
RL
532 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(); "" -}; \
fcf80c46 537 done
0f01b7bc 538 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
2b364f61 539 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 540 fn=`basename $$x`; \
5407338a 541 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
542 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; \
567a9e6f 546 done
2b364f61
RL
547 @set -e; for x in dummy $(BIN_SCRIPTS); do \
548 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 549 fn=`basename $$x`; \
5407338a 550 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
551 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; \
567a9e6f 555 done
567a9e6f
RL
556
557uninstall_runtime:
5407338a 558 @$(ECHO) "*** Uninstalling runtime files"
0f01b7bc 559 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
567a9e6f 560 do \
2b364f61 561 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 562 fn=`basename $$x`; \
5407338a 563 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 564 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 565 done;
2b364f61 566 @set -e; for x in dummy $(BIN_SCRIPTS); \
567a9e6f 567 do \
2b364f61 568 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 569 fn=`basename $$x`; \
5407338a 570 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 571 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 572 done
b1837abd 573 @ : {- output_off() unless windowsdll(); "" -}
0f01b7bc 574 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
2b364f61 575 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 576 fn=`basename $$s`; \
5407338a 577 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 578 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
fcf80c46 579 done
b1837abd 580 @ : {- output_on() unless windowsdll(); "" -}
b894054e 581 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
567a9e6f 582
567a9e6f
RL
583
584install_man_docs:
585 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 586 @$(ECHO) "*** Installing manpages"
cadb015b
RL
587 $(PERL) $(SRCDIR)/util/process_docs.pl \
588 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
567a9e6f
RL
589
590uninstall_man_docs:
5407338a 591 @$(ECHO) "*** Uninstalling manpages"
cadb015b
RL
592 $(PERL) $(SRCDIR)/util/process_docs.pl \
593 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
594 --remove
567a9e6f
RL
595
596install_html_docs:
597 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 598 @$(ECHO) "*** Installing HTML manpages"
cadb015b
RL
599 $(PERL) $(SRCDIR)/util/process_docs.pl \
600 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
567a9e6f
RL
601
602uninstall_html_docs:
5407338a 603 @$(ECHO) "*** Uninstalling manpages"
cadb015b
RL
604 $(PERL) $(SRCDIR)/util/process_docs.pl \
605 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
567a9e6f
RL
606
607
608# Developer targets (note: these are only available on Unix) #########
609
6bb2106e
RL
610update: generate errors ordinals
611
b7650c67
RL
612generate: generate_apps generate_crypto_bn generate_crypto_objects \
613 generate_crypto_conf generate_crypto_asn1
567a9e6f 614
65c1f979 615doc-nits:
1722496f 616 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
9e183d22 617 if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
65c1f979 618
567a9e6f
RL
619# Test coverage is a good idea for the future
620#coverage: $(PROGRAMS) $(TESTPROGRAMS)
621# ...
622
567a9e6f
RL
623lint:
624 lint -DLINT $(INCLUDES) $(SRCS)
625
9a9f8ee7
RL
626generate_apps:
627 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
628 < apps/openssl.cnf > apps/openssl-vms.cnf )
9a9f8ee7
RL
629
630generate_crypto_bn:
631 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
632
633generate_crypto_objects:
9a9f8ee7
RL
634 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
635 crypto/objects/objects.txt \
636 crypto/objects/obj_mac.num \
637 include/openssl/obj_mac.h )
e6f2bb66
KM
638 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
639 include/openssl/obj_mac.h \
640 crypto/objects/obj_dat.h )
9a9f8ee7
RL
641 ( 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 )
6bb2106e 645
b7650c67
RL
646generate_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
52df25cf
RS
654# Set to -force to force a rebuild
655ERROR_REBUILD=
567a9e6f
RL
656errors:
657 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
52df25cf 658 ( cd $(SRCDIR); $(PERL) util/mkerr.pl $(ERROR_REBUILD) -internal )
567a9e6f 659 ( cd $(SRCDIR)/engines; \
52df25cf
RS
660 for E in *.ec ; do \
661 $(PERL) ../util/mkerr.pl $(ERROR_REBUILD) -static \
662 -conf $$E `basename $$E .ec`.c ; \
663 done )
567a9e6f
RL
664
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
a1bce642 682TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
54bb8f74 683PREPARE_CMD=:
567a9e6f
RL
684tar:
685 TMPDIR=/var/tmp/openssl-copy.$$$$; \
54bb8f74 686 DISTDIR=$(NAME); \
567a9e6f
RL
687 mkdir -p $$TMPDIR/$$DISTDIR; \
688 (cd $(SRCDIR); \
689 git ls-tree -r --name-only --full-tree HEAD \
a1bce642 690 | grep -v '^fuzz/corpora' \
567a9e6f
RL
691 | while read F; do \
692 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
693 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
694 done); \
695 (cd $$TMPDIR; \
54bb8f74 696 $(PREPARE_CMD); \
567a9e6f
RL
697 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
698 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
699 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
54bb8f74 700 $(TAR_COMMAND) $$DISTDIR) \
567a9e6f
RL
701 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
702 rm -rf $$TMPDIR
703 cd $(SRCDIR); ls -l $(TARFILE).gz
704
705dist:
12ccb021 706 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' tar
567a9e6f
RL
707
708# Helper targets #####################################################
709
342a1a23 710link-utils: $(BLDDIR)/util/opensslwrap.sh
567a9e6f 711
27f42b46 712$(BLDDIR)/util/opensslwrap.sh: configdata.pm
567a9e6f
RL
713 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
714 mkdir -p "$(BLDDIR)/util"; \
715 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
716 fi
342a1a23 717
c058fcd7 718FORCE:
567a9e6f
RL
719
720# Building targets ###################################################
721
8478a703 722libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
567a9e6f
RL
723libcrypto.pc:
724 @ ( echo 'prefix=$(INSTALLTOP)'; \
725 echo 'exec_prefix=$${prefix}'; \
726 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
727 echo 'includedir=$${prefix}/include'; \
d4453024 728 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
567a9e6f
RL
729 echo ''; \
730 echo 'Name: OpenSSL-libcrypto'; \
731 echo 'Description: OpenSSL cryptography library'; \
732 echo 'Version: '$(VERSION); \
733 echo 'Libs: -L$${libdir} -lcrypto'; \
734 echo 'Libs.private: $(EX_LIBS)'; \
735 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
736
737libssl.pc:
738 @ ( echo 'prefix=$(INSTALLTOP)'; \
739 echo 'exec_prefix=$${prefix}'; \
740 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
741 echo 'includedir=$${prefix}/include'; \
742 echo ''; \
743 echo 'Name: OpenSSL-libssl'; \
744 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
745 echo 'Version: '$(VERSION); \
746 echo 'Requires.private: libcrypto'; \
747 echo 'Libs: -L$${libdir} -lssl'; \
748 echo 'Libs.private: $(EX_LIBS)'; \
749 echo 'Cflags: -I$${includedir}' ) > libssl.pc
750
751openssl.pc:
752 @ ( echo 'prefix=$(INSTALLTOP)'; \
753 echo 'exec_prefix=$${prefix}'; \
754 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
755 echo 'includedir=$${prefix}/include'; \
756 echo ''; \
757 echo 'Name: OpenSSL'; \
758 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
759 echo 'Version: '$(VERSION); \
760 echo 'Requires: libssl libcrypto' ) > openssl.pc
761
41240e68 762configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
27f42b46 763 @echo "Detected changed: $?"
567a9e6f 764 @echo "Reconfiguring..."
12ccb021 765 $(PERL) $(SRCDIR)/Configure reconf
567a9e6f
RL
766 @echo "**************************************************"
767 @echo "*** ***"
768 @echo "*** Please run the same make command again ***"
769 @echo "*** ***"
770 @echo "**************************************************"
771 @false
772
773{-
774 use File::Basename;
775 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
cedbb146
RL
776
777 # Helper function to figure out dependencies on libraries
778 # It takes a list of library names and outputs a list of dependencies
779 sub compute_lib_depends {
84af1bae 780 if ($disabled{shared}) {
33105818 781 return map { lib($_) } @_;
cedbb146
RL
782 }
783
784 # Depending on shared libraries:
785 # On Windows POSIX layers, we depend on {libname}.dll.a
786 # On Unix platforms, we depend on {shlibname}.so
186a31e5 787 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
cedbb146
RL
788 }
789
66ddf178
RL
790 sub generatesrc {
791 my %args = @_;
792 my $generator = join(" ", @{$args{generator}});
8d34daf0 793 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
d4605727 794 my $incs = join("", map { " -I".$_ } @{$args{incs}});
8d34daf0 795 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
66ddf178
RL
796
797 if ($args{src} !~ /\.[sS]$/) {
7cae3864
RL
798 if ($args{generator}->[0] =~ m|^.*\.in$|) {
799 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
800 "util", "dofile.pl")),
801 rel2abs($config{builddir}));
802 return <<"EOF";
803$args{src}: $args{generator}->[0] $deps
804 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
805 "-o$target{build_file}" $generator > \$@
806EOF
807 } else {
808 return <<"EOF";
769777b0 809$args{src}: $args{generator}->[0] $deps
8d34daf0 810 \$(PERL)$generator_incs $generator > \$@
66ddf178 811EOF
7cae3864 812 }
66ddf178 813 } else {
8458f1bf 814 if ($args{generator}->[0] =~ /\.pl$/) {
8d34daf0 815 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
8458f1bf 816 } elsif ($args{generator}->[0] =~ /\.m4$/) {
8d34daf0 817 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
8458f1bf
RL
818 } elsif ($args{generator}->[0] =~ /\.S$/) {
819 $generator = undef;
820 } else {
821 die "Generator type for $args{src} unknown: $generator\n";
822 }
823
824 if (defined($generator)) {
825 # If the target is named foo.S in build.info, we want to
826 # end up generating foo.s in two steps.
827 if ($args{src} =~ /\.S$/) {
828 (my $target = $args{src}) =~ s|\.S$|.s|;
829 return <<"EOF";
769777b0 830$target: $args{generator}->[0] $deps
0218fc37 831 ( trap "rm -f \$@.*" INT 0; \\
8458f1bf 832 $generator \$@.S; \\
57ade571 833 \$(CC) $incs \$(CFLAGS) -E \$@.S | \\
39199fb3
AP
834 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
835 mv -f \$@.i \$@ )
66ddf178 836EOF
8458f1bf
RL
837 }
838 # Otherwise....
66ddf178 839 return <<"EOF";
769777b0 840$args{src}: $args{generator}->[0] $deps
8458f1bf 841 $generator \$@
66ddf178 842EOF
66ddf178 843 }
8458f1bf 844 return <<"EOF";
769777b0 845$args{src}: $args{generator}->[0] $deps
57ade571 846 \$(CC) $incs \$(CFLAGS) -E \$< | \\
39199fb3 847 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
8458f1bf 848EOF
66ddf178
RL
849 }
850 }
851
bb26842d
RL
852 # Should one wonder about the end of the Perl snippet, it's because this
853 # second regexp eats up line endings as well, if the removed path is the
854 # last in the line. We may therefore need to put back a line ending.
88297284 855 sub src2obj {
567a9e6f 856 my %args = @_;
88297284 857 my $obj = $args{obj};
674d5858
RL
858 my @srcs = map { if ($unified_info{generate}->{$_}) {
859 (my $x = $_) =~ s/\.S$/.s/; $x
860 } else {
861 $_
862 }
863 } ( @{$args{srcs}} );
8458f1bf
RL
864 my $srcs = join(" ", @srcs);
865 my $deps = join(" ", @srcs, @{$args{deps}});
45502bfe 866 my $incs = join("", map { " -I".$_ } @{$args{incs}});
da430a55
RL
867 unless ($disabled{zlib}) {
868 if ($withargs{zlib_include}) {
869 $incs .= " -I".$withargs{zlib_include};
870 }
871 }
7763472f
RL
872 my $cc = '$(CC)';
873 my $cflags = '$(CFLAGS)';
874 if (grep /\.(cc|cpp)$/, @srcs) {
875 $cc = '$(CXX)';
876 $cflags = '$(CXXFLAGS)';
877 $cflags .= ' ' . { lib => '$(LIB_CXXFLAGS)',
878 dso => '$(DSO_CXXFLAGS)',
879 bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}};
880 } else {
881 $cflags .= ' ' . { lib => '$(LIB_CFLAGS)',
882 dso => '$(DSO_CFLAGS)',
883 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
884 }
567a9e6f 885 my $makedepprog = $config{makedepprog};
7e5b8b93
RL
886 my $recipe = <<"EOF";
887$obj$objext: $deps
888EOF
889 if (!$disabled{makedepend} && $makedepprog !~ /\/makedepend/) {
29eed3dd 890 $recipe .= <<"EOF";
7763472f 891 $cc $incs $cflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
7e5b8b93
RL
892 \@touch $obj$depext.tmp
893 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
894 rm -f $obj$depext.tmp; \\
29b28eee 895 else \\
7e5b8b93 896 mv $obj$depext.tmp $obj$depext; \\
987dbc7f 897 fi
29eed3dd 898EOF
7e5b8b93 899 } else {
29eed3dd 900 $recipe .= <<"EOF";
7763472f 901 $cc $incs $cflags -c -o \$\@ $srcs
567a9e6f 902EOF
7e5b8b93
RL
903 if (!$disabled{makedepend} && $makedepprog =~ /\/makedepend/) {
904 $recipe .= <<"EOF";
7763472f 905 -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cflags -- $srcs \\
7e5b8b93
RL
906 >$obj$depext.tmp 2>/dev/null
907 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
29b28eee 908 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
987dbc7f 909 rm -f $obj$depext.tmp; \\
29b28eee
RL
910 else \\
911 mv $obj$depext.tmp $obj$depext; \\
340da949 912 fi
567a9e6f 913EOF
7e5b8b93 914 }
29eed3dd
RL
915 }
916 return $recipe;
567a9e6f
RL
917 }
918 # On Unix, we build shlibs from static libs, so we're ignoring the
919 # object file array. We *know* this routine is only called when we've
920 # configure 'shared'.
921 sub libobj2shlib {
922 my %args = @_;
923 my $lib = $args{lib};
924 my $shlib = $args{shlib};
925 my $libd = dirname($lib);
926 my $libn = basename($lib);
927 (my $libname = $libn) =~ s/^lib//;
cedbb146
RL
928 my $linklibs = join("", map { my $d = dirname($_);
929 my $f = basename($_);
930 (my $l = $f) =~ s/^lib//;
931 " -L$d -l$l" } @{$args{deps}});
932 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
567a9e6f
RL
933 my $shlib_target = $target{shared_target};
934 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
f5c174ff 935 my $target = shlib_simple($lib);
d07abe13 936 my $target_full = shlib($lib);
567a9e6f 937 return <<"EOF"
cedbb146
RL
938# With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
939# that two files get produced, {shlibname}.dll and {libname}.dll.a.
940# With all other Unix platforms, we often build a shared library with the
941# SO version built into the file name and a symlink without the SO version
942# It's not necessary to have both as targets. The choice falls on the
d4453024
RL
943# simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
944# {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
834aae2a 945$target: $lib$libext $deps $ordinalsfile
567a9e6f 946 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
5407338a 947 ECHO=\$(ECHO) \\
cedbb146 948 PLATFORM=\$(PLATFORM) \\
cbece220 949 PERL="\$(PERL)" SRCDIR='\$(SRCDIR)' DSTDIR="$libd" \\
8a0a3d29
RL
950 INSTALLTOP='\$(INSTALLTOP)' LIBDIR='\$(LIBDIR)' \\
951 LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
d4453024 952 LIBNAME=$libname SHLIBVERSION=\$(SHLIB_VERSION_NUMBER) \\
d07abe13
RL
953 STLIBNAME=$lib$libext \\
954 SHLIBNAME=$target SHLIBNAME_FULL=$target_full \\
8a0a3d29 955 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(LIB_CFLAGS)' \\
d07abe13 956 LDFLAGS='\$(LDFLAGS)' SHARED_LDFLAGS='\$(LIB_LDFLAGS)' \\
8f41ff2d 957 RC='\$(RC)' SHARED_RCFLAGS='\$(RCFLAGS)' \\
e048fd51 958 link_shlib.$shlib_target
fcf80c46
RL
959EOF
960 . (windowsdll() ? <<"EOF" : "");
d4453024
RL
961 rm -f apps/$shlib'\$(SHLIB_EXT)'
962 rm -f test/$shlib'\$(SHLIB_EXT)'
963 cp -p $shlib'\$(SHLIB_EXT)' apps/
964 cp -p $shlib'\$(SHLIB_EXT)' test/
567a9e6f
RL
965EOF
966 }
5386287c 967 sub obj2dso {
567a9e6f 968 my %args = @_;
d07abe13
RL
969 my $dso = $args{lib};
970 my $dsod = dirname($dso);
971 my $dson = basename($dso);
567a9e6f
RL
972 my $shlibdeps = join("", map { my $d = dirname($_);
973 my $f = basename($_);
974 (my $l = $f) =~ s/^lib//;
975 " -L$d -l$l" } @{$args{deps}});
cedbb146 976 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
567a9e6f 977 my $shlib_target = $target{shared_target};
834aae2a 978 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
d07abe13 979 my $target = dso($dso);
567a9e6f 980 return <<"EOF";
f5c174ff 981$target: $objs $deps
567a9e6f 982 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
cedbb146 983 PLATFORM=\$(PLATFORM) \\
d07abe13 984 PERL="\$(PERL)" SRCDIR='\$(SRCDIR)' DSTDIR="$dsod" \\
8a0a3d29 985 LIBDEPS='\$(PLIB_LDFLAGS) '"$shlibdeps"' \$(EX_LIBS)' \\
d07abe13 986 SHLIBNAME_FULL=$target LDFLAGS='\$(LDFLAGS)' \\
8a0a3d29
RL
987 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(DSO_CFLAGS)' \\
988 SHARED_LDFLAGS='\$(DSO_LDFLAGS)' \\
567a9e6f 989 LIBEXTRAS="$objs" \\
e048fd51 990 link_dso.$shlib_target
567a9e6f
RL
991EOF
992 }
993 sub obj2lib {
994 my %args = @_;
33105818 995 (my $lib = $args{lib}) =~ s/\.a$//;
834aae2a 996 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
567a9e6f 997 return <<"EOF";
834aae2a 998$lib$libext: $objs
68cd4e3f 999 \$(AR) \$\@ \$\?
567a9e6f
RL
1000 \$(RANLIB) \$\@ || echo Never mind.
1001EOF
1002 }
1003 sub obj2bin {
1004 my %args = @_;
1005 my $bin = $args{bin};
1006 my $bind = dirname($bin);
1007 my $binn = basename($bin);
834aae2a 1008 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
cedbb146 1009 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
186a31e5
RL
1010 my $linklibs = join("", map { if ($_ =~ /\.a$/) {
1011 " $_";
1012 } else {
1013 my $d = dirname($_);
1014 my $f = basename($_);
1015 $d = "." if $d eq $f;
1016 (my $l = $f) =~ s/^lib//;
1017 " -L$d -l$l"
1018 }
1019 } @{$args{deps}});
84af1bae 1020 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
7763472f
RL
1021 my $cc = '$(CC)';
1022 my $cflags = '$(CFLAGS) $(BIN_CFLAGS)';
1023 if (grep /_cc$/, @{$args{objs}}) {
1024 $cc = '$(CXX)';
1025 $cflags = '$(CXXFLAGS) $(BIN_CXXFLAGS)';
1026 }
567a9e6f 1027 return <<"EOF";
834aae2a
BL
1028$bin$exeext: $objs $deps
1029 \$(RM) $bin$exeext
567a9e6f 1030 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
cbece220 1031 PERL="\$(PERL)" SRCDIR=\$(SRCDIR) \\
834aae2a 1032 APPNAME=$bin$exeext OBJECTS="$objs" \\
8a0a3d29 1033 LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
7763472f 1034 CC='$cc' CFLAGS='$cflags' \\
fad599f7 1035 LDFLAGS='\$(LDFLAGS)' \\
567a9e6f
RL
1036 link_app.$shlib_target
1037EOF
1038 }
1039 sub in2script {
1040 my %args = @_;
1041 my $script = $args{script};
1042 my $sources = join(" ", @{$args{sources}});
1043 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1044 "util", "dofile.pl")),
1045 rel2abs($config{builddir}));
1046 return <<"EOF";
88297284 1047$script: $sources
4b799cea 1048 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
ba327ade 1049 "-o$target{build_file}" $sources > "$script"
567a9e6f 1050 chmod a+x $script
0ad1d94d
RL
1051EOF
1052 }
1053 sub generatedir {
1054 my %args = @_;
1055 my $dir = $args{dir};
1056 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1057 my @actions = ();
1058 my %extinfo = ( dso => $dsoext,
1059 lib => $libext,
1060 bin => $exeext );
1061
1062 foreach my $type (("dso", "lib", "bin", "script")) {
1063 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
850000aa
RL
1064 # For lib object files, we could update the library. However, it
1065 # was decided that it's enough to build the directory local object
1066 # files, so we don't need to add any actions, and the dependencies
1067 # are already taken care of.
1068 if ($type ne "lib") {
0ad1d94d
RL
1069 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1070 if (dirname($prod) eq $dir) {
1071 push @deps, $prod.$extinfo{$type};
1072 } else {
1073 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1074 }
1075 }
1076 }
1077 }
1078
1079 my $deps = join(" ", @deps);
1080 my $actions = join("\n", "", @actions);
1081 return <<"EOF";
1082$args{dir} $args{dir}/: $deps$actions
567a9e6f
RL
1083EOF
1084 }
1085 "" # Important! This becomes part of the template result.
1086-}