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