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