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 # DESTDIR is for package builders so that they can configure for, say,
46 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
47 # Normally it is left empty.
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=$(INSTALLTOP)/share/man
86 HTMLDIR=$(INSTALLTOP)/share/doc/$(BASENAME)/html
88 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
89 # appended after the manpage file section number. "ssl" is popular,
90 # resulting in files such as config.5ssl rather than config.5.
96 CROSS_COMPILE= {- $config{cross_compile_prefix} -}
97 CC= $(CROSS_COMPILE){- $target{cc} -}
98 CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $config{cflags} -}
99 CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
100 DEPFLAGS= {- join(" ",map { "-D".$_} @{$config{depdefines}}) -}
101 LDFLAGS= {- $config{lflags} -}
102 PLIB_LDFLAGS= {- $config{plib_lflags} -}
103 EX_LIBS= {- $config{ex_libs} -}
104 SHARED_LDFLAGS={- $target{shared_ldflag}
105 # Unlike other OSes (like Solaris, Linux, Tru64,
106 # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
107 # and FreeBSD) "demand" RPATH set on .so objects.
108 # Apparently application RPATH is not global and
109 # does not apply to .so linked with other .so.
110 # Problem manifests itself when libssl.so fails to
111 # load libcrypto.so. One can argue that we should
112 # engrave this into Makefile.shared rules or into
113 # BSD-* config lines above. Meanwhile let's try to
114 # be cautious and pass -rpath to linker only when
115 # $prefix is not /usr.
116 . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
117 ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
118 SHARED_RCFLAGS={- $target{shared_rcflag} -}
120 PERL={- $config{perl} -}
122 ARFLAGS= {- $target{arflags} -}
123 AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
124 RANLIB= {- $target{ranlib} -}
125 NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
127 TAR= {- $target{tar} || "tar" -}
128 TARFLAGS= {- $target{tarflags} -}
129 MAKEDEPEND=$(CROSS_COMPILE){- $config{makedepprog} -}
132 NAME= $(BASENAME)-$(VERSION)
133 TARFILE= ../$(NAME).tar
135 # We let the C compiler driver to take care of .s files. This is done in
136 # order to be excused from maintaining a separate set of architecture
137 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
138 # gcc, then the driver will automatically translate it to -xarch=v8plus
139 # and pass it down to assembler.
142 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
144 # For x86 assembler: Set PROCESSOR to 386 if you want to support
146 PROCESSOR= {- $config{processor} -}
148 # The main targets ###################################################
150 all: build_libs build_engines build_apps link-utils
152 # The pkg-config files depend on the libraries as well as Makefile
153 build_libs: libcrypto.pc libssl.pc openssl.pc
154 build_engines: $(ENGINES)
155 build_apps: $(PROGRAMS) $(SCRIPTS)
156 build_tests: $(TESTPROGS)
158 test tests: build_tests build_apps build_engines rehash
160 SRCTOP=../$(SRCDIR) \
161 BLDTOP=../$(BLDDIR) \
162 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
165 @TOP=$(SRCDIR) PERL=$(PERL) $(PERL) $(SRCDIR)/test/run_tests.pl list
168 -rm -f `find $(BLDDIR) -name '*$(LIB_EXT)' -o -name '*$(SHLIB_EXT)'`
170 install: install_sw install_ssldirs install_docs
172 uninstall: uninstall_docs uninstall_sw
175 rm -f $(PROGRAMS) $(TESTPROGS)
176 rm -f `find $(BLDDIR) -name '*$(DEP_EXT)'`
177 rm -f `find $(BLDDIR) -name '*$(OBJ_EXT)'`
178 rm -f $(BLDDIR)/core $(BLDDIR)/rehash.time
179 rm -f $(BLDDIR)/tags $(BLDDIR)/TAGS
180 rm -f $(BLDDIR)/openssl.pc $(BLDDIR)/libcrypto.pc $(BLDDIR)/libssl.pc
181 -rm -f `find $(BLDDIR) -type l`
184 DCLEAN_CMD=sed -e '/^. DO NOT DELETE.*/,$$d'
186 $(DCLEAN_CMD) < Makefile >Makefile.new
187 mv -f Makefile.new Makefile
189 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
190 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
191 keys %{$unified_info{sources}}); -}
193 ( $(DCLEAN_CMD) < Makefile; \
194 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
196 cat `find . -name '*$(DEP_EXT)'` ) > Makefile.new
197 mv -f Makefile.new Makefile
199 # Install helper targets #############################################
201 install_sw: all install_dev install_engines install_runtime
203 uninstall_sw: uninstall_dev uninstall_engines uninstall_runtime
205 install_docs: install_man_docs install_html_docs
207 uninstall_docs: uninstall_man_docs uninstall_html_docs
210 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
211 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
214 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
215 @echo "*** Installing development files"
216 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
217 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
218 $(BLDDIR)/include/openssl/*.h; do \
220 echo "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
221 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
222 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
224 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
225 @set -e; for l in $(LIBS); do \
227 echo "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
228 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
229 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
230 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
231 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
232 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
234 @ : {- output_off() if $config{no_shared}; "" -}
235 @set -e; for s in $(SHLIBS); do \
237 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
238 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
239 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
240 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
241 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
242 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
243 echo "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
244 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
245 ln -sf $$fn $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
247 : {- output_off() unless windowsdll(); "" -}; \
248 echo "install $$s.a -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
249 cp $$s.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
250 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
251 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \
252 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
253 : {- output_on() unless windowsdll(); "" -}; \
255 @ : {- output_on() if $config{no_shared}; "" -}
256 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
257 @echo "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
258 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
259 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
260 @echo "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
261 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
262 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
263 @echo "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
264 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
265 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
268 @echo "*** Uninstalling development files"
269 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
270 $(BLDDIR)/include/openssl/*.h; do \
272 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
273 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
275 @set -e; for l in $(LIBS); do \
277 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
278 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
280 @set -e; for s in $(SHLIBS); do \
282 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
283 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
284 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
285 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
287 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
288 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
289 : {- output_off() unless windowsdll(); "" -}; \
290 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
291 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
292 : {- output_on() unless windowsdll(); "" -}; \
294 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
295 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
296 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
297 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
298 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
299 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
302 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
303 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/
304 @echo "*** Installing engines"
305 @set -e; for e in $(ENGINES); do \
307 echo "install $$e -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
308 cp $$e $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
309 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
310 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \
311 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
315 @echo "*** Uninstalling engines"
316 @set -e; for e in $(ENGINES); do \
318 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
319 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
323 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
324 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
325 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
326 @echo "*** Installing runtime files"
327 : {- output_off() unless windowsdll(); "" -};
328 @set -e; for s in $(SHLIBS); do \
330 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
331 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
332 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
333 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
334 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
336 : {- output_on() unless windowsdll(); "" -};
337 @set -e; for x in $(PROGRAMS); do \
339 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
340 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
341 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
342 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
343 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
345 @set -e; for x in $(BIN_SCRIPTS); do \
347 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
348 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
349 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
350 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
351 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
353 @set -e; for x in $(MISC_SCRIPTS); do \
355 echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
356 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
357 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
358 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
359 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
361 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"
362 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
363 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
364 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
367 @echo "*** Uninstalling runtime files"
368 @set -e; for x in $(PROGRAMS); \
371 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
372 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
374 @set -e; for x in $(BIN_SCRIPTS); \
377 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
378 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
380 @set -e; for x in $(MISC_SCRIPTS); \
383 echo "$(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
384 $(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
386 : {- output_off() unless windowsdll(); "" -};
387 @set -e; for s in $(SHLIBS); do \
389 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
390 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
392 : {- output_on() unless windowsdll(); "" -};
393 $(RM) $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
395 # A method to extract all names from a .pod file
396 # The first sed extracts everything between "=head1 NAME" and the next =head1
397 # The second sed joins all the lines into one
398 # The third sed removes the description and turns all commas into spaces
399 # Voilà , you have a space separated list of names!
400 EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
401 sed -e ':a;{N;s/\n/ /;ba}' | \
402 sed -e 's/ - .*$$//;s/,/ /g'
405 here=`cd $(SRCDIR); pwd`; \
406 point=$$here/util/point.sh; \
407 for ds in apps:1 crypto:3 ssl:3; do \
408 defdir=`echo $$ds | cut -f1 -d:`; \
409 defsec=`echo $$ds | cut -f2 -d:`; \
410 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
411 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
412 [ -z "$$SEC" ] && SEC=$$defsec; \
413 fn=`basename $$p .pod`; \
414 NAME=`echo $$fn | tr [a-z] [A-Z]`; \
415 suf=`eval "echo $$OUTSUFFIX"`; \
416 top=`eval "echo $$OUTTOP"`; \
417 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
418 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
419 cat $$p | eval "$$GENERATE" \
420 > $$top/man$$SEC/$$fn$$suf; \
421 names=`cat $$p | $(EXTRACT_NAMES)`; \
422 ( cd $$top/man$$SEC; \
423 for n in $$names; do \
426 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
427 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
428 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
431 if [ "$$comp_n" != "$$comp_fn" ]; then \
432 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
433 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
440 here=`cd $(SRCDIR); pwd`; \
441 for ds in apps:1 crypto:3 ssl:3; do \
442 defdir=`echo $$ds | cut -f1 -d:`; \
443 defsec=`echo $$ds | cut -f2 -d:`; \
444 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
445 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
446 [ -z "$$SEC" ] && SEC=$$defsec; \
447 fn=`basename $$p .pod`; \
448 suf=`eval "echo $$OUTSUFFIX"`; \
449 top=`eval "echo $$OUTTOP"`; \
450 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
451 $(RM) $$top/man$$SEC/$$fn$$suf; \
452 names=`cat $$p | $(EXTRACT_NAMES)`; \
453 for n in $$names; do \
456 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
457 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
458 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
461 if [ "$$comp_n" != "$$comp_fn" ]; then \
462 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
463 $(RM) $$top/man$$SEC/$$n$$suf; \
470 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
471 @echo "*** Installing manpages"
473 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
474 OUTTOP="$(DESTDIR)$(MANDIR)"; \
475 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
479 @echo "*** Uninstalling manpages"
481 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
482 OUTTOP="$(DESTDIR)$(MANDIR)"; \
486 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
487 @echo "*** Installing HTML manpages"
489 OUTSUFFIX='.$(HTMLSUFFIX)'; \
490 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
491 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
492 --podpath=apps:crypto:ssl \
493 | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \
497 @echo "*** Uninstalling manpages"
499 OUTSUFFIX='.$(HTMLSUFFIX)'; \
500 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
504 # Developer targets (note: these are only available on Unix) #########
506 update: generate errors ordinals
508 generate: generate_apps generate_crypto_bn generate_crypto_objects
510 # Test coverage is a good idea for the future
511 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
514 # Currently disabled, util/selftest.pl needs a rewrite
516 # SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl
519 lint -DLINT $(INCLUDES) $(SRCS)
521 generate_apps: $(SRCDIR)/apps/openssl-vms.cnf $(SRCDIR)/apps/progs.h
523 generate_crypto_bn: $(SRCDIR)/crypto/bn/bn_prime.h
525 generate_crypto_objects: $(SRCDIR)/crypto/objects/obj_dat.h \
526 $(SRCDIR)/include/openssl/obj_mac.h \
527 $(SRCDIR)/crypto/objects/obj_xref.h
530 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
531 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
532 ( cd $(SRCDIR)/engines; \
534 $(PERL) ../util/mkerr.pl -conf $$e \
535 -nostatic -staticloader -write *.c; \
537 ( cd $(SRCDIR)/crypto/ct; \
538 $(PERL) ../../util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c )
541 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
542 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
546 SRCTOP=../$(SRCDIR) \
547 BLDTOP=../$(BLDDIR) \
548 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
553 -etags `find . -name '*.[ch]' -o -name '*.pm'`
555 # Release targets (note: only available on Unix) #####################
558 TMPDIR=/var/tmp/openssl-copy.$$$$; \
559 DISTDIR=openssl-$(VERSION); \
560 mkdir -p $$TMPDIR/$$DISTDIR; \
562 git ls-tree -r --name-only --full-tree HEAD \
564 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
565 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
568 [ -n "$(PREPARE_CMD)" ] && $(PREPARE_CMD); \
569 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
570 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
571 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
572 $(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - $$DISTDIR) \
573 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
575 cd $(SRCDIR); ls -l $(TARFILE).gz
578 @$(MAKE) PREPARE_CMD='./Configure dist' tar
580 # Helper targets #####################################################
582 rehash: link-utils copy-certs build_apps
583 @if [ -z "$(CROSS_COMPILE)" ]; then \
584 (OPENSSL="$(BLDDIR)/util/shlib_wrap.sh apps/openssl"; \
585 [ -x "$(BLDDIR)/openssl.exe" ] && OPENSSL="$(BLDDIR)/openssl.exe" || :; \
586 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
587 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
588 $$OPENSSL rehash certs/demo \
589 || $(PERL) tools/c_rehash certs/demo) && \
593 link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
595 $(BLDDIR)/util/opensslwrap.sh: Makefile
596 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
597 mkdir -p "$(BLDDIR)/util"; \
598 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
600 $(BLDDIR)/util/shlib_wrap.sh: Makefile
601 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
602 mkdir -p "$(BLDDIR)/util"; \
603 ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
607 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
608 cp -R "$(SRCDIR)/certs" "$(BLDDIR)/"; \
611 $(SRCDIR)/apps/openssl-vms.cnf: $(SRCDIR)/apps/openssl.cnf
612 $(PERL) $(SRCDIR)/VMS/VMSify-conf.pl \
613 < $(SRCDIR)/apps/openssl.cnf > $(SRCDIR)/apps/openssl-vms.cnf
615 {- # because the program apps/openssl has object files as sources, and
616 # they then have the corresponding C files as source, we need to chain
617 # the lookups in %unified_info
618 my $apps_openssl = catfile("apps","openssl");
619 our @openssl_source = map { @{$unified_info{sources}->{$_}} }
620 @{$unified_info{sources}->{$apps_openssl}};
622 $(SRCDIR)/apps/progs.h:
624 $(PERL) $(SRCDIR)/apps/progs.pl {- join(" ", @openssl_source) -} > $@
626 $(SRCDIR)/crypto/bn/bn_prime.h: $(SRCDIR)/crypto/bn/bn_prime.pl
627 $(PERL) $(SRCDIR)/crypto/bn/bn_prime.pl > $(SRCDIR)/crypto/bn/bn_prime.h
629 $(SRCDIR)/crypto/objects/obj_dat.h: $(SRCDIR)/crypto/objects/obj_dat.pl \
630 $(SRCDIR)/include/openssl/obj_mac.h
631 $(PERL) $(SRCDIR)/crypto/objects/obj_dat.pl \
632 $(SRCDIR)/include/openssl/obj_mac.h \
633 $(SRCDIR)/crypto/objects/obj_dat.h
635 # objects.pl both reads and writes obj_mac.num
636 $(SRCDIR)/include/openssl/obj_mac.h: $(SRCDIR)/crypto/objects/objects.pl \
637 $(SRCDIR)/crypto/objects/objects.txt \
638 $(SRCDIR)/crypto/objects/obj_mac.num
639 $(PERL) $(SRCDIR)/crypto/objects/objects.pl \
640 $(SRCDIR)/crypto/objects/objects.txt \
641 $(SRCDIR)/crypto/objects/obj_mac.num \
642 $(SRCDIR)/include/openssl/obj_mac.h
643 @sleep 1; touch $(SRCDIR)/include/openssl/obj_mac.h; sleep 1
645 $(SRCDIR)/crypto/objects/obj_xref.h: $(SRCDIR)/crypto/objects/objxref.pl \
646 $(SRCDIR)/crypto/objects/obj_xref.txt \
647 $(SRCDIR)/crypto/objects/obj_mac.num
648 $(PERL) $(SRCDIR)/crypto/objects/objxref.pl \
649 $(SRCDIR)/crypto/objects/obj_mac.num \
650 $(SRCDIR)/crypto/objects/obj_xref.txt \
651 > $(SRCDIR)/crypto/objects/obj_xref.h
652 @sleep 1; touch $(SRCDIR)/crypto/objects/obj_xref.h; sleep 1
656 # Building targets ###################################################
658 libcrypto.pc libssl.pc openssl.pc: Makefile $(LIBS)
660 @ ( echo 'prefix=$(INSTALLTOP)'; \
661 echo 'exec_prefix=$${prefix}'; \
662 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
663 echo 'includedir=$${prefix}/include'; \
665 echo 'Name: OpenSSL-libcrypto'; \
666 echo 'Description: OpenSSL cryptography library'; \
667 echo 'Version: '$(VERSION); \
668 echo 'Libs: -L$${libdir} -lcrypto'; \
669 echo 'Libs.private: $(EX_LIBS)'; \
670 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
673 @ ( echo 'prefix=$(INSTALLTOP)'; \
674 echo 'exec_prefix=$${prefix}'; \
675 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
676 echo 'includedir=$${prefix}/include'; \
678 echo 'Name: OpenSSL-libssl'; \
679 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
680 echo 'Version: '$(VERSION); \
681 echo 'Requires.private: libcrypto'; \
682 echo 'Libs: -L$${libdir} -lssl'; \
683 echo 'Libs.private: $(EX_LIBS)'; \
684 echo 'Cflags: -I$${includedir}' ) > libssl.pc
687 @ ( echo 'prefix=$(INSTALLTOP)'; \
688 echo 'exec_prefix=$${prefix}'; \
689 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
690 echo 'includedir=$${prefix}/include'; \
692 echo 'Name: OpenSSL'; \
693 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
694 echo 'Version: '$(VERSION); \
695 echo 'Requires: libssl libcrypto' ) > openssl.pc
697 # Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which
698 # wasn't passed down automatically. It's quite safe to use it like we do
699 # below; if it doesn't exist, the result will be empty and 'make' will pick
700 # up $(MAKEFLAGS) which is passed down as an environment variable.
701 Makefile: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/config
702 @echo "Makefile is older than {- $config{build_file_template} -}, $(SRCDIR)/Configure or $(SRCDIR)/config."
703 @echo "Reconfiguring..."
704 $(SRCDIR)/Configure reconf
705 @echo "**************************************************"
707 @echo "*** Please run the same make command again ***"
709 @echo "**************************************************"
714 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
716 # Helper function to figure out dependencies on libraries
717 # It takes a list of library names and outputs a list of dependencies
718 sub compute_lib_depends {
719 if ($config{no_shared}) {
720 return map { $_."\$(LIB_EXT)" } @_;
723 # Depending on shared libraries:
724 # On Windows POSIX layers, we depend on {libname}.dll.a
725 # On Unix platforms, we depend on {shlibname}.so
726 return map { if (windowsdll()) {
727 "$_\$(SHLIB_EXT_SIMPLE).a"
730 $unified_info{sharednames}->{$_} || $_;
731 "$libname\$(SHLIB_EXT_SIMPLE)"
737 my $obj = $args{obj};
738 my $srcs = join(" ", @{$args{srcs}});
739 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
740 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
741 my $makedepprog = $config{makedepprog};
742 if ($makedepprog eq "makedepend") {
744 $obj\$(DEP_EXT): $deps
745 rm -f \$\@.tmp; touch \$\@.tmp
746 \$(MAKEDEPEND) -f\$\@.tmp -o"|$obj" \\
747 -- -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs \\
750 sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$\$/d' -e '/^\\(#.*\\| *\\)\$\$/d' \$\@.tmp > \$\@
752 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
753 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
757 $obj\$(DEP_EXT): $deps
758 \$(CC) -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
759 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
760 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
763 # On Unix, we build shlibs from static libs, so we're ignoring the
764 # object file array. We *know* this routine is only called when we've
765 # configure 'shared'.
768 my $lib = $args{lib};
769 my $shlib = $args{shlib};
770 my $libd = dirname($lib);
771 my $libn = basename($lib);
772 (my $libname = $libn) =~ s/^lib//;
773 my $linklibs = join("", map { my $d = dirname($_);
774 my $f = basename($_);
775 (my $l = $f) =~ s/^lib//;
776 " -L$d -l$l" } @{$args{deps}});
777 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
778 my $shlib_target = $target{shared_target};
779 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
780 my $shlibtarget = windowsdll() ?
781 "$lib\$(SHLIB_EXT_SIMPLE).a" : "$shlib\$(SHLIB_EXT_SIMPLE)";
783 # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
784 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
785 # With all other Unix platforms, we often build a shared library with the
786 # SO version built into the file name and a symlink without the SO version
787 # It's not necessary to have both as targets. The choice falls on the
788 # simplest, {libname}\$(SHLIB_EXT_SIMPLE).a for Windows POSIX layers and
789 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
790 $shlibtarget: $lib\$(LIB_EXT) $deps $ordinalsfile
791 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
792 PLATFORM=\$(PLATFORM) \\
793 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
794 INSTALLTOP="\$(INSTALLTOP)" LIBDIR="\$(LIBDIR)" \\
795 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
796 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
797 LIBCOMPATVERSIONS=";\$(SHLIB_VERSION_HISTORY)" \\
798 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
799 CROSS_COMPILE="\$(CROSS_COMPILE)" \\
800 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
801 SHARED_RCFLAGS="\$(SHARED_RCFLAGS)" \\
804 . (windowsdll() ? <<"EOF" : "");
805 rm -f apps/$shlib\$(SHLIB_EXT)
806 rm -f test/$shlib\$(SHLIB_EXT)
807 cp -p $shlib\$(SHLIB_EXT) apps/
808 cp -p $shlib\$(SHLIB_EXT) test/
813 my $lib = $args{lib};
814 my $libd = dirname($lib);
815 my $libn = basename($lib);
816 (my $libname = $libn) =~ s/^lib//;
817 my $shlibdeps = join("", map { my $d = dirname($_);
818 my $f = basename($_);
819 (my $l = $f) =~ s/^lib//;
820 " -L$d -l$l" } @{$args{deps}});
821 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
822 my $shlib_target = $target{shared_target};
823 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
825 $lib\$(SHLIB_EXT_SIMPLE): $objs $deps
826 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
827 PLATFORM=\$(PLATFORM) \\
828 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
829 LIBDEPS="\$(PLIB_LDFLAGS) $shlibdeps \$(EX_LIBS)" \\
830 LIBNAME=$libname LDFLAGS="\$(LDFLAGS)" \\
831 CC="\$(CC)" CFLAGS="\$(CFLAGS)" \\
832 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" \\
833 SHLIB_EXT=\$(SHLIB_EXT_SIMPLE) \\
840 my $lib = $args{lib};
841 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
843 $lib\$(LIB_EXT): $objs
845 \$(RANLIB) \$\@ || echo Never mind.
850 my $bin = $args{bin};
851 my $bind = dirname($bin);
852 my $binn = basename($bin);
853 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
854 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
855 my $linklibs = join("", map { my $d = dirname($_);
856 my $f = basename($_);
857 $d = "." if $d eq $f;
858 (my $l = $f) =~ s/^lib//;
859 " -L$d -l$l" } @{$args{deps}});
860 my $shlib_target = $config{no_shared} ? "" : $target{shared_target};
862 $bin\$(EXE_EXT): $objs $deps
863 \$(RM) $bin\$(EXE_EXT)
864 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
865 PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
866 APPNAME=$bin OBJECTS="$objs" \\
867 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
868 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
869 LIBRPATH="\$(INSTALLTOP)/\$(LIBDIR)" \\
870 link_app.$shlib_target
875 my $script = $args{script};
876 my $sources = join(" ", @{$args{sources}});
877 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
878 "util", "dofile.pl")),
879 rel2abs($config{builddir}));
882 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
883 "-o$target{build_file}" $sources > "$script"
887 "" # Important! This becomes part of the template result.