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 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
41 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
42 keys %{$unified_info{sources}}); -}
44 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
45 MISC_SCRIPTS=$(SRCDIR)/tools/c_hash $(SRCDIR)/tools/c_info \
46 $(SRCDIR)/tools/c_issuer $(SRCDIR)/tools/c_name \
47 $(BLDDIR)/apps/CA.pl $(SRCDIR)/apps/tsget
49 # DESTDIR is for package builders so that they can configure for, say,
50 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
51 # Normally it is left empty.
54 # Do not edit these manually. Use Configure with --prefix or --openssldir
55 # to change this! Short explanation in the top comment in Configure
56 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
58 our $prefix = $config{prefix} || "/usr/local";
61 # The logic here is that if no --openssldir was given,
62 # OPENSSLDIR will get the value from $prefix plus "/ssl".
63 # If --openssldir was given and the value is an absolute
64 # path, OPENSSLDIR will get its value without change.
65 # If the value from --openssldir is a relative path,
66 # OPENSSLDIR will get $prefix with the --openssldir
67 # value appended as a subdirectory.
69 use File::Spec::Functions;
72 (file_name_is_absolute($config{openssldir}) ?
74 : catdir($prefix, $config{openssldir}))
75 : catdir($prefix, "ssl");
78 # if $prefix/lib$target{multilib} is not an existing
79 # directory, then assume that it's not searched by linker
80 # automatically, in which case adding $target{multilib} suffix
81 # causes more grief than we're ready to tolerate, so don't...
83 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
84 our $libdir = $config{libdir} || "lib$multilib";
86 ENGINESDIR={- use File::Spec::Functions;
87 catdir($prefix,$libdir,"engines") -}
89 MANDIR=$(INSTALLTOP)/share/man
90 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
91 HTMLDIR=$(DOCDIR)/html
93 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
94 # appended after the manpage file section number. "ssl" is popular,
95 # resulting in files such as config.5ssl rather than config.5.
101 CROSS_COMPILE= {- $config{cross_compile_prefix} -}
102 CC= $(CROSS_COMPILE){- $target{cc} -}
103 CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $config{cflags} -}
104 CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
105 LDFLAGS= {- $config{lflags} -}
106 PLIB_LDFLAGS= {- $config{plib_lflags} -}
107 EX_LIBS= {- $config{ex_libs} -}
108 SHARED_LDFLAGS={- $target{shared_ldflag}
109 # Unlike other OSes (like Solaris, Linux, Tru64,
110 # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
111 # and FreeBSD) "demand" RPATH set on .so objects.
112 # Apparently application RPATH is not global and
113 # does not apply to .so linked with other .so.
114 # Problem manifests itself when libssl.so fails to
115 # load libcrypto.so. One can argue that we should
116 # engrave this into Makefile.shared rules or into
117 # BSD-* config lines above. Meanwhile let's try to
118 # be cautious and pass -rpath to linker only when
119 # $prefix is not /usr.
120 . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
121 ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
122 SHARED_RCFLAGS={- $target{shared_rcflag} -}
124 PERL={- $config{perl} -}
126 ARFLAGS= {- $target{arflags} -}
127 AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
128 RANLIB= {- $target{ranlib} -}
129 NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
131 TAR= {- $target{tar} || "tar" -}
132 TARFLAGS= {- $target{tarflags} -}
133 MAKEDEPEND=$(CROSS_COMPILE){- $config{makedepprog} -}
136 NAME= $(BASENAME)-$(VERSION)
137 TARFILE= ../$(NAME).tar
139 # We let the C compiler driver to take care of .s files. This is done in
140 # order to be excused from maintaining a separate set of architecture
141 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
142 # gcc, then the driver will automatically translate it to -xarch=v8plus
143 # and pass it down to assembler.
146 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
148 # For x86 assembler: Set PROCESSOR to 386 if you want to support
150 PROCESSOR= {- $config{processor} -}
152 # The main targets ###################################################
154 all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep \
157 build_libs: configdata.pm build_libs_nodep depend
158 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
159 build_engines: configdata.pm build_engines_nodep depend
160 build_engines_nodep: $(ENGINES)
161 build_apps: configdata.pm build_apps_nodep depend
162 build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
163 build_tests: configdata.pm build_tests_nodep depend
164 build_tests_nodep: $(TESTPROGS)
166 test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend rehash
168 SRCTOP=../$(SRCDIR) \
169 BLDTOP=../$(BLDDIR) \
171 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
174 @TOP=$(SRCDIR) PERL=$(PERL) $(PERL) $(SRCDIR)/test/run_tests.pl list
177 -rm -f `find $(BLDDIR) -name '*$(LIB_EXT)' -o -name '*$(SHLIB_EXT)'`
179 install: install_sw install_ssldirs install_docs
181 uninstall: uninstall_docs uninstall_sw
184 rm -f $(PROGRAMS) $(TESTPROGS)
185 rm -f `find $(BLDDIR) -name '*$(DEP_EXT)'`
186 rm -f `find $(BLDDIR) -name '*$(OBJ_EXT)'`
187 rm -f $(BLDDIR)/core $(BLDDIR)/rehash.time
188 rm -f $(BLDDIR)/tags $(BLDDIR)/TAGS
189 rm -f $(BLDDIR)/openssl.pc $(BLDDIR)/libcrypto.pc $(BLDDIR)/libssl.pc
190 -rm -f `find $(BLDDIR) -type l`
193 # This exists solely for those who still type 'make depend'
196 @( sed -e '/^# DO NOT DELETE THIS LINE.*/,$$d' < Makefile; \
197 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
199 for d in $(DEPS); do \
200 if [ -f $$d ]; then cat $$d; fi; \
201 done ) > Makefile.new
202 @if ! cmp Makefile.new Makefile >/dev/null 2>&1; then \
203 mv -f Makefile.new Makefile; \
206 # Install helper targets #############################################
208 install_sw: all install_dev install_engines install_runtime
210 uninstall_sw: uninstall_dev uninstall_engines uninstall_runtime
212 install_docs: install_man_docs install_html_docs
214 uninstall_docs: uninstall_man_docs uninstall_html_docs
215 $(RM) -r -v $(DESTDIR)$(DOCDIR)
218 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
219 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
222 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
223 @echo "*** Installing development files"
224 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
225 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
226 $(BLDDIR)/include/openssl/*.h; do \
228 echo "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
229 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
230 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
232 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
233 @set -e; for l in $(LIBS); do \
235 echo "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
236 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
237 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
238 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
239 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
240 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
242 @ : {- output_off() if $config{no_shared}; "" -}
243 @set -e; for s in $(SHLIBS); do \
245 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
246 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
247 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
248 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
249 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
250 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
251 echo "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
252 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
253 ln -sf $$fn $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
255 : {- output_off() unless windowsdll(); "" -}; \
256 echo "install $$s.a -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
257 cp $$s.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
258 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
259 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \
260 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
261 : {- output_on() unless windowsdll(); "" -}; \
263 @ : {- output_on() if $config{no_shared}; "" -}
264 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
265 @echo "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
266 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
267 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
268 @echo "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
269 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
270 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
271 @echo "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
272 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
273 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
276 @echo "*** Uninstalling development files"
277 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
278 $(BLDDIR)/include/openssl/*.h; do \
280 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
281 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
283 @set -e; for l in $(LIBS); do \
285 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
286 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
288 @set -e; for s in $(SHLIBS); do \
290 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
291 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
292 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
293 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
295 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
296 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
297 : {- output_off() unless windowsdll(); "" -}; \
298 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
299 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
300 : {- output_on() unless windowsdll(); "" -}; \
302 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
303 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
304 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
305 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
306 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
307 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
310 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
311 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/
312 @echo "*** Installing engines"
313 @set -e; for e in $(ENGINES); do \
315 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
318 echo "install $$e -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn"; \
319 cp $$e $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
320 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
321 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \
322 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
326 @echo "*** Uninstalling engines"
327 @set -e; for e in $(ENGINES); do \
329 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
332 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn"; \
333 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
337 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
338 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
339 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
340 @echo "*** Installing runtime files"
341 : {- output_off() unless windowsdll(); "" -};
342 @set -e; for s in $(SHLIBS); do \
344 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
345 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
346 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
347 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
348 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
350 : {- output_on() unless windowsdll(); "" -};
351 @set -e; for x in $(PROGRAMS); do \
353 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
354 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
355 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
356 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
357 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
359 @set -e; for x in $(BIN_SCRIPTS); do \
361 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
362 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
363 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
364 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
365 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
367 @set -e; for x in $(MISC_SCRIPTS); do \
369 echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
370 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
371 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
372 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
373 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
375 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"
376 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
377 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
378 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
381 @echo "*** Uninstalling runtime files"
382 @set -e; for x in $(PROGRAMS); \
385 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
386 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
388 @set -e; for x in $(BIN_SCRIPTS); \
391 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
392 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
394 @set -e; for x in $(MISC_SCRIPTS); \
397 echo "$(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
398 $(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
400 : {- output_off() unless windowsdll(); "" -};
401 @set -e; for s in $(SHLIBS); do \
403 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
404 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
406 : {- output_on() unless windowsdll(); "" -};
407 $(RM) $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
409 # A method to extract all names from a .pod file
410 # The first sed extracts everything between "=head1 NAME" and the next =head1
411 # The second sed joins all the lines into one
412 # The third sed removes the description and turns all commas into spaces
413 # Voilà , you have a space separated list of names!
414 EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
415 sed -e ':a;{N;s/\n/ /;ba}' | \
416 sed -e 's/ - .*$$//;s/,/ /g'
419 here=`cd $(SRCDIR); pwd`; \
420 point=$$here/util/point.sh; \
421 for ds in apps:1 crypto:3 ssl:3; do \
422 defdir=`echo $$ds | cut -f1 -d:`; \
423 defsec=`echo $$ds | cut -f2 -d:`; \
424 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
425 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
426 [ -z "$$SEC" ] && SEC=$$defsec; \
427 fn=`basename $$p .pod`; \
428 NAME=`echo $$fn | tr [a-z] [A-Z]`; \
429 suf=`eval "echo $$OUTSUFFIX"`; \
430 top=`eval "echo $$OUTTOP"`; \
431 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
432 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
433 cat $$p | eval "$$GENERATE" \
434 > $$top/man$$SEC/$$fn$$suf; \
435 names=`cat $$p | $(EXTRACT_NAMES)`; \
436 ( cd $$top/man$$SEC; \
437 for n in $$names; do \
440 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
441 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
442 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
445 if [ "$$comp_n" != "$$comp_fn" ]; then \
446 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
447 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
454 here=`cd $(SRCDIR); pwd`; \
455 for ds in apps:1 crypto:3 ssl:3; do \
456 defdir=`echo $$ds | cut -f1 -d:`; \
457 defsec=`echo $$ds | cut -f2 -d:`; \
458 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
459 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
460 [ -z "$$SEC" ] && SEC=$$defsec; \
461 fn=`basename $$p .pod`; \
462 suf=`eval "echo $$OUTSUFFIX"`; \
463 top=`eval "echo $$OUTTOP"`; \
464 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
465 $(RM) $$top/man$$SEC/$$fn$$suf; \
466 names=`cat $$p | $(EXTRACT_NAMES)`; \
467 for n in $$names; do \
470 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
471 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
472 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
475 if [ "$$comp_n" != "$$comp_fn" ]; then \
476 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
477 $(RM) $$top/man$$SEC/$$n$$suf; \
480 ( $(RMDIR) $$top/man$$SEC 2>/dev/null || exit 0 ); \
485 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
486 @echo "*** Installing manpages"
488 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
489 OUTTOP="$(DESTDIR)$(MANDIR)"; \
490 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
494 @echo "*** Uninstalling manpages"
496 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
497 OUTTOP="$(DESTDIR)$(MANDIR)"; \
501 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
502 @echo "*** Installing HTML manpages"
504 OUTSUFFIX='.$(HTMLSUFFIX)'; \
505 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
506 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
507 --podpath=apps:crypto:ssl \
508 | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \
512 @echo "*** Uninstalling manpages"
514 OUTSUFFIX='.$(HTMLSUFFIX)'; \
515 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
519 # Developer targets (note: these are only available on Unix) #########
521 update: generate errors ordinals
523 generate: generate_apps generate_crypto_bn generate_crypto_objects
525 # Test coverage is a good idea for the future
526 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
529 # Currently disabled, util/selftest.pl needs a rewrite
531 # SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl
534 lint -DLINT $(INCLUDES) $(SRCS)
536 generate_apps: $(SRCDIR)/apps/openssl-vms.cnf $(SRCDIR)/apps/progs.h
538 generate_crypto_bn: $(SRCDIR)/crypto/bn/bn_prime.h
540 generate_crypto_objects: $(SRCDIR)/crypto/objects/obj_dat.h \
541 $(SRCDIR)/include/openssl/obj_mac.h \
542 $(SRCDIR)/crypto/objects/obj_xref.h
545 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
546 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
547 ( cd $(SRCDIR)/engines; \
549 $(PERL) ../util/mkerr.pl -conf $$e \
550 -nostatic -staticloader -write *.c; \
552 ( cd $(SRCDIR)/crypto/ct; \
553 $(PERL) ../../util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c )
556 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
557 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
561 SRCTOP=../$(SRCDIR) \
562 BLDTOP=../$(BLDDIR) \
563 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
568 -etags `find . -name '*.[ch]' -o -name '*.pm'`
570 # Release targets (note: only available on Unix) #####################
573 TMPDIR=/var/tmp/openssl-copy.$$$$; \
574 DISTDIR=openssl-$(VERSION); \
575 mkdir -p $$TMPDIR/$$DISTDIR; \
577 git ls-tree -r --name-only --full-tree HEAD \
579 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
580 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
583 [ -n "$(PREPARE_CMD)" ] && $(PREPARE_CMD); \
584 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
585 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
586 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
587 $(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - $$DISTDIR) \
588 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
590 cd $(SRCDIR); ls -l $(TARFILE).gz
593 @$(MAKE) PREPARE_CMD='./Configure dist' tar
595 # Helper targets #####################################################
597 rehash: link-utils copy-certs build_apps_nodep
598 @if [ -z "$(CROSS_COMPILE)" ]; then \
599 (OPENSSL="$(BLDDIR)/util/shlib_wrap.sh apps/openssl"; \
600 [ -x "$(BLDDIR)/openssl.exe" ] && OPENSSL="$(BLDDIR)/openssl.exe" || :; \
601 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
602 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
603 $$OPENSSL rehash certs/demo \
604 || $(PERL) tools/c_rehash certs/demo) && \
608 link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
610 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
611 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
612 mkdir -p "$(BLDDIR)/util"; \
613 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
615 $(BLDDIR)/util/shlib_wrap.sh: configdata.pm
616 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
617 mkdir -p "$(BLDDIR)/util"; \
618 ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
622 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
623 cp -R "$(SRCDIR)/certs" "$(BLDDIR)/"; \
626 $(SRCDIR)/apps/openssl-vms.cnf: $(SRCDIR)/apps/openssl.cnf
627 $(PERL) $(SRCDIR)/VMS/VMSify-conf.pl \
628 < $(SRCDIR)/apps/openssl.cnf > $(SRCDIR)/apps/openssl-vms.cnf
630 {- # because the program apps/openssl has object files as sources, and
631 # they then have the corresponding C files as source, we need to chain
632 # the lookups in %unified_info
633 my $apps_openssl = catfile("apps","openssl");
634 our @openssl_source = map { @{$unified_info{sources}->{$_}} }
635 @{$unified_info{sources}->{$apps_openssl}};
637 $(SRCDIR)/apps/progs.h:
639 $(PERL) $(SRCDIR)/apps/progs.pl {- join(" ", @openssl_source) -} > $@
641 $(SRCDIR)/crypto/bn/bn_prime.h: $(SRCDIR)/crypto/bn/bn_prime.pl
642 $(PERL) $(SRCDIR)/crypto/bn/bn_prime.pl > $(SRCDIR)/crypto/bn/bn_prime.h
644 $(SRCDIR)/crypto/objects/obj_dat.h: $(SRCDIR)/crypto/objects/obj_dat.pl \
645 $(SRCDIR)/include/openssl/obj_mac.h
646 $(PERL) $(SRCDIR)/crypto/objects/obj_dat.pl \
647 $(SRCDIR)/include/openssl/obj_mac.h \
648 $(SRCDIR)/crypto/objects/obj_dat.h
650 # objects.pl both reads and writes obj_mac.num
651 $(SRCDIR)/include/openssl/obj_mac.h: $(SRCDIR)/crypto/objects/objects.pl \
652 $(SRCDIR)/crypto/objects/objects.txt \
653 $(SRCDIR)/crypto/objects/obj_mac.num
654 $(PERL) $(SRCDIR)/crypto/objects/objects.pl \
655 $(SRCDIR)/crypto/objects/objects.txt \
656 $(SRCDIR)/crypto/objects/obj_mac.num \
657 $(SRCDIR)/include/openssl/obj_mac.h
658 @sleep 1; touch $(SRCDIR)/include/openssl/obj_mac.h; sleep 1
660 $(SRCDIR)/crypto/objects/obj_xref.h: $(SRCDIR)/crypto/objects/objxref.pl \
661 $(SRCDIR)/crypto/objects/obj_xref.txt \
662 $(SRCDIR)/crypto/objects/obj_mac.num
663 $(PERL) $(SRCDIR)/crypto/objects/objxref.pl \
664 $(SRCDIR)/crypto/objects/obj_mac.num \
665 $(SRCDIR)/crypto/objects/obj_xref.txt \
666 > $(SRCDIR)/crypto/objects/obj_xref.h
667 @sleep 1; touch $(SRCDIR)/crypto/objects/obj_xref.h; sleep 1
671 # Building targets ###################################################
673 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS)
675 @ ( echo 'prefix=$(INSTALLTOP)'; \
676 echo 'exec_prefix=$${prefix}'; \
677 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
678 echo 'includedir=$${prefix}/include'; \
680 echo 'Name: OpenSSL-libcrypto'; \
681 echo 'Description: OpenSSL cryptography library'; \
682 echo 'Version: '$(VERSION); \
683 echo 'Libs: -L$${libdir} -lcrypto'; \
684 echo 'Libs.private: $(EX_LIBS)'; \
685 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
688 @ ( echo 'prefix=$(INSTALLTOP)'; \
689 echo 'exec_prefix=$${prefix}'; \
690 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
691 echo 'includedir=$${prefix}/include'; \
693 echo 'Name: OpenSSL-libssl'; \
694 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
695 echo 'Version: '$(VERSION); \
696 echo 'Requires.private: libcrypto'; \
697 echo 'Libs: -L$${libdir} -lssl'; \
698 echo 'Libs.private: $(EX_LIBS)'; \
699 echo 'Cflags: -I$${includedir}' ) > libssl.pc
702 @ ( echo 'prefix=$(INSTALLTOP)'; \
703 echo 'exec_prefix=$${prefix}'; \
704 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
705 echo 'includedir=$${prefix}/include'; \
707 echo 'Name: OpenSSL'; \
708 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
709 echo 'Version: '$(VERSION); \
710 echo 'Requires: libssl libcrypto' ) > openssl.pc
712 # Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which
713 # wasn't passed down automatically. It's quite safe to use it like we do
714 # below; if it doesn't exist, the result will be empty and 'make' will pick
715 # up $(MAKEFLAGS) which is passed down as an environment variable.
716 configdata.pm: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/config
717 @echo "Detected changed: $?"
718 @echo "Reconfiguring..."
719 $(SRCDIR)/Configure reconf
720 @echo "**************************************************"
722 @echo "*** Please run the same make command again ***"
724 @echo "**************************************************"
729 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
731 # Helper function to figure out dependencies on libraries
732 # It takes a list of library names and outputs a list of dependencies
733 sub compute_lib_depends {
734 if ($config{no_shared}) {
735 return map { $_."\$(LIB_EXT)" } @_;
738 # Depending on shared libraries:
739 # On Windows POSIX layers, we depend on {libname}.dll.a
740 # On Unix platforms, we depend on {shlibname}.so
741 return map { if (windowsdll()) {
742 "$_\$(SHLIB_EXT_SIMPLE).a"
745 $unified_info{sharednames}->{$_} || $_;
746 "$libname\$(SHLIB_EXT_SIMPLE)"
752 my $obj = $args{obj};
753 my $srcs = join(" ", @{$args{srcs}});
754 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
755 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
756 my $makedepprog = $config{makedepprog};
757 if ($makedepprog eq "makedepend") {
759 $obj\$(DEP_EXT): $deps
760 rm -f \$\@.tmp; touch \$\@.tmp
761 \$(MAKEDEPEND) -f\$\@.tmp -o"|$obj" -- \$(CFLAGS)$incs -- $srcs \\
763 sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$\$/d' -e '/^\\(#.*\\| *\\)\$\$/d' \$\@.tmp > \$\@
765 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
766 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
770 $obj\$(DEP_EXT): $deps
771 \$(CC) \$(CFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
772 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
773 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
776 # On Unix, we build shlibs from static libs, so we're ignoring the
777 # object file array. We *know* this routine is only called when we've
778 # configure 'shared'.
781 my $lib = $args{lib};
782 my $shlib = $args{shlib};
783 my $libd = dirname($lib);
784 my $libn = basename($lib);
785 (my $libname = $libn) =~ s/^lib//;
786 my $linklibs = join("", map { my $d = dirname($_);
787 my $f = basename($_);
788 (my $l = $f) =~ s/^lib//;
789 " -L$d -l$l" } @{$args{deps}});
790 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
791 my $shlib_target = $target{shared_target};
792 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
793 my $shlibtarget = windowsdll() ?
794 "$lib\$(SHLIB_EXT_SIMPLE).a" : "$shlib\$(SHLIB_EXT_SIMPLE)";
796 # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
797 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
798 # With all other Unix platforms, we often build a shared library with the
799 # SO version built into the file name and a symlink without the SO version
800 # It's not necessary to have both as targets. The choice falls on the
801 # simplest, {libname}\$(SHLIB_EXT_SIMPLE).a for Windows POSIX layers and
802 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
803 $shlibtarget: $lib\$(LIB_EXT) $deps $ordinalsfile
804 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
805 PLATFORM=\$(PLATFORM) \\
806 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
807 INSTALLTOP="\$(INSTALLTOP)" LIBDIR="\$(LIBDIR)" \\
808 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
809 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
810 LIBCOMPATVERSIONS=";\$(SHLIB_VERSION_HISTORY)" \\
811 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
812 CROSS_COMPILE="\$(CROSS_COMPILE)" \\
813 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
814 SHARED_RCFLAGS="\$(SHARED_RCFLAGS)" \\
817 . (windowsdll() ? <<"EOF" : "");
818 rm -f apps/$shlib\$(SHLIB_EXT)
819 rm -f test/$shlib\$(SHLIB_EXT)
820 cp -p $shlib\$(SHLIB_EXT) apps/
821 cp -p $shlib\$(SHLIB_EXT) test/
826 my $lib = $args{lib};
827 my $libd = dirname($lib);
828 my $libn = basename($lib);
829 (my $libname = $libn) =~ s/^lib//;
830 my $shlibdeps = join("", map { my $d = dirname($_);
831 my $f = basename($_);
832 (my $l = $f) =~ s/^lib//;
833 " -L$d -l$l" } @{$args{deps}});
834 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
835 my $shlib_target = $target{shared_target};
836 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
838 $lib\$(SHLIB_EXT_SIMPLE): $objs $deps
839 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
840 PLATFORM=\$(PLATFORM) \\
841 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
842 LIBDEPS="\$(PLIB_LDFLAGS) $shlibdeps \$(EX_LIBS)" \\
843 LIBNAME=$libname LDFLAGS="\$(LDFLAGS)" \\
844 CC="\$(CC)" CFLAGS="\$(CFLAGS)" \\
845 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" \\
846 SHLIB_EXT=\$(SHLIB_EXT_SIMPLE) \\
853 my $lib = $args{lib};
854 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
856 $lib\$(LIB_EXT): $objs
858 \$(RANLIB) \$\@ || echo Never mind.
863 my $bin = $args{bin};
864 my $bind = dirname($bin);
865 my $binn = basename($bin);
866 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
867 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
868 my $linklibs = join("", map { my $d = dirname($_);
869 my $f = basename($_);
870 $d = "." if $d eq $f;
871 (my $l = $f) =~ s/^lib//;
872 " -L$d -l$l" } @{$args{deps}});
873 my $shlib_target = $config{no_shared} ? "" : $target{shared_target};
875 $bin\$(EXE_EXT): $objs $deps
876 \$(RM) $bin\$(EXE_EXT)
877 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
878 PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
879 APPNAME=$bin OBJECTS="$objs" \\
880 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
881 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
882 LIBRPATH="\$(INSTALLTOP)/\$(LIBDIR)" \\
883 link_app.$shlib_target
888 my $script = $args{script};
889 my $sources = join(" ", @{$args{sources}});
890 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
891 "util", "dofile.pl")),
892 rel2abs($config{builddir}));
895 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
896 "-o$target{build_file}" $sources > "$script"
900 "" # Important! This becomes part of the template result.