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