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