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