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