2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
7 sub shlib_ext { $target{shared_extension} || ".so" }
8 sub shlib_ext_simple { (my $x = $target{shared_extension})
9 =~ s/\.\$\(SHLIB_MAJOR\)\.\$\(SHLIB_MINOR\)//;
12 PLATFORM={- $config{target} -}
13 OPTIONS={- $config{options} -}
14 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
15 SRCDIR={- $config{sourcedir} -}
16 BLDDIR={- $config{builddir} -}
18 VERSION={- $config{version} -}
19 MAJOR={- $config{major} -}
20 MINOR={- $config{minor} -}
21 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
22 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
23 SHLIB_MAJOR={- $config{shlib_major} -}
24 SHLIB_MINOR={- $config{shlib_minor} -}
25 SHLIB_TARGET={- $target{shared_target} -}
27 EXE_EXT={- $target{exe_extension} || "" -}
28 LIB_EXT={- $target{lib_extension} || ".a" -}
29 SHLIB_EXT={- shlib_ext() -}
30 SHLIB_EXT_SIMPLE={- shlib_ext_simple() -}
31 OBJ_EXT={- $target{obj_extension} || ".o" -}
32 DEP_EXT={- $target{dep_extension} || ".d" -}
34 LIBS={- join(" ", map { $_."\$(LIB_EXT)" } @{$unified_info{libraries}}) -}
35 SHLIBS={- join(" ", map { $_."\$(SHLIB_EXT)" } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}}) -}
36 ENGINES={- join(" ", map { $_."\$(SHLIB_EXT_SIMPLE)" } @{$unified_info{engines}}) -}
37 PROGRAMS={- join(" ", map { $_."\$(EXE_EXT)" } grep { !m|^test/| } @{$unified_info{programs}}) -}
38 TESTPROGS={- join(" ", map { $_."\$(EXE_EXT)" } grep { m|^test/| } @{$unified_info{programs}}) -}
39 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
40 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
41 MISC_SCRIPTS=$(SRCDIR)/tools/c_hash $(SRCDIR)/tools/c_info \
42 $(SRCDIR)/tools/c_issuer $(SRCDIR)/tools/c_name \
43 $(BLDDIR)/apps/CA.pl $(SRCDIR)/apps/tsget
45 # INSTALL_PREFIX is for package builders so that they can configure
46 # for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
47 # Normally it is left empty.
48 INSTALL_PREFIX={- $config{install_prefix} -}
50 # Do not edit these manually. Use Configure with --prefix or --openssldir
51 # to change this! Short explanation in the top comment in Configure
52 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
54 our $prefix = $config{prefix} || "/usr/local";
57 # The logic here is that if no --openssldir was given,
58 # OPENSSLDIR will get the value from $prefix plus "/ssl".
59 # If --openssldir was given and the value is an absolute
60 # path, OPENSSLDIR will get its value without change.
61 # If the value from --openssldir is a relative path,
62 # OPENSSLDIR will get $prefix with the --openssldir
63 # value appended as a subdirectory.
65 use File::Spec::Functions;
68 (file_name_is_absolute($config{openssldir}) ?
70 : catdir($prefix, $config{openssldir}))
71 : catdir($prefix, "ssl");
74 # if $prefix/lib$target{multilib} is not an existing
75 # directory, then assume that it's not searched by linker
76 # automatically, in which case adding $target{multilib} suffix
77 # causes more grief than we're ready to tolerate, so don't...
79 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
80 our $libdir = $config{libdir} || "lib$multilib";
82 ENGINESDIR={- use File::Spec::Functions;
83 catdir($prefix,$libdir,"engines") -}
85 MANDIR=$(OPENSSLDIR)/man
86 HTMLDIR=$(OPENSSLDIR)/html
93 CROSS_COMPILE= {- $config{cross_compile_prefix} -}
94 CC= $(CROSS_COMPILE){- $target{cc} -}
95 CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $config{cflags} -}
96 CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
97 DEPFLAGS= {- join(" ",map { "-D".$_} @{$config{depdefines}}) -}
98 LDFLAGS= {- $config{lflags} -}
99 PLIB_LDFLAGS= {- $config{plib_lflags} -}
100 EX_LIBS= {- $config{ex_libs} -}
101 SHARED_LDFLAGS={- $target{shared_ldflag}
102 # Unlike other OSes (like Solaris, Linux, Tru64,
103 # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
104 # and FreeBSD) "demand" RPATH set on .so objects.
105 # Apparently application RPATH is not global and
106 # does not apply to .so linked with other .so.
107 # Problem manifests itself when libssl.so fails to
108 # load libcrypto.so. One can argue that we should
109 # engrave this into Makefile.shared rules or into
110 # BSD-* config lines above. Meanwhile let's try to
111 # be cautious and pass -rpath to linker only when
112 # $prefix is not /usr.
113 . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
114 ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
116 PERL={- $config{perl} -}
118 ARFLAGS= {- $target{arflags} -}
119 AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
120 RANLIB= {- $target{ranlib} -}
121 NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
123 TAR= {- $target{tar} || "tar" -}
124 TARFLAGS= {- $target{tarflags} -}
127 NAME= $(BASENAME)-$(VERSION)
128 TARFILE= ../$(NAME).tar
130 # We let the C compiler driver to take care of .s files. This is done in
131 # order to be excused from maintaining a separate set of architecture
132 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
133 # gcc, then the driver will automatically translate it to -xarch=v8plus
134 # and pass it down to assembler.
137 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
139 # For x86 assembler: Set PROCESSOR to 386 if you want to support
141 PROCESSOR= {- $config{processor} -}
143 # The main targets ###################################################
145 all: Makefile libcrypto.pc libssl.pc openssl.pc $(ENGINES) $(PROGRAMS) $(SCRIPTS) $(TESTPROGS)
147 test tests: $(TESTPROGS) rehash
149 SRCTOP=../$(SRCDIR) \
150 BLDTOP=../$(BLDDIR) \
151 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
154 @TOP=$(SRCDIR) PERL=$(PERL) $(PERL) $(SRCDIR)/test/run_tests.pl list
157 -rm -f `find $(BLDDIR) -name '*$(LIB_EXT)' -o -name '*$(SHLIB_EXT)'`
159 install: install_sw install_docs
161 uninstall: uninstall_docs uninstall_sw
164 rm -f $(PROGRAMS) $(TESTPROGS)
165 rm -f `find $(BLDDIR) -name '*$(DEP_EXT)'`
166 rm -f `find $(BLDDIR) -name '*$(OBJ_EXT)'`
167 rm -f $(BLDDIR)/core $(BLDDIR)/rehash.time
168 rm -f $(BLDDIR)/tags $(BLDDIR)/TAGS
169 rm -f $(BLDDIR)/openssl.pc $(BLDDIR)/libcrypto.pc $(BLDDIR)/libssl.pc
170 -rm -f `find $(BLDDIR) -type l`
173 DCLEAN_CMD=sed -e '/^DO NOT DELETE.*/,$$d'
175 $(DCLEAN_CMD) < Makefile >Makefile.new
176 mv -f Makefile.new Makefile
178 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
179 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
180 keys %{$unified_info{sources}}); -}
182 ( $(DCLEAN_CMD) < Makefile; \
183 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
185 cat `find . -name '*$(DEP_EXT)'` ) > Makefile.new
186 mv -f Makefile.new Makefile
188 # Install helper targets #############################################
190 install_sw: all install_dev install_engines install_runtime
192 uninstall_sw: uninstall_dev uninstall_engines uninstall_runtime
194 install_docs: install_man_docs install_html_docs
196 uninstall_docs: uninstall_man_docs uninstall_html_docs
199 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
200 @echo "*** Installing development files"
201 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl
202 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
203 $(BLDDIR)/include/openssl/*.h; do \
205 echo "install $$i -> $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$fn"; \
206 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$fn; \
207 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$fn; \
209 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)
210 @set -e; for l in $(LIBS); do \
212 echo "install $$l -> $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
213 cp $$l $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
214 $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
215 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
216 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
217 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
219 @ : {- output_off() if $config{no_shared}; "" -}
220 @set -e; for s in $(SHLIBS); do \
222 echo "install $$s -> $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
223 cp $$s $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
224 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
225 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
226 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
227 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
228 echo "link $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
229 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
230 ln -sf $$fn $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
232 : {- output_off() unless windowsdll(); "" -}; \
233 echo "install $$s.a -> $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
234 cp $$s.a $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
235 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
236 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \
237 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
238 : {- output_on() -}; \
240 @ : {- output_on() -}
241 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
242 @echo "install libcrypto.pc -> $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
243 @cp libcrypto.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
244 @chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
245 @echo "install libssl.pc -> $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
246 @cp libssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
247 @chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
248 @echo "install openssl.pc -> $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
249 @cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
250 @chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
253 @echo "*** Uninstalling development files"
254 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
255 $(BLDDIR)/include/openssl/*.h; do \
257 echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$fn"; \
258 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$fn; \
260 @set -e; for l in $(LIBS); do \
262 echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
263 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
265 @set -e; for s in $(SHLIBS); do \
267 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
268 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
269 echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
270 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
272 echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
273 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
274 : {- output_off() unless windowsdll(); "" -}; \
275 echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
276 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
277 : {- output_on() -}; \
279 @echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
280 @$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
281 @echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
282 @$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
283 @echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
284 @$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
287 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
288 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/
289 @echo "*** Installing engines"
290 @set -e; for e in $(ENGINES); do \
292 echo "install $$e -> $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
293 cp $$e $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
294 chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
295 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \
296 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
300 @echo "*** Uninstalling engines"
301 @set -e; for e in $(ENGINES); do \
303 echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
304 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
308 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
309 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin
310 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(OPENSSLDIR)/misc
311 @echo "*** Installing runtime files"
312 : {- output_off() unless windowsdll(); "" -};
313 @set -e; for s in $(SHLIBS); do \
315 echo "install $$s -> $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
316 cp $$s $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new; \
317 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new; \
318 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new \
319 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn; \
322 @set -e; for x in $(PROGRAMS); do \
324 echo "install $$x -> $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
325 cp $$x $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new; \
326 chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new; \
327 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new \
328 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn; \
330 @set -e; for x in $(BIN_SCRIPTS); do \
332 echo "install $$x -> $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
333 cp $$x $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new; \
334 chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new; \
335 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new \
336 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn; \
338 @set -e; for x in $(MISC_SCRIPTS); do \
340 echo "install $$x -> $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn"; \
341 cp $$x $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn.new; \
342 chmod 755 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn.new; \
343 mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn.new \
344 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn; \
346 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf"
347 @cp $(SRCDIR)/apps/openssl.cnf $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new
348 @chmod 644 $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new
349 @mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf
352 @echo "*** Uninstalling runtime files"
353 @set -e; for x in $(PROGRAMS); \
356 echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
357 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn; \
359 @set -e; for x in $(BIN_SCRIPTS); \
362 echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
363 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn; \
365 @set -e; for x in $(MISC_SCRIPTS); \
368 echo "$(RM) $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn"; \
369 $(RM) $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn; \
371 : {- output_off() unless windowsdll(); "" -};
372 @set -e; for s in $(SHLIBS); do \
374 echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
375 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn; \
378 $(RM) $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf
380 # A method to extract all names from a .pod file
381 # The first sed extracts everything between "=head1 NAME" and the next =head1
382 # The second sed joins all the lines into one
383 # The third sed removes the description and turns all commas into spaces
384 # Voilà , you have a space separated list of names!
385 EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
386 sed -e ':a;{N;s/\n/ /;ba}' | \
387 sed -e 's/ - .*$$//;s/,/ /g'
390 here=`cd $(SRCDIR); pwd`; \
391 point=$$here/util/point.sh; \
392 for ds in apps:1 crypto:3 ssl:3; do \
393 defdir=`echo $$ds | cut -f1 -d:`; \
394 defsec=`echo $$ds | cut -f2 -d:`; \
395 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
396 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
397 [ -z "$$SEC" ] && SEC=$$defsec; \
398 fn=`basename $$p .pod`; \
399 NAME=`echo $$fn | tr [a-z] [A-Z]`; \
400 suf=`eval "echo $$OUTSUFFIX"`; \
401 top=`eval "echo $$OUTTOP"`; \
402 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
403 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
404 cat $$p | eval "$$GENERATE" \
405 > $$top/man$$SEC/$$fn$$suf; \
406 names=`cat $$p | $(EXTRACT_NAMES)`; \
407 ( cd $$top/man$$SEC; \
408 for n in $$names; do \
409 if [ "$$n" != "$$fn" ]; then \
410 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
411 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
418 here=`cd $(SRCDIR); pwd`; \
419 for ds in apps:1 crypto:3 ssl:3; do \
420 defdir=`echo $$ds | cut -f1 -d:`; \
421 defsec=`echo $$ds | cut -f2 -d:`; \
422 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
423 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
424 [ -z "$$SEC" ] && SEC=$$defsec; \
425 fn=`basename $$p .pod`; \
426 suf=`eval "echo $$OUTSUFFIX"`; \
427 top=`eval "echo $$OUTTOP"`; \
428 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
429 $(RM) $$top/man$$SEC/$$fn$$suf; \
430 names=`cat $$p | $(EXTRACT_NAMES)`; \
431 for n in $$names; do \
432 if [ "$$n" != "$$fn" ]; then \
433 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
434 $(RM) $$top/man$$SEC/$$n$$suf; \
441 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
442 @echo "*** Installing manpages"
444 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
445 OUTTOP="$(INSTALL_PREFIX)$(MANDIR)"; \
446 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
450 @echo "*** Uninstalling manpages"
452 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
453 OUTTOP="$(INSTALL_PREFIX)$(MANDIR)"; \
457 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
458 @echo "*** Installing HTML manpages"
460 OUTSUFFIX='.$(HTMLSUFFIX)'; \
461 OUTTOP="$(INSTALL_PREFIX)$(HTMLDIR)"; \
462 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
463 --podpath=apps:crypto:ssl \
464 | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \
468 @echo "*** Uninstalling manpages"
470 OUTSUFFIX='.$(HTMLSUFFIX)'; \
471 OUTTOP="$(INSTALL_PREFIX)$(HTMLDIR)"; \
475 # Developer targets (note: these are only available on Unix) #########
477 update: errors ordinals tags test_ordinals
479 # Test coverage is a good idea for the future
480 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
483 # Currently disabled, util/selftest.pl needs a rewrite
485 # SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl
488 lint -DLINT $(INCLUDES) $(SRCS)
491 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
492 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
493 ( cd $(SRCDIR)/engines; \
495 $(PERL) ../util/mkerr.pl -conf $$e \
496 -nostatic -staticloader -write *.c; \
498 ( cd $(SRCDIR)/crypto/ct; \
499 $(PERL) ../../util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c )
502 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
503 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
507 SRCTOP=../$(SRCDIR) \
508 BLDTOP=../$(BLDDIR) \
509 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
514 -etags `find . -name '*.[ch]' -o -name '*.pm'`
516 # Release targets (note: only available on Unix) #####################
519 TMPDIR=/var/tmp/openssl-copy.$$$$; \
520 DISTDIR=openssl-$(VERSION); \
521 mkdir -p $$TMPDIR/$$DISTDIR; \
523 git ls-tree -r --name-only --full-tree HEAD \
525 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
526 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
529 [ -n "$(PREPARE_CMD)" ] && $(PREPARE_CMD); \
530 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
531 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
532 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
533 $(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - $$DISTDIR) \
534 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
536 cd $(SRCDIR); ls -l $(TARFILE).gz
539 @$(MAKE) PREPARE_CMD='./Configure dist' tar
541 # Helper targets #####################################################
543 rehash: link-utils copy-certs
544 @if [ -z "$(CROSS_COMPILE)" ]; then \
545 (OPENSSL="$(BLDDIR)/util/shlib_wrap.sh apps/openssl"; \
546 [ -x "$(BLDDIR)/openssl.exe" ] && OPENSSL="$(BLDDIR)/openssl.exe" || :; \
547 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
548 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
549 $$OPENSSL rehash certs/demo \
550 || $(PERL) tools/c_rehash certs/demo) && \
554 link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
556 $(BLDDIR)/util/opensslwrap.sh: Makefile
557 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
558 mkdir -p "$(BLDDIR)/util"; \
559 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
561 $(BLDDIR)/util/shlib_wrap.sh: Makefile
562 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
563 mkdir -p "$(BLDDIR)/util"; \
564 ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
568 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
569 cp -R "$(SRCDIR)/certs" "$(BLDDIR)/"; \
574 # Building targets ###################################################
576 libcrypto.pc libssl.pc openssl.pc: Makefile $(LIBS)
578 @ ( echo 'prefix=$(INSTALLTOP)'; \
579 echo 'exec_prefix=$${prefix}'; \
580 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
581 echo 'includedir=$${prefix}/include'; \
583 echo 'Name: OpenSSL-libcrypto'; \
584 echo 'Description: OpenSSL cryptography library'; \
585 echo 'Version: '$(VERSION); \
586 echo 'Libs: -L$${libdir} -lcrypto'; \
587 echo 'Libs.private: $(EX_LIBS)'; \
588 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
591 @ ( echo 'prefix=$(INSTALLTOP)'; \
592 echo 'exec_prefix=$${prefix}'; \
593 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
594 echo 'includedir=$${prefix}/include'; \
596 echo 'Name: OpenSSL-libssl'; \
597 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
598 echo 'Version: '$(VERSION); \
599 echo 'Requires.private: libcrypto'; \
600 echo 'Libs: -L$${libdir} -lssl'; \
601 echo 'Libs.private: $(EX_LIBS)'; \
602 echo 'Cflags: -I$${includedir}' ) > libssl.pc
605 @ ( echo 'prefix=$(INSTALLTOP)'; \
606 echo 'exec_prefix=$${prefix}'; \
607 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
608 echo 'includedir=$${prefix}/include'; \
610 echo 'Name: OpenSSL'; \
611 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
612 echo 'Version: '$(VERSION); \
613 echo 'Requires: libssl libcrypto' ) > openssl.pc
615 # Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which
616 # wasn't passed down automatically. It's quite safe to use it like we do
617 # below; if it doesn't exist, the result will be empty and 'make' will pick
618 # up $(MAKEFLAGS) which is passed down as an environment variable.
619 Makefile: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/config
620 @echo "Makefile is older than {- $config{build_file_template} -}, $(SRCDIR)/Configure or $(SRCDIR)/config."
621 @echo "Reconfiguring..."
622 $(SRCDIR)/Configure reconf
623 @echo "**************************************************"
625 @echo "*** Please run the same make command again ***"
627 @echo "**************************************************"
632 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
634 # Helper function to figure out dependencies on libraries
635 # It takes a list of library names and outputs a list of dependencies
636 sub compute_lib_depends {
637 if ($config{no_shared}) {
638 return map { $_."\$(LIB_EXT)" } @_;
641 # Depending on shared libraries:
642 # On Windows POSIX layers, we depend on {libname}.dll.a
643 # On Unix platforms, we depend on {shlibname}.so
644 return map { if (windowsdll()) {
645 "$_\$(SHLIB_EXT_SIMPLE).a"
648 $unified_info{sharednames}->{$_} || $_;
649 "$libname\$(SHLIB_EXT_SIMPLE)"
655 my $dep = $args{obj}.'$(DEP_EXT)';
656 my $obj = $args{obj}.'$(OBJ_EXT)';
657 my $srcs = join(" ", @{$args{srcs}});
658 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
659 my $makedepprog = $config{makedepprog};
660 if ($makedepprog eq "makedepend") {
663 rm -f \$\@.tmp; touch \$\@.tmp
664 \$(MAKEDEPEND) -f\$\@.tmp -o"|$obj"\
665 -- -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs \
667 sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$/d' -e '/^\\(#.*\\| *\\)\$/d' \$\@.tmp > \$\@
672 $dep : $srcs Makefile
673 \$(CC) -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
678 my $obj = $args{obj}.'$(OBJ_EXT)';
679 my $srcs = join(" ", @{$args{srcs}});
680 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
681 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
684 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
687 # On Unix, we build shlibs from static libs, so we're ignoring the
688 # object file array. We *know* this routine is only called when we've
689 # configure 'shared'.
692 my $lib = $args{lib};
693 my $shlib = $args{shlib};
694 my $libd = dirname($lib);
695 my $libn = basename($lib);
696 (my $libname = $libn) =~ s/^lib//;
697 my $linklibs = join("", map { my $d = dirname($_);
698 my $f = basename($_);
699 (my $l = $f) =~ s/^lib//;
700 " -L$d -l$l" } @{$args{deps}});
701 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
702 my $shlib_target = $target{shared_target};
703 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
704 my $shlibtarget = windowsdll() ?
705 "$lib\$(SHLIB_EXT_SIMPLE).a" : "$shlib\$(SHLIB_EXT_SIMPLE)";
707 # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
708 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
709 # With all other Unix platforms, we often build a shared library with the
710 # SO version built into the file name and a symlink without the SO version
711 # It's not necessary to have both as targets. The choice falls on the
712 # simplest, {libname}\$(SHLIB_EXT_SIMPLE).a for Windows POSIX layers and
713 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
714 $shlibtarget : $lib\$(LIB_EXT) $deps $ordinalsfile
715 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
716 PLATFORM=\$(PLATFORM) \\
717 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
718 INSTALLTOP="\$(INSTALLTOP)" LIBDIR="\$(LIBDIR)" \\
719 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
720 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
721 LIBCOMPATVERSIONS=";\$(SHLIB_VERSION_HISTORY)" \\
722 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
723 CROSS_COMPILE="\$(CROSS_COMPILE)" \\
724 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
727 . (windowsdll() ? <<"EOF" : "");
728 rm -f apps/$shlib\$(SHLIB_EXT)
729 rm -f test/$shlib\$(SHLIB_EXT)
730 cp -p $shlib\$(SHLIB_EXT) apps/
731 cp -p $shlib\$(SHLIB_EXT) test/
736 my $lib = $args{lib};
737 my $libd = dirname($lib);
738 my $libn = basename($lib);
739 (my $libname = $libn) =~ s/^lib//;
740 my $shlibdeps = join("", map { my $d = dirname($_);
741 my $f = basename($_);
742 (my $l = $f) =~ s/^lib//;
743 " -L$d -l$l" } @{$args{deps}});
744 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
745 my $shlib_target = $target{shared_target};
746 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
748 $lib\$(SHLIB_EXT_SIMPLE): $objs $deps
749 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
750 PLATFORM=\$(PLATFORM) \\
751 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
752 LIBDEPS="\$(PLIB_LDFLAGS) $shlibdeps \$(EX_LIBS)" \\
753 LIBNAME=$libname LDFLAGS="\$(LDFLAGS)" \\
754 CC="\$(CC)" CFLAGS="\$(CFLAGS)" \\
755 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" \\
756 SHLIB_EXT=\$(SHLIB_EXT_SIMPLE) \\
763 my $lib = $args{lib};
764 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
766 $lib\$(LIB_EXT) : $objs
768 \$(RANLIB) \$\@ || echo Never mind.
773 my $bin = $args{bin};
774 my $bind = dirname($bin);
775 my $binn = basename($bin);
776 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
777 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
778 my $linklibs = join("", map { my $d = dirname($_);
779 my $f = basename($_);
780 $d = "." if $d eq $f;
781 (my $l = $f) =~ s/^lib//;
782 " -L$d -l$l" } @{$args{deps}});
783 my $shlib_target = $config{no_shared} ? "" : $target{shared_target};
785 $bin\$(EXE_EXT) : $objs $deps
786 \$(RM) $bin\$(EXE_EXT)
787 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
788 PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
789 APPNAME=$bin OBJECTS="$objs" \\
790 LIBDEPS="\$(PLIB_LDFLAGS) \$(LDFLAGS) $linklibs \$(EX_LIBS)" \\
791 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
792 LIBRPATH="\$(INSTALLTOP)/\$(LIBDIR)" \\
793 link_app.$shlib_target
798 my $script = $args{script};
799 my $sources = join(" ", @{$args{sources}});
800 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
801 "util", "dofile.pl")),
802 rel2abs($config{builddir}));
805 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" $sources > "$script"
809 "" # Important! This becomes part of the template result.