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