]> git.ipfire.org Git - thirdparty/openssl.git/blame - Configurations/unix-Makefile.tmpl
Avoid msys name mangling
[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
RL
16
17 # shlib and shlib_simple both take a static library name and figure
18 # out what the shlib name should be.
19 #
20 # When OpenSSL is configured "no-shared", these functions will just
21 # return empty lists, making them suitable to join().
22 #
23 # With Windows DLL producers, shlib($libname) will return the shared
24 # library name (which usually is different from the static library
25 # name) with the default shared extension appended to it, while
26 # shlib_simple($libname) will return the static library name with
27 # the shared extension followed by ".a" appended to it. The former
28 # result is used as the runtime shared library while the latter is
29 # used as the DLL import library.
30 #
31 # On all Unix systems, shlib($libname) will return the library name
32 # with the default shared extension, while shlib_simple($libname)
33 # will return the name from shlib($libname) with any SO version number
34 # removed. On some systems, they may therefore return the exact same
35 # string.
36 sub shlib {
84af1bae 37 return () if $disabled{shared};
f5c174ff 38 my $lib = shift;
834aae2a 39 return $unified_info{sharednames}->{$lib} . $shlibext;
f5c174ff
RL
40 }
41 sub shlib_simple {
84af1bae 42 return () if $disabled{shared};
f5c174ff
RL
43
44 my $lib = shift;
45 if (windowsdll()) {
834aae2a 46 return $lib . $shlibextimport;
f5c174ff 47 }
834aae2a 48 return $lib . $shlibextsimple;
f5c174ff
RL
49 }
50
51 # dso is a complement to shlib / shlib_simple that returns the
52 # given libname with the simple shared extension (possible SO version
53 # removed). This differs from shlib_simple() by being unconditional.
54 sub dso {
f5c174ff
RL
55 my $engine = shift;
56
834aae2a 57 return $engine . $dsoext;
f5c174ff 58 }
834aae2a 59 '';
567a9e6f
RL
60-}
61PLATFORM={- $config{target} -}
62OPTIONS={- $config{options} -}
63CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
64SRCDIR={- $config{sourcedir} -}
65BLDDIR={- $config{builddir} -}
66
67VERSION={- $config{version} -}
68MAJOR={- $config{major} -}
69MINOR={- $config{minor} -}
70SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
71SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
72SHLIB_MAJOR={- $config{shlib_major} -}
73SHLIB_MINOR={- $config{shlib_minor} -}
74SHLIB_TARGET={- $target{shared_target} -}
75
834aae2a 76LIBS={- join(" ", map { $_.$libext } @{$unified_info{libraries}}) -}
f5c174ff
RL
77SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
78ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
834aae2a
BL
79PROGRAMS={- join(" ", map { $_.$exeext } grep { !m|^test/| } @{$unified_info{programs}}) -}
80TESTPROGS={- join(" ", map { $_.$exeext } grep { m|^test/| } @{$unified_info{programs}}) -}
567a9e6f 81SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
29eed3dd 82{- output_off() if $disabled{makedepend}; "" -}
834aae2a 83DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
c058fcd7
RL
84 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
85 keys %{$unified_info{sources}}); -}
29eed3dd 86{- output_on() if $disabled{makedepend}; "" -}
05a7aee0
RL
87GENERATED={- join(" ",
88 ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
89 grep { defined $unified_info{generate}->{$_} }
90 map { @{$unified_info{sources}->{$_}} }
91 grep { /\.o$/ } keys %{$unified_info{sources}} ),
92 ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -}
c058fcd7 93
df653379 94{- output_off() if $disabled{apps}; "" -}
567a9e6f
RL
95BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
96MISC_SCRIPTS=$(SRCDIR)/tools/c_hash $(SRCDIR)/tools/c_info \
97 $(SRCDIR)/tools/c_issuer $(SRCDIR)/tools/c_name \
2d5a1cfa 98 $(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
df653379 99{- output_on() if $disabled{apps}; "" -}
567a9e6f 100
c8c2b779
RL
101SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
102
3c65577f
RL
103# DESTDIR is for package builders so that they can configure for, say,
104# /usr/ and yet have everything installed to /tmp/somedir/usr/.
567a9e6f 105# Normally it is left empty.
3c65577f 106DESTDIR=
567a9e6f
RL
107
108# Do not edit these manually. Use Configure with --prefix or --openssldir
109# to change this! Short explanation in the top comment in Configure
110INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
111 #
112 our $prefix = $config{prefix} || "/usr/local";
113 $prefix -}
114OPENSSLDIR={- #
115 # The logic here is that if no --openssldir was given,
116 # OPENSSLDIR will get the value from $prefix plus "/ssl".
117 # If --openssldir was given and the value is an absolute
118 # path, OPENSSLDIR will get its value without change.
119 # If the value from --openssldir is a relative path,
120 # OPENSSLDIR will get $prefix with the --openssldir
121 # value appended as a subdirectory.
122 #
123 use File::Spec::Functions;
124 our $openssldir =
125 $config{openssldir} ?
126 (file_name_is_absolute($config{openssldir}) ?
127 $config{openssldir}
128 : catdir($prefix, $config{openssldir}))
129 : catdir($prefix, "ssl");
130 $openssldir -}
131LIBDIR={- #
132 # if $prefix/lib$target{multilib} is not an existing
133 # directory, then assume that it's not searched by linker
134 # automatically, in which case adding $target{multilib} suffix
135 # causes more grief than we're ready to tolerate, so don't...
136 our $multilib =
137 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
138 our $libdir = $config{libdir} || "lib$multilib";
139 $libdir -}
140ENGINESDIR={- use File::Spec::Functions;
141 catdir($prefix,$libdir,"engines") -}
142
dde10ab4 143MANDIR=$(INSTALLTOP)/share/man
8be7bdb5
RL
144DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
145HTMLDIR=$(DOCDIR)/html
567a9e6f 146
3544091a
RL
147# MANSUFFIX is for the benefit of anyone who may want to have a suffix
148# appended after the manpage file section number. "ssl" is popular,
149# resulting in files such as config.5ssl rather than config.5.
150MANSUFFIX=
567a9e6f
RL
151HTMLSUFFIX=html
152
153
154
155CROSS_COMPILE= {- $config{cross_compile_prefix} -}
156CC= $(CROSS_COMPILE){- $target{cc} -}
2952b9b8 157CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -}
076e596f 158CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
940a09ba
RL
159LDFLAGS= {- $target{lflags} -}
160PLIB_LDFLAGS= {- $target{plib_lflags} -}
2952b9b8 161EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
bbd9a50f
RL
162LIB_CFLAGS={- $target{shared_cflag} || "" -}
163LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag}
164 # Unlike other OSes (like Solaris, Linux, Tru64,
165 # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
166 # and FreeBSD) "demand" RPATH set on .so objects.
167 # Apparently application RPATH is not global and
168 # does not apply to .so linked with other .so.
169 # Problem manifests itself when libssl.so fails to
170 # load libcrypto.so. One can argue that we should
171 # engrave this into Makefile.shared rules or into
172 # BSD-* config lines above. Meanwhile let's try to
173 # be cautious and pass -rpath to linker only when
174 # $prefix is not /usr.
175 . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
176 ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
45502bfe 177DSO_CFLAGS={- $target{shared_cflag} || "" -}
bbd9a50f 178DSO_LDFLAGS=$(LIB_LDFLAGS)
cba792a1 179BIN_CFLAGS={- $target{bin_cflags} -}
567a9e6f
RL
180
181PERL={- $config{perl} -}
182
183ARFLAGS= {- $target{arflags} -}
184AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
185RANLIB= {- $target{ranlib} -}
186NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
8f41ff2d
RL
187RCFLAGS={- $target{shared_rcflag} -}
188RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
567a9e6f 189RM= rm -f
98e5534e 190RMDIR= rmdir
567a9e6f
RL
191TAR= {- $target{tar} || "tar" -}
192TARFLAGS= {- $target{tarflags} -}
29eed3dd 193MAKEDEPEND={- $config{makedepprog} -}
567a9e6f
RL
194
195BASENAME= openssl
196NAME= $(BASENAME)-$(VERSION)
197TARFILE= ../$(NAME).tar
198
199# We let the C compiler driver to take care of .s files. This is done in
200# order to be excused from maintaining a separate set of architecture
201# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
202# gcc, then the driver will automatically translate it to -xarch=v8plus
203# and pass it down to assembler.
204AS=$(CC) -c
205ASFLAG=$(CFLAGS)
206PERLASM_SCHEME= {- $target{perlasm_scheme} -}
207
208# For x86 assembler: Set PROCESSOR to 386 if you want to support
209# the 80386.
210PROCESSOR= {- $config{processor} -}
211
212# The main targets ###################################################
213
27f42b46 214all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep \
c058fcd7 215 depend link-utils
567a9e6f 216
27f42b46 217build_libs: configdata.pm build_libs_nodep depend
c058fcd7 218build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
27f42b46 219build_engines: configdata.pm build_engines_nodep depend
c058fcd7 220build_engines_nodep: $(ENGINES)
27f42b46 221build_apps: configdata.pm build_apps_nodep depend
c058fcd7 222build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
27f42b46 223build_tests: configdata.pm build_tests_nodep depend
c058fcd7 224build_tests_nodep: $(TESTPROGS)
68a5f1a2 225
1b741653
RL
226test: tests
227tests: build_tests_nodep build_apps_nodep build_engines_nodep \
228 depend link-utils
d90a6beb 229 @ : {- output_off() if $disabled{tests}; "" -}
567a9e6f
RL
230 ( cd test; \
231 SRCTOP=../$(SRCDIR) \
232 BLDTOP=../$(BLDDIR) \
834aae2a 233 EXE_EXT={- $exeext -} \
a717738b 234 OPENSSL_ENGINES=../$(BLDDIR)/engines \
567a9e6f 235 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
d90a6beb
MC
236 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
237 @echo "Tests are not supported with your chosen Configure options"
238 @ : {- output_on() if !$disabled{tests}; "" -}
567a9e6f
RL
239
240list-tests:
241 @TOP=$(SRCDIR) PERL=$(PERL) $(PERL) $(SRCDIR)/test/run_tests.pl list
242
243libclean:
f99f91f1
RL
244 @set -e; for s in $(SHLIB_INFO); do \
245 s1=`echo "$$s" | cut -f1 -d";"`; \
246 s2=`echo "$$s" | cut -f2 -d";"`; \
247 echo $(RM) $$s1; \
248 $(RM) $$s1; \
249 if [ "$$s1" != "$$s2" ]; then \
250 echo $(RM) $$s2; \
251 $(RM) $$s2; \
252 fi; \
253 done
254 $(RM) $(LIBS)
567a9e6f 255
dde10ab4 256install: install_sw install_ssldirs install_docs
567a9e6f
RL
257
258uninstall: uninstall_docs uninstall_sw
259
260clean: libclean
4c1cf7e4
RL
261 rm -f $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
262 rm -f $(GENERATED)
263 -rm -f `find . -name '*{- $depext -}'`
264 -rm -f `find . -name '*{- $objext -}'`
265 rm -f core
266 rm -f tags TAGS
267 rm -f openssl.pc libcrypto.pc libssl.pc
1b4d0e3c 268 -rm -f `find . -type l -a \! -path "./.git/*"`
567a9e6f
RL
269 rm -f $(TARFILE)
270
c058fcd7 271# This exists solely for those who still type 'make depend'
f8d9d6e4
RL
272#
273# We check if any depfile is newer than Makefile and decide to
a6adf099 274# concatenate only if that is true.
ea80a25e 275depend:
29eed3dd 276 @: {- output_off() if $disabled{makedepend}; "" -}
e3d81858 277 @if [ -n "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then \
f8d9d6e4
RL
278 ( sed -e '/^# DO NOT DELETE THIS LINE.*/,$$d' < Makefile; \
279 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
280 echo; \
a6adf099
RL
281 for f in $(DEPS); do \
282 if [ -f $$f ]; then cat $$f; fi; \
f8d9d6e4 283 done ) > Makefile.new; \
29b28eee 284 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
f8d9d6e4 285 rm -f Makefile.new; \
29b28eee
RL
286 else \
287 mv -f Makefile.new Makefile; \
f8d9d6e4 288 fi; \
c058fcd7 289 fi
29eed3dd 290 @: {- output_on() if $disabled{makedepend}; "" -}
567a9e6f
RL
291
292# Install helper targets #############################################
293
294install_sw: all install_dev install_engines install_runtime
295
f99f91f1 296uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
567a9e6f
RL
297
298install_docs: install_man_docs install_html_docs
299
300uninstall_docs: uninstall_man_docs uninstall_html_docs
8be7bdb5 301 $(RM) -r -v $(DESTDIR)$(DOCDIR)
567a9e6f 302
dde10ab4
RL
303install_ssldirs:
304 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
305 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
306
567a9e6f
RL
307install_dev:
308 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
309 @echo "*** Installing development files"
3c65577f 310 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
567a9e6f
RL
311 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
312 $(BLDDIR)/include/openssl/*.h; do \
313 fn=`basename $$i`; \
3c65577f
RL
314 echo "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
315 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
316 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 317 done
3c65577f 318 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
567a9e6f
RL
319 @set -e; for l in $(LIBS); do \
320 fn=`basename $$l`; \
3c65577f
RL
321 echo "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
322 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
323 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
324 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
325 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
326 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
567a9e6f 327 done
84af1bae 328 @ : {- output_off() if $disabled{shared}; "" -}
c8c2b779
RL
329 @set -e; for s in $(SHLIB_INFO); do \
330 s1=`echo "$$s" | cut -f1 -d";"`; \
331 s2=`echo "$$s" | cut -f2 -d";"`; \
332 fn1=`basename $$s1`; \
333 fn2=`basename $$s2`; \
334 : {- output_off() if windowsdll(); "" -}; \
335 echo "install $$s1 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
336 cp $$s1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
337 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
338 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new \
339 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
340 if [ "$$fn1" != "$$fn2" ]; then \
341 echo "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
342 ln -sf $$fn1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
567a9e6f 343 fi; \
c8c2b779
RL
344 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
345 echo "install $$s2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
346 cp $$s2 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
347 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
348 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new \
349 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
ce5ed82f 350 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 351 done
84af1bae 352 @ : {- output_on() if $disabled{shared}; "" -}
3c65577f
RL
353 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
354 @echo "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
355 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
356 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
357 @echo "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
358 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
359 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
360 @echo "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
361 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
362 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
567a9e6f
RL
363
364uninstall_dev:
365 @echo "*** Uninstalling development files"
366 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
367 $(BLDDIR)/include/openssl/*.h; do \
368 fn=`basename $$i`; \
3c65577f
RL
369 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
370 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 371 done
98e5534e
RL
372 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
373 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
567a9e6f
RL
374 @set -e; for l in $(LIBS); do \
375 fn=`basename $$l`; \
3c65577f
RL
376 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
377 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
567a9e6f 378 done
84af1bae 379 @ : {- output_off() if $disabled{shared}; "" -}
c8c2b779
RL
380 @set -e; for s in $(SHLIB_INFO); do \
381 s1=`echo "$$s" | cut -f1 -d";"`; \
382 s2=`echo "$$s" | cut -f2 -d";"`; \
383 fn1=`basename $$s1`; \
384 fn2=`basename $$s2`; \
385 : {- output_off() if windowsdll(); "" -}; \
386 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
387 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
388 if [ "$$fn1" != "$$fn2" ]; then \
3c65577f
RL
389 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
390 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
567a9e6f 391 fi; \
c8c2b779
RL
392 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
393 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
394 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
ce5ed82f 395 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 396 done
c8cca980 397 @ : {- output_on() if $disabled{shared}; "" -}
b894054e
RL
398 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
399 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
400 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
401 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
402 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
567a9e6f
RL
403
404install_engines:
405 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
3c65577f 406 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/
567a9e6f 407 @echo "*** Installing engines"
2b364f61
RL
408 @set -e; for e in dummy $(ENGINES); do \
409 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 410 fn=`basename $$e`; \
f0c93a85
RL
411 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
412 continue; \
413 fi; \
414 echo "install $$e -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn"; \
3c65577f
RL
415 cp $$e $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
416 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
417 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \
418 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
567a9e6f
RL
419 done
420
421uninstall_engines:
422 @echo "*** Uninstalling engines"
2b364f61
RL
423 @set -e; for e in dummy $(ENGINES); do \
424 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 425 fn=`basename $$e`; \
f0c93a85
RL
426 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
427 continue; \
428 fi; \
429 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn"; \
3c65577f 430 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
567a9e6f 431 done
b894054e 432 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines
567a9e6f
RL
433
434install_runtime:
435 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
3c65577f
RL
436 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
437 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
567a9e6f 438 @echo "*** Installing runtime files"
fcf80c46 439 : {- output_off() unless windowsdll(); "" -};
2b364f61
RL
440 @set -e; for s in dummy $(SHLIBS); do \
441 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 442 fn=`basename $$s`; \
3c65577f
RL
443 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
444 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
445 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
446 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
447 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
fcf80c46 448 done
dac494d2 449 : {- output_on() unless windowsdll(); "" -};
2b364f61
RL
450 @set -e; for x in dummy $(PROGRAMS); do \
451 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 452 fn=`basename $$x`; \
3c65577f
RL
453 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
454 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
455 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
456 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
457 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 458 done
2b364f61
RL
459 @set -e; for x in dummy $(BIN_SCRIPTS); do \
460 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 461 fn=`basename $$x`; \
3c65577f
RL
462 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
463 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
464 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
465 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
466 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 467 done
2b364f61
RL
468 @set -e; for x in dummy $(MISC_SCRIPTS); do \
469 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 470 fn=`basename $$x`; \
3c65577f
RL
471 echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
472 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
473 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
474 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
475 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
567a9e6f 476 done
3c65577f
RL
477 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"
478 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
479 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
480 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
567a9e6f
RL
481
482uninstall_runtime:
483 @echo "*** Uninstalling runtime files"
2b364f61 484 @set -e; for x in dummy $(PROGRAMS); \
567a9e6f 485 do \
2b364f61 486 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 487 fn=`basename $$x`; \
3c65577f
RL
488 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
489 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 490 done;
2b364f61 491 @set -e; for x in dummy $(BIN_SCRIPTS); \
567a9e6f 492 do \
2b364f61 493 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 494 fn=`basename $$x`; \
3c65577f
RL
495 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
496 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 497 done
2b364f61 498 @set -e; for x in dummy $(MISC_SCRIPTS); \
567a9e6f 499 do \
2b364f61 500 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 501 fn=`basename $$x`; \
3c65577f
RL
502 echo "$(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
503 $(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
567a9e6f 504 done
fcf80c46 505 : {- output_off() unless windowsdll(); "" -};
2b364f61
RL
506 @set -e; for s in dummy $(SHLIBS); do \
507 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 508 fn=`basename $$s`; \
3c65577f
RL
509 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
510 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
fcf80c46 511 done
dac494d2 512 : {- output_on() unless windowsdll(); "" -};
3c65577f 513 $(RM) $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
b894054e
RL
514 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
515 -$(RMDIR) $(DESTDIR)$(OPENSSLDIR)/misc
567a9e6f
RL
516
517# A method to extract all names from a .pod file
518# The first sed extracts everything between "=head1 NAME" and the next =head1
5287761b
RL
519# The perl command joins all the lines into one
520# The second sed removes the description and turns all commas into spaces
567a9e6f
RL
521# Voilà, you have a space separated list of names!
522EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
5287761b 523 $(PERL) -p -0 -e 's/\n/ /g; END {print "\n"}' | \
567a9e6f
RL
524 sed -e 's/ - .*$$//;s/,/ /g'
525PROCESS_PODS=\
526 set -e; \
527 here=`cd $(SRCDIR); pwd`; \
528 point=$$here/util/point.sh; \
529 for ds in apps:1 crypto:3 ssl:3; do \
530 defdir=`echo $$ds | cut -f1 -d:`; \
531 defsec=`echo $$ds | cut -f2 -d:`; \
532 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
533 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
534 [ -z "$$SEC" ] && SEC=$$defsec; \
535 fn=`basename $$p .pod`; \
beadb441 536 Name=$$fn; \
567a9e6f
RL
537 NAME=`echo $$fn | tr [a-z] [A-Z]`; \
538 suf=`eval "echo $$OUTSUFFIX"`; \
539 top=`eval "echo $$OUTTOP"`; \
540 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
541 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
542 cat $$p | eval "$$GENERATE" \
543 > $$top/man$$SEC/$$fn$$suf; \
544 names=`cat $$p | $(EXTRACT_NAMES)`; \
545 ( cd $$top/man$$SEC; \
546 for n in $$names; do \
3af104f3
RL
547 comp_n="$$n"; \
548 comp_fn="$$fn"; \
549 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
550 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
551 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
552 ;; \
553 esac; \
554 if [ "$$comp_n" != "$$comp_fn" ]; then \
567a9e6f
RL
555 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
556 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
557 fi; \
558 done ); \
559 done; \
560 done
561UNINSTALL_DOCS=\
562 set -e; \
563 here=`cd $(SRCDIR); pwd`; \
564 for ds in apps:1 crypto:3 ssl:3; do \
565 defdir=`echo $$ds | cut -f1 -d:`; \
566 defsec=`echo $$ds | cut -f2 -d:`; \
567 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
568 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
569 [ -z "$$SEC" ] && SEC=$$defsec; \
570 fn=`basename $$p .pod`; \
571 suf=`eval "echo $$OUTSUFFIX"`; \
572 top=`eval "echo $$OUTTOP"`; \
573 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
574 $(RM) $$top/man$$SEC/$$fn$$suf; \
575 names=`cat $$p | $(EXTRACT_NAMES)`; \
576 for n in $$names; do \
3af104f3
RL
577 comp_n="$$n"; \
578 comp_fn="$$fn"; \
579 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
580 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
581 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
582 ;; \
583 esac; \
584 if [ "$$comp_n" != "$$comp_fn" ]; then \
567a9e6f
RL
585 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
586 $(RM) $$top/man$$SEC/$$n$$suf; \
587 fi; \
588 done; \
8be7bdb5 589 ( $(RMDIR) $$top/man$$SEC 2>/dev/null || exit 0 ); \
567a9e6f
RL
590 done; \
591 done
592
593install_man_docs:
594 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
595 @echo "*** Installing manpages"
596 @\
597 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
3c65577f 598 OUTTOP="$(DESTDIR)$(MANDIR)"; \
567a9e6f
RL
599 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
600 $(PROCESS_PODS)
601
602uninstall_man_docs:
603 @echo "*** Uninstalling manpages"
604 @\
605 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
3c65577f 606 OUTTOP="$(DESTDIR)$(MANDIR)"; \
567a9e6f
RL
607 $(UNINSTALL_DOCS)
608
609install_html_docs:
610 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
611 @echo "*** Installing HTML manpages"
612 @\
613 OUTSUFFIX='.$(HTMLSUFFIX)'; \
3c65577f 614 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
567a9e6f 615 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
beadb441 616 --podpath=apps:crypto:ssl --title=\$$Name \
567a9e6f
RL
617 | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \
618 $(PROCESS_PODS)
619
620uninstall_html_docs:
621 @echo "*** Uninstalling manpages"
622 @\
623 OUTSUFFIX='.$(HTMLSUFFIX)'; \
3c65577f 624 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
567a9e6f
RL
625 $(UNINSTALL_DOCS)
626
627
628# Developer targets (note: these are only available on Unix) #########
629
6bb2106e
RL
630update: generate errors ordinals
631
b7650c67
RL
632generate: generate_apps generate_crypto_bn generate_crypto_objects \
633 generate_crypto_conf generate_crypto_asn1
567a9e6f
RL
634
635# Test coverage is a good idea for the future
636#coverage: $(PROGRAMS) $(TESTPROGRAMS)
637# ...
638
639# Currently disabled, util/selftest.pl needs a rewrite
640#report:
641# SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl
642
643lint:
644 lint -DLINT $(INCLUDES) $(SRCS)
645
9a9f8ee7
RL
646{- # because the program apps/openssl has object files as sources, and
647 # they then have the corresponding C files as source, we need to chain
648 # the lookups in %unified_info
649 my $apps_openssl = catfile("apps","openssl");
650 our @openssl_source = map { @{$unified_info{sources}->{$_}} }
651 @{$unified_info{sources}->{$apps_openssl}};
652 ""; -}
653generate_apps:
654 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
655 < apps/openssl.cnf > apps/openssl-vms.cnf )
656 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b apps/progs.pl \
657 {- join(" ", @openssl_source) -} \
658 > apps/progs.h )
659
660generate_crypto_bn:
661 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
662
663generate_crypto_objects:
9a9f8ee7
RL
664 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
665 crypto/objects/objects.txt \
666 crypto/objects/obj_mac.num \
667 include/openssl/obj_mac.h )
e6f2bb66
KM
668 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
669 include/openssl/obj_mac.h \
670 crypto/objects/obj_dat.h )
9a9f8ee7
RL
671 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
672 crypto/objects/obj_mac.num \
673 crypto/objects/obj_xref.txt \
674 > crypto/objects/obj_xref.h )
6bb2106e 675
b7650c67
RL
676generate_crypto_conf:
677 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
678 > crypto/conf/conf_def.h )
679
680generate_crypto_asn1:
681 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
682 > crypto/asn1/charmap.h )
683
567a9e6f
RL
684errors:
685 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
686 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
687 ( cd $(SRCDIR)/engines; \
688 for e in *.ec; do \
689 $(PERL) ../util/mkerr.pl -conf $$e \
690 -nostatic -staticloader -write *.c; \
691 done )
567a9e6f
RL
692
693ordinals:
694 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
695 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
696
697test_ordinals:
698 ( cd test; \
699 SRCTOP=../$(SRCDIR) \
700 BLDTOP=../$(BLDDIR) \
701 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
702
703tags TAGS: FORCE
704 rm -f TAGS tags
705 -ctags -R .
706 -etags `find . -name '*.[ch]' -o -name '*.pm'`
707
708# Release targets (note: only available on Unix) #####################
709
54bb8f74
RL
710TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
711PREPARE_CMD=:
567a9e6f
RL
712tar:
713 TMPDIR=/var/tmp/openssl-copy.$$$$; \
54bb8f74 714 DISTDIR=$(NAME); \
567a9e6f
RL
715 mkdir -p $$TMPDIR/$$DISTDIR; \
716 (cd $(SRCDIR); \
717 git ls-tree -r --name-only --full-tree HEAD \
718 | while read F; do \
719 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
720 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
721 done); \
722 (cd $$TMPDIR; \
54bb8f74 723 $(PREPARE_CMD); \
567a9e6f
RL
724 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
725 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
726 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
54bb8f74 727 $(TAR_COMMAND) $$DISTDIR) \
567a9e6f
RL
728 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
729 rm -rf $$TMPDIR
730 cd $(SRCDIR); ls -l $(TARFILE).gz
731
732dist:
733 @$(MAKE) PREPARE_CMD='./Configure dist' tar
734
735# Helper targets #####################################################
736
53ff6ac1 737link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
567a9e6f 738
27f42b46 739$(BLDDIR)/util/opensslwrap.sh: configdata.pm
567a9e6f
RL
740 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
741 mkdir -p "$(BLDDIR)/util"; \
742 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
743 fi
27f42b46 744$(BLDDIR)/util/shlib_wrap.sh: configdata.pm
567a9e6f
RL
745 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
746 mkdir -p "$(BLDDIR)/util"; \
747 ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
748 fi
c058fcd7 749FORCE:
567a9e6f
RL
750
751# Building targets ###################################################
752
27f42b46 753libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS)
567a9e6f
RL
754libcrypto.pc:
755 @ ( echo 'prefix=$(INSTALLTOP)'; \
756 echo 'exec_prefix=$${prefix}'; \
757 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
758 echo 'includedir=$${prefix}/include'; \
759 echo ''; \
760 echo 'Name: OpenSSL-libcrypto'; \
761 echo 'Description: OpenSSL cryptography library'; \
762 echo 'Version: '$(VERSION); \
763 echo 'Libs: -L$${libdir} -lcrypto'; \
764 echo 'Libs.private: $(EX_LIBS)'; \
765 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
766
767libssl.pc:
768 @ ( echo 'prefix=$(INSTALLTOP)'; \
769 echo 'exec_prefix=$${prefix}'; \
770 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
771 echo 'includedir=$${prefix}/include'; \
772 echo ''; \
773 echo 'Name: OpenSSL-libssl'; \
774 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
775 echo 'Version: '$(VERSION); \
776 echo 'Requires.private: libcrypto'; \
777 echo 'Libs: -L$${libdir} -lssl'; \
778 echo 'Libs.private: $(EX_LIBS)'; \
779 echo 'Cflags: -I$${includedir}' ) > libssl.pc
780
781openssl.pc:
782 @ ( echo 'prefix=$(INSTALLTOP)'; \
783 echo 'exec_prefix=$${prefix}'; \
784 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
785 echo 'includedir=$${prefix}/include'; \
786 echo ''; \
787 echo 'Name: OpenSSL'; \
788 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
789 echo 'Version: '$(VERSION); \
790 echo 'Requires: libssl libcrypto' ) > openssl.pc
791
792# Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which
793# wasn't passed down automatically. It's quite safe to use it like we do
794# below; if it doesn't exist, the result will be empty and 'make' will pick
795# up $(MAKEFLAGS) which is passed down as an environment variable.
c1ea997a 796configdata.pm: $(SRCDIR)/Configurations/unix-Makefile.tmpl $(SRCDIR)/Configurations/common.tmpl $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_infos}}) -}
27f42b46 797 @echo "Detected changed: $?"
567a9e6f
RL
798 @echo "Reconfiguring..."
799 $(SRCDIR)/Configure reconf
800 @echo "**************************************************"
801 @echo "*** ***"
802 @echo "*** Please run the same make command again ***"
803 @echo "*** ***"
804 @echo "**************************************************"
805 @false
806
807{-
808 use File::Basename;
809 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
cedbb146
RL
810
811 # Helper function to figure out dependencies on libraries
812 # It takes a list of library names and outputs a list of dependencies
813 sub compute_lib_depends {
84af1bae 814 if ($disabled{shared}) {
834aae2a 815 return map { $_.$libext } @_;
cedbb146
RL
816 }
817
818 # Depending on shared libraries:
819 # On Windows POSIX layers, we depend on {libname}.dll.a
820 # On Unix platforms, we depend on {shlibname}.so
f5c174ff 821 return map { shlib_simple($_) } @_;
cedbb146
RL
822 }
823
66ddf178
RL
824 sub generatesrc {
825 my %args = @_;
826 my $generator = join(" ", @{$args{generator}});
8d34daf0 827 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
d4605727 828 my $incs = join("", map { " -I".$_ } @{$args{incs}});
8d34daf0 829 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
66ddf178
RL
830
831 if ($args{src} !~ /\.[sS]$/) {
832 return <<"EOF";
769777b0 833$args{src}: $args{generator}->[0] $deps
8d34daf0 834 \$(PERL)$generator_incs $generator > \$@
66ddf178
RL
835EOF
836 } else {
8458f1bf 837 if ($args{generator}->[0] =~ /\.pl$/) {
8d34daf0 838 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
8458f1bf 839 } elsif ($args{generator}->[0] =~ /\.m4$/) {
8d34daf0 840 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
8458f1bf
RL
841 } elsif ($args{generator}->[0] =~ /\.S$/) {
842 $generator = undef;
843 } else {
844 die "Generator type for $args{src} unknown: $generator\n";
845 }
846
847 if (defined($generator)) {
848 # If the target is named foo.S in build.info, we want to
849 # end up generating foo.s in two steps.
850 if ($args{src} =~ /\.S$/) {
851 (my $target = $args{src}) =~ s|\.S$|.s|;
852 return <<"EOF";
769777b0 853$target: $args{generator}->[0] $deps
0218fc37 854 ( trap "rm -f \$@.*" INT 0; \\
8458f1bf 855 $generator \$@.S; \\
39199fb3
AP
856 \$(CC) \$(CFLAGS) $incs -E \$@.S | \\
857 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
858 mv -f \$@.i \$@ )
66ddf178 859EOF
8458f1bf
RL
860 }
861 # Otherwise....
66ddf178 862 return <<"EOF";
769777b0 863$args{src}: $args{generator}->[0] $deps
8458f1bf 864 $generator \$@
66ddf178 865EOF
66ddf178 866 }
8458f1bf 867 return <<"EOF";
769777b0 868$args{src}: $args{generator}->[0] $deps
39199fb3
AP
869 \$(CC) \$(CFLAGS) $incs -E \$< | \\
870 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
8458f1bf 871EOF
66ddf178
RL
872 }
873 }
874
bb26842d
RL
875 # Should one wonder about the end of the Perl snippet, it's because this
876 # second regexp eats up line endings as well, if the removed path is the
877 # last in the line. We may therefore need to put back a line ending.
88297284 878 sub src2obj {
567a9e6f 879 my %args = @_;
88297284 880 my $obj = $args{obj};
674d5858
RL
881 my @srcs = map { if ($unified_info{generate}->{$_}) {
882 (my $x = $_) =~ s/\.S$/.s/; $x
883 } else {
884 $_
885 }
886 } ( @{$args{srcs}} );
8458f1bf
RL
887 my $srcs = join(" ", @srcs);
888 my $deps = join(" ", @srcs, @{$args{deps}});
45502bfe 889 my $incs = join("", map { " -I".$_ } @{$args{incs}});
da430a55
RL
890 unless ($disabled{zlib}) {
891 if ($withargs{zlib_include}) {
892 $incs .= " -I".$withargs{zlib_include};
893 }
894 }
bbd9a50f 895 my $ecflags = { lib => '$(LIB_CFLAGS)',
45502bfe
RL
896 dso => '$(DSO_CFLAGS)',
897 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
567a9e6f 898 my $makedepprog = $config{makedepprog};
29eed3dd
RL
899 my $recipe = "";
900 if (!$disabled{makedepend} && $makedepprog =~ /\/makedepend/) {
901 $recipe .= <<"EOF";
834aae2a 902$obj$depext: $deps
f3e5948a
RL
903 -\$(MAKEDEPEND) -f- -o"|$obj$objext" -- \$(CFLAGS) $ecflags$incs -- $srcs \\
904 >\$\@.tmp 2>/dev/null
757c416c 905 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' \$\@.tmp
29b28eee 906 \@if cmp \$\@.tmp \$\@ > /dev/null 2> /dev/null; then \\
987dbc7f 907 rm -f \$\@.tmp; \\
29b28eee
RL
908 else \\
909 mv \$\@.tmp \$\@; \\
987dbc7f 910 fi
29eed3dd
RL
911EOF
912 $deps = $obj.$depext;
913 }
914 if ($disabled{makedepend} || $makedepprog =~ /\/makedepend/) {
915 $recipe .= <<"EOF";
916$obj$objext: $deps
45502bfe 917 \$(CC) \$(CFLAGS) $ecflags$incs -c -o \$\@ $srcs
567a9e6f
RL
918EOF
919 }
29eed3dd
RL
920 if (!$disabled{makedepend} && $makedepprog !~ /\/makedepend/) {
921 $recipe .= <<"EOF";
340da949
RL
922$obj$objext: $deps
923 \$(CC) \$(CFLAGS) $ecflags$incs -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
924 \@touch $obj$depext.tmp
29b28eee 925 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
987dbc7f 926 rm -f $obj$depext.tmp; \\
29b28eee
RL
927 else \\
928 mv $obj$depext.tmp $obj$depext; \\
340da949 929 fi
567a9e6f 930EOF
29eed3dd
RL
931 }
932 return $recipe;
567a9e6f
RL
933 }
934 # On Unix, we build shlibs from static libs, so we're ignoring the
935 # object file array. We *know* this routine is only called when we've
936 # configure 'shared'.
937 sub libobj2shlib {
938 my %args = @_;
939 my $lib = $args{lib};
940 my $shlib = $args{shlib};
941 my $libd = dirname($lib);
942 my $libn = basename($lib);
943 (my $libname = $libn) =~ s/^lib//;
cedbb146
RL
944 my $linklibs = join("", map { my $d = dirname($_);
945 my $f = basename($_);
946 (my $l = $f) =~ s/^lib//;
947 " -L$d -l$l" } @{$args{deps}});
948 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
567a9e6f
RL
949 my $shlib_target = $target{shared_target};
950 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
f5c174ff 951 my $target = shlib_simple($lib);
567a9e6f 952 return <<"EOF"
cedbb146
RL
953# With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
954# that two files get produced, {shlibname}.dll and {libname}.dll.a.
955# With all other Unix platforms, we often build a shared library with the
956# SO version built into the file name and a symlink without the SO version
957# It's not necessary to have both as targets. The choice falls on the
834aae2a
BL
958# simplest, {libname}$shlibextimport for Windows POSIX layers and
959# {libname}$shlibextsimple for the Unix platforms.
960$target: $lib$libext $deps $ordinalsfile
567a9e6f 961 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
cedbb146 962 PLATFORM=\$(PLATFORM) \\
8a0a3d29
RL
963 PERL=\$(PERL) SRCDIR='\$(SRCDIR)' DSTDIR="$libd" \\
964 INSTALLTOP='\$(INSTALLTOP)' LIBDIR='\$(LIBDIR)' \\
965 LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
cedbb146 966 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
8a0a3d29
RL
967 LIBCOMPATVERSIONS=';\$(SHLIB_VERSION_HISTORY)' \\
968 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(LIB_CFLAGS)' \\
8f41ff2d 969 LDFLAGS='\$(LDFLAGS)' \\
8a0a3d29 970 SHARED_LDFLAGS='\$(LIB_LDFLAGS)' SHLIB_EXT=$shlibext \\
8f41ff2d 971 RC='\$(RC)' SHARED_RCFLAGS='\$(RCFLAGS)' \\
e048fd51 972 link_shlib.$shlib_target
fcf80c46
RL
973EOF
974 . (windowsdll() ? <<"EOF" : "");
834aae2a
BL
975 rm -f apps/$shlib$shlibext
976 rm -f test/$shlib$shlibext
977 cp -p $shlib$shlibext apps/
978 cp -p $shlib$shlibext test/
567a9e6f
RL
979EOF
980 }
5386287c 981 sub obj2dso {
567a9e6f
RL
982 my %args = @_;
983 my $lib = $args{lib};
984 my $libd = dirname($lib);
985 my $libn = basename($lib);
986 (my $libname = $libn) =~ s/^lib//;
987 my $shlibdeps = join("", map { my $d = dirname($_);
988 my $f = basename($_);
989 (my $l = $f) =~ s/^lib//;
990 " -L$d -l$l" } @{$args{deps}});
cedbb146 991 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
567a9e6f 992 my $shlib_target = $target{shared_target};
834aae2a 993 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
f5c174ff 994 my $target = dso($lib);
567a9e6f 995 return <<"EOF";
f5c174ff 996$target: $objs $deps
567a9e6f 997 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
cedbb146 998 PLATFORM=\$(PLATFORM) \\
8a0a3d29
RL
999 PERL=\$(PERL) SRCDIR='\$(SRCDIR)' DSTDIR="$libd" \\
1000 LIBDEPS='\$(PLIB_LDFLAGS) '"$shlibdeps"' \$(EX_LIBS)' \\
1001 LIBNAME=$libname LDFLAGS='\$(LDFLAGS)' \\
1002 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(DSO_CFLAGS)' \\
1003 SHARED_LDFLAGS='\$(DSO_LDFLAGS)' \\
834aae2a 1004 SHLIB_EXT=$dsoext \\
567a9e6f 1005 LIBEXTRAS="$objs" \\
e048fd51 1006 link_dso.$shlib_target
567a9e6f
RL
1007EOF
1008 }
1009 sub obj2lib {
1010 my %args = @_;
1011 my $lib = $args{lib};
834aae2a 1012 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
567a9e6f 1013 return <<"EOF";
834aae2a 1014$lib$libext: $objs
68cd4e3f 1015 \$(AR) \$\@ \$\?
567a9e6f
RL
1016 \$(RANLIB) \$\@ || echo Never mind.
1017EOF
1018 }
1019 sub obj2bin {
1020 my %args = @_;
1021 my $bin = $args{bin};
1022 my $bind = dirname($bin);
1023 my $binn = basename($bin);
834aae2a 1024 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
cedbb146
RL
1025 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1026 my $linklibs = join("", map { my $d = dirname($_);
1027 my $f = basename($_);
1028 $d = "." if $d eq $f;
1029 (my $l = $f) =~ s/^lib//;
1030 " -L$d -l$l" } @{$args{deps}});
84af1bae 1031 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
567a9e6f 1032 return <<"EOF";
834aae2a
BL
1033$bin$exeext: $objs $deps
1034 \$(RM) $bin$exeext
567a9e6f 1035 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
cedbb146 1036 PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
834aae2a 1037 APPNAME=$bin$exeext OBJECTS="$objs" \\
8a0a3d29
RL
1038 LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
1039 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(BIN_CFLAGS)' \\
1040 LDFLAGS='\$(LDFLAGS)' LIBRPATH='\$(INSTALLTOP)/\$(LIBDIR)' \\
567a9e6f
RL
1041 link_app.$shlib_target
1042EOF
1043 }
1044 sub in2script {
1045 my %args = @_;
1046 my $script = $args{script};
1047 my $sources = join(" ", @{$args{sources}});
1048 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1049 "util", "dofile.pl")),
1050 rel2abs($config{builddir}));
1051 return <<"EOF";
88297284 1052$script: $sources
4b799cea 1053 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
ba327ade 1054 "-o$target{build_file}" $sources > "$script"
567a9e6f
RL
1055 chmod a+x $script
1056EOF
1057 }
1058 "" # Important! This becomes part of the template result.
1059-}