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