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