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