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
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)" : "") -}
115 SHARED_RCFLAGS={- $target{shared_rcflag} -}
117 PERL={- $config{perl} -}
119 ARFLAGS= {- $target{arflags} -}
120 AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
121 RANLIB= {- $target{ranlib} -}
122 NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
124 TAR= {- $target{tar} || "tar" -}
125 TARFLAGS= {- $target{tarflags} -}
128 NAME= $(BASENAME)-$(VERSION)
129 TARFILE= ../$(NAME).tar
131 # We let the C compiler driver to take care of .s files. This is done in
132 # order to be excused from maintaining a separate set of architecture
133 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
134 # gcc, then the driver will automatically translate it to -xarch=v8plus
135 # and pass it down to assembler.
138 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
140 # For x86 assembler: Set PROCESSOR to 386 if you want to support
142 PROCESSOR= {- $config{processor} -}
144 # The main targets ###################################################
146 all: Makefile libcrypto.pc libssl.pc openssl.pc $(ENGINES) $(PROGRAMS) $(SCRIPTS) $(TESTPROGS) link-utils
148 test tests: $(TESTPROGS) rehash
150 SRCTOP=../$(SRCDIR) \
151 BLDTOP=../$(BLDDIR) \
152 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
155 @TOP=$(SRCDIR) PERL=$(PERL) $(PERL) $(SRCDIR)/test/run_tests.pl list
158 -rm -f `find $(BLDDIR) -name '*$(LIB_EXT)' -o -name '*$(SHLIB_EXT)'`
160 install: install_sw install_ssldirs install_docs
162 uninstall: uninstall_docs uninstall_sw
165 rm -f $(PROGRAMS) $(TESTPROGS)
166 rm -f `find $(BLDDIR) -name '*$(DEP_EXT)'`
167 rm -f `find $(BLDDIR) -name '*$(OBJ_EXT)'`
168 rm -f $(BLDDIR)/core $(BLDDIR)/rehash.time
169 rm -f $(BLDDIR)/tags $(BLDDIR)/TAGS
170 rm -f $(BLDDIR)/openssl.pc $(BLDDIR)/libcrypto.pc $(BLDDIR)/libssl.pc
171 -rm -f `find $(BLDDIR) -type l`
174 DCLEAN_CMD=sed -e '/^DO NOT DELETE.*/,$$d'
176 $(DCLEAN_CMD) < Makefile >Makefile.new
177 mv -f Makefile.new Makefile
179 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
180 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
181 keys %{$unified_info{sources}}); -}
183 ( $(DCLEAN_CMD) < Makefile; \
184 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
186 cat `find . -name '*$(DEP_EXT)'` ) > Makefile.new
187 mv -f Makefile.new Makefile
189 # Install helper targets #############################################
191 install_sw: all install_dev install_engines install_runtime
193 uninstall_sw: uninstall_dev uninstall_engines uninstall_runtime
195 install_docs: install_man_docs install_html_docs
197 uninstall_docs: uninstall_man_docs uninstall_html_docs
200 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
201 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
204 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
205 @echo "*** Installing development files"
206 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
207 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
208 $(BLDDIR)/include/openssl/*.h; do \
210 echo "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
211 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
212 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
214 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
215 @set -e; for l in $(LIBS); do \
217 echo "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
218 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
219 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
220 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
221 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
222 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
224 @ : {- output_off() if $config{no_shared}; "" -}
225 @set -e; for s in $(SHLIBS); do \
227 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
228 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
229 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
230 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
231 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
232 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
233 echo "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
234 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
235 ln -sf $$fn $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
237 : {- output_off() unless windowsdll(); "" -}; \
238 echo "install $$s.a -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
239 cp $$s.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
240 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
241 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \
242 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
243 : {- output_on() unless windowsdll(); "" -}; \
245 @ : {- output_on() if $config{no_shared}; "" -}
246 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
247 @echo "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
248 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
249 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
250 @echo "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
251 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
252 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
253 @echo "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
254 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
255 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
258 @echo "*** Uninstalling development files"
259 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
260 $(BLDDIR)/include/openssl/*.h; do \
262 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
263 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
265 @set -e; for l in $(LIBS); do \
267 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
268 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
270 @set -e; for s in $(SHLIBS); do \
272 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
273 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
274 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
275 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
277 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
278 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
279 : {- output_off() unless windowsdll(); "" -}; \
280 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
281 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
282 : {- output_on() unless windowsdll(); "" -}; \
284 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
285 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
286 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
287 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
288 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
289 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
292 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
293 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/
294 @echo "*** Installing engines"
295 @set -e; for e in $(ENGINES); do \
297 echo "install $$e -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
298 cp $$e $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
299 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
300 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \
301 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
305 @echo "*** Uninstalling engines"
306 @set -e; for e in $(ENGINES); do \
308 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
309 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
313 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
314 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
315 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
316 @echo "*** Installing runtime files"
317 : {- output_off() unless windowsdll(); "" -};
318 @set -e; for s in $(SHLIBS); do \
320 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
321 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
322 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
323 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
324 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
326 : {- output_on() unless windowsdll(); "" -};
327 @set -e; for x in $(PROGRAMS); do \
329 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
330 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
331 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
332 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
333 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
335 @set -e; for x in $(BIN_SCRIPTS); do \
337 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
338 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
339 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
340 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
341 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
343 @set -e; for x in $(MISC_SCRIPTS); do \
345 echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
346 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
347 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
348 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
349 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
351 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"
352 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
353 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
354 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
357 @echo "*** Uninstalling runtime files"
358 @set -e; for x in $(PROGRAMS); \
361 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
362 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
364 @set -e; for x in $(BIN_SCRIPTS); \
367 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
368 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
370 @set -e; for x in $(MISC_SCRIPTS); \
373 echo "$(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
374 $(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
376 : {- output_off() unless windowsdll(); "" -};
377 @set -e; for s in $(SHLIBS); do \
379 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
380 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
382 : {- output_on() unless windowsdll(); "" -};
383 $(RM) $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
385 # A method to extract all names from a .pod file
386 # The first sed extracts everything between "=head1 NAME" and the next =head1
387 # The second sed joins all the lines into one
388 # The third sed removes the description and turns all commas into spaces
389 # Voilà , you have a space separated list of names!
390 EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
391 sed -e ':a;{N;s/\n/ /;ba}' | \
392 sed -e 's/ - .*$$//;s/,/ /g'
395 here=`cd $(SRCDIR); pwd`; \
396 point=$$here/util/point.sh; \
397 for ds in apps:1 crypto:3 ssl:3; do \
398 defdir=`echo $$ds | cut -f1 -d:`; \
399 defsec=`echo $$ds | cut -f2 -d:`; \
400 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
401 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
402 [ -z "$$SEC" ] && SEC=$$defsec; \
403 fn=`basename $$p .pod`; \
404 NAME=`echo $$fn | tr [a-z] [A-Z]`; \
405 suf=`eval "echo $$OUTSUFFIX"`; \
406 top=`eval "echo $$OUTTOP"`; \
407 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
408 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
409 cat $$p | eval "$$GENERATE" \
410 > $$top/man$$SEC/$$fn$$suf; \
411 names=`cat $$p | $(EXTRACT_NAMES)`; \
412 ( cd $$top/man$$SEC; \
413 for n in $$names; do \
416 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
417 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
418 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
421 if [ "$$comp_n" != "$$comp_fn" ]; then \
422 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
423 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
430 here=`cd $(SRCDIR); pwd`; \
431 for ds in apps:1 crypto:3 ssl:3; do \
432 defdir=`echo $$ds | cut -f1 -d:`; \
433 defsec=`echo $$ds | cut -f2 -d:`; \
434 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
435 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
436 [ -z "$$SEC" ] && SEC=$$defsec; \
437 fn=`basename $$p .pod`; \
438 suf=`eval "echo $$OUTSUFFIX"`; \
439 top=`eval "echo $$OUTTOP"`; \
440 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
441 $(RM) $$top/man$$SEC/$$fn$$suf; \
442 names=`cat $$p | $(EXTRACT_NAMES)`; \
443 for n in $$names; do \
446 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
447 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
448 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
451 if [ "$$comp_n" != "$$comp_fn" ]; then \
452 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
453 $(RM) $$top/man$$SEC/$$n$$suf; \
460 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
461 @echo "*** Installing manpages"
463 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
464 OUTTOP="$(DESTDIR)$(MANDIR)"; \
465 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
469 @echo "*** Uninstalling manpages"
471 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
472 OUTTOP="$(DESTDIR)$(MANDIR)"; \
476 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
477 @echo "*** Installing HTML manpages"
479 OUTSUFFIX='.$(HTMLSUFFIX)'; \
480 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
481 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
482 --podpath=apps:crypto:ssl \
483 | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \
487 @echo "*** Uninstalling manpages"
489 OUTSUFFIX='.$(HTMLSUFFIX)'; \
490 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
494 # Developer targets (note: these are only available on Unix) #########
496 update: generate errors ordinals
498 generate: generate_apps generate_crypto_bn generate_crypto_objects
500 # Test coverage is a good idea for the future
501 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
504 # Currently disabled, util/selftest.pl needs a rewrite
506 # SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl
509 lint -DLINT $(INCLUDES) $(SRCS)
511 generate_apps: $(SRCDIR)/apps/openssl-vms.cnf $(SRCDIR)/apps/progs.h
513 generate_crypto_bn: $(SRCDIR)/crypto/bn/bn_prime.h
515 generate_crypto_objects: $(SRCDIR)/crypto/objects/obj_dat.h \
516 $(SRCDIR)/include/openssl/obj_mac.h \
517 $(SRCDIR)/crypto/objects/obj_xref.h
520 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
521 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
522 ( cd $(SRCDIR)/engines; \
524 $(PERL) ../util/mkerr.pl -conf $$e \
525 -nostatic -staticloader -write *.c; \
527 ( cd $(SRCDIR)/crypto/ct; \
528 $(PERL) ../../util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c )
531 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
532 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
536 SRCTOP=../$(SRCDIR) \
537 BLDTOP=../$(BLDDIR) \
538 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
543 -etags `find . -name '*.[ch]' -o -name '*.pm'`
545 # Release targets (note: only available on Unix) #####################
548 TMPDIR=/var/tmp/openssl-copy.$$$$; \
549 DISTDIR=openssl-$(VERSION); \
550 mkdir -p $$TMPDIR/$$DISTDIR; \
552 git ls-tree -r --name-only --full-tree HEAD \
554 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
555 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
558 [ -n "$(PREPARE_CMD)" ] && $(PREPARE_CMD); \
559 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
560 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
561 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
562 $(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - $$DISTDIR) \
563 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
565 cd $(SRCDIR); ls -l $(TARFILE).gz
568 @$(MAKE) PREPARE_CMD='./Configure dist' tar
570 # Helper targets #####################################################
572 rehash: link-utils copy-certs
573 @if [ -z "$(CROSS_COMPILE)" ]; then \
574 (OPENSSL="$(BLDDIR)/util/shlib_wrap.sh apps/openssl"; \
575 [ -x "$(BLDDIR)/openssl.exe" ] && OPENSSL="$(BLDDIR)/openssl.exe" || :; \
576 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
577 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
578 $$OPENSSL rehash certs/demo \
579 || $(PERL) tools/c_rehash certs/demo) && \
583 link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
585 $(BLDDIR)/util/opensslwrap.sh: Makefile
586 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
587 mkdir -p "$(BLDDIR)/util"; \
588 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
590 $(BLDDIR)/util/shlib_wrap.sh: Makefile
591 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
592 mkdir -p "$(BLDDIR)/util"; \
593 ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
597 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
598 cp -R "$(SRCDIR)/certs" "$(BLDDIR)/"; \
601 $(SRCDIR)/apps/openssl-vms.cnf: $(SRCDIR)/apps/openssl.cnf
602 $(PERL) $(SRCDIR)/VMS/VMSify-conf.pl \
603 < $(SRCDIR)/apps/openssl.cnf > $(SRCDIR)/apps/openssl-vms.cnf
605 {- # because the program apps/openssl has object files as sources, and
606 # they then have the corresponding C files as source, we need to chain
607 # the lookups in %unified_info
608 my $apps_openssl = catfile("apps","openssl");
609 our @openssl_source = map { @{$unified_info{sources}->{$_}} }
610 @{$unified_info{sources}->{$apps_openssl}};
612 $(SRCDIR)/apps/progs.h:
614 $(PERL) $(SRCDIR)/apps/progs.pl {- join(" ", @openssl_source) -} > $@
616 $(SRCDIR)/crypto/bn/bn_prime.h: $(SRCDIR)/crypto/bn/bn_prime.pl
617 $(PERL) $(SRCDIR)/crypto/bn/bn_prime.pl > $(SRCDIR)/crypto/bn/bn_prime.h
619 $(SRCDIR)/crypto/objects/obj_dat.h: $(SRCDIR)/crypto/objects/obj_dat.pl \
620 $(SRCDIR)/include/openssl/obj_mac.h
621 $(PERL) $(SRCDIR)/crypto/objects/obj_dat.pl \
622 $(SRCDIR)/include/openssl/obj_mac.h \
623 $(SRCDIR)/crypto/objects/obj_dat.h
625 # objects.pl both reads and writes obj_mac.num
626 $(SRCDIR)/include/openssl/obj_mac.h: $(SRCDIR)/crypto/objects/objects.pl \
627 $(SRCDIR)/crypto/objects/objects.txt \
628 $(SRCDIR)/crypto/objects/obj_mac.num
629 $(PERL) $(SRCDIR)/crypto/objects/objects.pl \
630 $(SRCDIR)/crypto/objects/objects.txt \
631 $(SRCDIR)/crypto/objects/obj_mac.num \
632 $(SRCDIR)/include/openssl/obj_mac.h
633 @sleep 1; touch $(SRCDIR)/include/openssl/obj_mac.h; sleep 1
635 $(SRCDIR)/crypto/objects/obj_xref.h: $(SRCDIR)/crypto/objects/objxref.pl \
636 $(SRCDIR)/crypto/objects/obj_xref.txt \
637 $(SRCDIR)/crypto/objects/obj_mac.num
638 $(PERL) $(SRCDIR)/crypto/objects/objxref.pl \
639 $(SRCDIR)/crypto/objects/obj_mac.num \
640 $(SRCDIR)/crypto/objects/obj_xref.txt \
641 > $(SRCDIR)/crypto/objects/obj_xref.h
642 @sleep 1; touch $(SRCDIR)/crypto/objects/obj_xref.h; sleep 1
646 # Building targets ###################################################
648 libcrypto.pc libssl.pc openssl.pc: Makefile $(LIBS)
650 @ ( echo 'prefix=$(INSTALLTOP)'; \
651 echo 'exec_prefix=$${prefix}'; \
652 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
653 echo 'includedir=$${prefix}/include'; \
655 echo 'Name: OpenSSL-libcrypto'; \
656 echo 'Description: OpenSSL cryptography library'; \
657 echo 'Version: '$(VERSION); \
658 echo 'Libs: -L$${libdir} -lcrypto'; \
659 echo 'Libs.private: $(EX_LIBS)'; \
660 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
663 @ ( echo 'prefix=$(INSTALLTOP)'; \
664 echo 'exec_prefix=$${prefix}'; \
665 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
666 echo 'includedir=$${prefix}/include'; \
668 echo 'Name: OpenSSL-libssl'; \
669 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
670 echo 'Version: '$(VERSION); \
671 echo 'Requires.private: libcrypto'; \
672 echo 'Libs: -L$${libdir} -lssl'; \
673 echo 'Libs.private: $(EX_LIBS)'; \
674 echo 'Cflags: -I$${includedir}' ) > libssl.pc
677 @ ( echo 'prefix=$(INSTALLTOP)'; \
678 echo 'exec_prefix=$${prefix}'; \
679 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
680 echo 'includedir=$${prefix}/include'; \
682 echo 'Name: OpenSSL'; \
683 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
684 echo 'Version: '$(VERSION); \
685 echo 'Requires: libssl libcrypto' ) > openssl.pc
687 # Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which
688 # wasn't passed down automatically. It's quite safe to use it like we do
689 # below; if it doesn't exist, the result will be empty and 'make' will pick
690 # up $(MAKEFLAGS) which is passed down as an environment variable.
691 Makefile: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/config
692 @echo "Makefile is older than {- $config{build_file_template} -}, $(SRCDIR)/Configure or $(SRCDIR)/config."
693 @echo "Reconfiguring..."
694 $(SRCDIR)/Configure reconf
695 @echo "**************************************************"
697 @echo "*** Please run the same make command again ***"
699 @echo "**************************************************"
704 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
706 # Helper function to figure out dependencies on libraries
707 # It takes a list of library names and outputs a list of dependencies
708 sub compute_lib_depends {
709 if ($config{no_shared}) {
710 return map { $_."\$(LIB_EXT)" } @_;
713 # Depending on shared libraries:
714 # On Windows POSIX layers, we depend on {libname}.dll.a
715 # On Unix platforms, we depend on {shlibname}.so
716 return map { if (windowsdll()) {
717 "$_\$(SHLIB_EXT_SIMPLE).a"
720 $unified_info{sharednames}->{$_} || $_;
721 "$libname\$(SHLIB_EXT_SIMPLE)"
727 my $dep = $args{obj}.'$(DEP_EXT)';
728 my $obj = $args{obj}.'$(OBJ_EXT)';
729 my $srcs = join(" ", @{$args{srcs}});
730 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
731 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
732 my $makedepprog = $config{makedepprog};
733 if ($makedepprog eq "makedepend") {
736 rm -f \$\@.tmp; touch \$\@.tmp
737 \$(MAKEDEPEND) -f\$\@.tmp -o"|$obj"\
738 -- -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs \
740 sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$/d' -e '/^\\(#.*\\| *\\)\$/d' \$\@.tmp > \$\@
745 $dep : $deps Makefile
746 \$(CC) -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
751 my $obj = $args{obj}.'$(OBJ_EXT)';
752 my $srcs = join(" ", @{$args{srcs}});
753 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
754 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
757 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
760 # On Unix, we build shlibs from static libs, so we're ignoring the
761 # object file array. We *know* this routine is only called when we've
762 # configure 'shared'.
765 my $lib = $args{lib};
766 my $shlib = $args{shlib};
767 my $libd = dirname($lib);
768 my $libn = basename($lib);
769 (my $libname = $libn) =~ s/^lib//;
770 my $linklibs = join("", map { my $d = dirname($_);
771 my $f = basename($_);
772 (my $l = $f) =~ s/^lib//;
773 " -L$d -l$l" } @{$args{deps}});
774 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
775 my $shlib_target = $target{shared_target};
776 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
777 my $shlibtarget = windowsdll() ?
778 "$lib\$(SHLIB_EXT_SIMPLE).a" : "$shlib\$(SHLIB_EXT_SIMPLE)";
780 # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
781 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
782 # With all other Unix platforms, we often build a shared library with the
783 # SO version built into the file name and a symlink without the SO version
784 # It's not necessary to have both as targets. The choice falls on the
785 # simplest, {libname}\$(SHLIB_EXT_SIMPLE).a for Windows POSIX layers and
786 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
787 $shlibtarget : $lib\$(LIB_EXT) $deps $ordinalsfile
788 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
789 PLATFORM=\$(PLATFORM) \\
790 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
791 INSTALLTOP="\$(INSTALLTOP)" LIBDIR="\$(LIBDIR)" \\
792 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
793 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
794 LIBCOMPATVERSIONS=";\$(SHLIB_VERSION_HISTORY)" \\
795 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
796 CROSS_COMPILE="\$(CROSS_COMPILE)" \\
797 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
798 SHARED_RCFLAGS="\$(SHARED_RCFLAGS)" \\
801 . (windowsdll() ? <<"EOF" : "");
802 rm -f apps/$shlib\$(SHLIB_EXT)
803 rm -f test/$shlib\$(SHLIB_EXT)
804 cp -p $shlib\$(SHLIB_EXT) apps/
805 cp -p $shlib\$(SHLIB_EXT) test/
810 my $lib = $args{lib};
811 my $libd = dirname($lib);
812 my $libn = basename($lib);
813 (my $libname = $libn) =~ s/^lib//;
814 my $shlibdeps = join("", map { my $d = dirname($_);
815 my $f = basename($_);
816 (my $l = $f) =~ s/^lib//;
817 " -L$d -l$l" } @{$args{deps}});
818 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
819 my $shlib_target = $target{shared_target};
820 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
822 $lib\$(SHLIB_EXT_SIMPLE): $objs $deps
823 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
824 PLATFORM=\$(PLATFORM) \\
825 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
826 LIBDEPS="\$(PLIB_LDFLAGS) $shlibdeps \$(EX_LIBS)" \\
827 LIBNAME=$libname LDFLAGS="\$(LDFLAGS)" \\
828 CC="\$(CC)" CFLAGS="\$(CFLAGS)" \\
829 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" \\
830 SHLIB_EXT=\$(SHLIB_EXT_SIMPLE) \\
837 my $lib = $args{lib};
838 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
840 $lib\$(LIB_EXT) : $objs
842 \$(RANLIB) \$\@ || echo Never mind.
847 my $bin = $args{bin};
848 my $bind = dirname($bin);
849 my $binn = basename($bin);
850 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
851 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
852 my $linklibs = join("", map { my $d = dirname($_);
853 my $f = basename($_);
854 $d = "." if $d eq $f;
855 (my $l = $f) =~ s/^lib//;
856 " -L$d -l$l" } @{$args{deps}});
857 my $shlib_target = $config{no_shared} ? "" : $target{shared_target};
859 $bin\$(EXE_EXT) : $objs $deps
860 \$(RM) $bin\$(EXE_EXT)
861 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
862 PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
863 APPNAME=$bin OBJECTS="$objs" \\
864 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
865 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
866 LIBRPATH="\$(INSTALLTOP)/\$(LIBDIR)" \\
867 link_app.$shlib_target
872 my $script = $args{script};
873 my $sources = join(" ", @{$args{sources}});
874 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
875 "util", "dofile.pl")),
876 rel2abs($config{builddir}));
879 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" $sources > "$script"
883 "" # Important! This becomes part of the template result.