2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
8 PLATFORM={- $config{target} -}
9 OPTIONS={- $config{options} -}
10 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
11 SRCDIR={- $config{sourcedir} -}
12 BLDDIR={- $config{builddir} -}
14 VERSION={- $config{version} -}
15 MAJOR={- $config{major} -}
16 MINOR={- $config{minor} -}
17 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
18 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
19 SHLIB_MAJOR={- $config{shlib_major} -}
20 SHLIB_MINOR={- $config{shlib_minor} -}
21 SHLIB_TARGET={- $target{shared_target} -}
23 EXE_EXT={- $target{exe_extension} || "" -}
24 LIB_EXT={- $target{lib_extension} || ".a" -}
25 SHLIB_EXT={- $target{shared_extension} || ".so" -}
26 SHLIB_EXT_SIMPLE={- $target{shared_extension_simple} || ".so" -}
27 SHLIB_EXT_IMPORT={- $target{shared_import_extension} || "" -}
28 DSO_EXT={- $target{dso_extension} || ".so" -}
29 OBJ_EXT={- $target{obj_extension} || ".o" -}
30 DEP_EXT={- $target{dep_extension} || ".d" -}
32 LIBS={- join(" ", map { $_."\$(LIB_EXT)" } @{$unified_info{libraries}}) -}
33 SHLIBS={- join(" ", map { $_."\$(SHLIB_EXT)" } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}}) -}
34 ENGINES={- join(" ", map { $_."\$(DSO_EXT)" } @{$unified_info{engines}}) -}
35 PROGRAMS={- join(" ", map { $_."\$(EXE_EXT)" } grep { !m|^test/| } @{$unified_info{programs}}) -}
36 TESTPROGS={- join(" ", map { $_."\$(EXE_EXT)" } grep { m|^test/| } @{$unified_info{programs}}) -}
37 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
38 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
39 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
40 keys %{$unified_info{sources}}); -}
42 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
43 MISC_SCRIPTS=$(SRCDIR)/tools/c_hash $(SRCDIR)/tools/c_info \
44 $(SRCDIR)/tools/c_issuer $(SRCDIR)/tools/c_name \
45 $(BLDDIR)/apps/CA.pl $(SRCDIR)/apps/tsget
47 # DESTDIR is for package builders so that they can configure for, say,
48 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
49 # Normally it is left empty.
52 # Do not edit these manually. Use Configure with --prefix or --openssldir
53 # to change this! Short explanation in the top comment in Configure
54 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
56 our $prefix = $config{prefix} || "/usr/local";
59 # The logic here is that if no --openssldir was given,
60 # OPENSSLDIR will get the value from $prefix plus "/ssl".
61 # If --openssldir was given and the value is an absolute
62 # path, OPENSSLDIR will get its value without change.
63 # If the value from --openssldir is a relative path,
64 # OPENSSLDIR will get $prefix with the --openssldir
65 # value appended as a subdirectory.
67 use File::Spec::Functions;
70 (file_name_is_absolute($config{openssldir}) ?
72 : catdir($prefix, $config{openssldir}))
73 : catdir($prefix, "ssl");
76 # if $prefix/lib$target{multilib} is not an existing
77 # directory, then assume that it's not searched by linker
78 # automatically, in which case adding $target{multilib} suffix
79 # causes more grief than we're ready to tolerate, so don't...
81 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
82 our $libdir = $config{libdir} || "lib$multilib";
84 ENGINESDIR={- use File::Spec::Functions;
85 catdir($prefix,$libdir,"engines") -}
87 MANDIR=$(INSTALLTOP)/share/man
88 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
89 HTMLDIR=$(DOCDIR)/html
91 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
92 # appended after the manpage file section number. "ssl" is popular,
93 # resulting in files such as config.5ssl rather than config.5.
99 CROSS_COMPILE= {- $config{cross_compile_prefix} -}
100 CC= $(CROSS_COMPILE){- $target{cc} -}
101 CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $config{cflags} -}
102 CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
103 LDFLAGS= {- $config{lflags} -}
104 PLIB_LDFLAGS= {- $config{plib_lflags} -}
105 EX_LIBS= {- $config{ex_libs} -}
106 SHARED_LDFLAGS={- $target{shared_ldflag}
107 # Unlike other OSes (like Solaris, Linux, Tru64,
108 # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
109 # and FreeBSD) "demand" RPATH set on .so objects.
110 # Apparently application RPATH is not global and
111 # does not apply to .so linked with other .so.
112 # Problem manifests itself when libssl.so fails to
113 # load libcrypto.so. One can argue that we should
114 # engrave this into Makefile.shared rules or into
115 # BSD-* config lines above. Meanwhile let's try to
116 # be cautious and pass -rpath to linker only when
117 # $prefix is not /usr.
118 . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
119 ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
120 SHARED_RCFLAGS={- $target{shared_rcflag} -}
122 PERL={- $config{perl} -}
124 ARFLAGS= {- $target{arflags} -}
125 AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
126 RANLIB= {- $target{ranlib} -}
127 NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
129 TAR= {- $target{tar} || "tar" -}
130 TARFLAGS= {- $target{tarflags} -}
131 MAKEDEPEND=$(CROSS_COMPILE){- $config{makedepprog} -}
134 NAME= $(BASENAME)-$(VERSION)
135 TARFILE= ../$(NAME).tar
137 # We let the C compiler driver to take care of .s files. This is done in
138 # order to be excused from maintaining a separate set of architecture
139 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
140 # gcc, then the driver will automatically translate it to -xarch=v8plus
141 # and pass it down to assembler.
144 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
146 # For x86 assembler: Set PROCESSOR to 386 if you want to support
148 PROCESSOR= {- $config{processor} -}
150 # The main targets ###################################################
152 all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep \
155 build_libs: configdata.pm build_libs_nodep depend
156 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
157 build_engines: configdata.pm build_engines_nodep depend
158 build_engines_nodep: $(ENGINES)
159 build_apps: configdata.pm build_apps_nodep depend
160 build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
161 build_tests: configdata.pm build_tests_nodep depend
162 build_tests_nodep: $(TESTPROGS)
164 test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend rehash
166 SRCTOP=../$(SRCDIR) \
167 BLDTOP=../$(BLDDIR) \
169 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
172 @TOP=$(SRCDIR) PERL=$(PERL) $(PERL) $(SRCDIR)/test/run_tests.pl list
175 -rm -f `find $(BLDDIR) -name '*$(LIB_EXT)' -o -name '*$(SHLIB_EXT)'`
177 install: install_sw install_ssldirs install_docs
179 uninstall: uninstall_docs uninstall_sw
182 rm -f $(PROGRAMS) $(TESTPROGS)
183 rm -f `find $(BLDDIR) -name '*$(DEP_EXT)'`
184 rm -f `find $(BLDDIR) -name '*$(OBJ_EXT)'`
185 rm -f $(BLDDIR)/core $(BLDDIR)/rehash.time
186 rm -f $(BLDDIR)/tags $(BLDDIR)/TAGS
187 rm -f $(BLDDIR)/openssl.pc $(BLDDIR)/libcrypto.pc $(BLDDIR)/libssl.pc
188 -rm -f `find $(BLDDIR) -type l`
191 # This exists solely for those who still type 'make depend'
194 @( sed -e '/^# DO NOT DELETE THIS LINE.*/,$$d' < Makefile; \
195 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
197 for d in $(DEPS); do \
198 if [ -f $$d ]; then cat $$d; fi; \
199 done ) > Makefile.new
200 @if ! cmp Makefile.new Makefile >/dev/null 2>&1; then \
201 mv -f Makefile.new Makefile; \
204 # Install helper targets #############################################
206 install_sw: all install_dev install_engines install_runtime
208 uninstall_sw: uninstall_dev uninstall_engines uninstall_runtime
210 install_docs: install_man_docs install_html_docs
212 uninstall_docs: uninstall_man_docs uninstall_html_docs
213 $(RM) -r -v $(DESTDIR)$(DOCDIR)
216 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
217 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
220 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
221 @echo "*** Installing development files"
222 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
223 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
224 $(BLDDIR)/include/openssl/*.h; do \
226 echo "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
227 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
228 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
230 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
231 @set -e; for l in $(LIBS); do \
233 echo "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
234 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
235 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
236 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
237 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
238 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
240 @ : {- output_off() if $config{no_shared}; "" -}
241 @set -e; for s in $(SHLIBS); do \
243 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
244 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
245 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
246 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
247 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
248 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
249 echo "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
250 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
251 ln -sf $$fn $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
253 : {- output_off() unless windowsdll(); "" -}; \
254 echo "install $$s.a -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
255 cp $$s.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
256 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
257 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \
258 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
259 : {- output_on() unless windowsdll(); "" -}; \
261 @ : {- output_on() if $config{no_shared}; "" -}
262 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
263 @echo "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
264 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
265 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
266 @echo "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
267 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
268 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
269 @echo "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
270 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
271 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
274 @echo "*** Uninstalling development files"
275 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
276 $(BLDDIR)/include/openssl/*.h; do \
278 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
279 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
281 @set -e; for l in $(LIBS); do \
283 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
284 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
286 @set -e; for s in $(SHLIBS); do \
288 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
289 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
290 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
291 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
293 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
294 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
295 : {- output_off() unless windowsdll(); "" -}; \
296 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
297 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
298 : {- output_on() unless windowsdll(); "" -}; \
300 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
301 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
302 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
303 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
304 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
305 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
308 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
309 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/
310 @echo "*** Installing engines"
311 @set -e; for e in $(ENGINES); do \
313 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
316 echo "install $$e -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn"; \
317 cp $$e $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
318 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
319 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \
320 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
324 @echo "*** Uninstalling engines"
325 @set -e; for e in $(ENGINES); do \
327 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
330 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn"; \
331 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
335 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
336 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
337 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
338 @echo "*** Installing runtime files"
339 : {- output_off() unless windowsdll(); "" -};
340 @set -e; for s in $(SHLIBS); do \
342 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
343 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
344 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
345 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
346 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
348 : {- output_on() unless windowsdll(); "" -};
349 @set -e; for x in $(PROGRAMS); do \
351 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
352 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
353 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
354 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
355 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
357 @set -e; for x in $(BIN_SCRIPTS); do \
359 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
360 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
361 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
362 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
363 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
365 @set -e; for x in $(MISC_SCRIPTS); do \
367 echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
368 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
369 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
370 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
371 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
373 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"
374 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
375 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
376 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
379 @echo "*** Uninstalling runtime files"
380 @set -e; for x in $(PROGRAMS); \
383 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
384 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
386 @set -e; for x in $(BIN_SCRIPTS); \
389 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
390 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
392 @set -e; for x in $(MISC_SCRIPTS); \
395 echo "$(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
396 $(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
398 : {- output_off() unless windowsdll(); "" -};
399 @set -e; for s in $(SHLIBS); do \
401 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
402 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
404 : {- output_on() unless windowsdll(); "" -};
405 $(RM) $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
407 # A method to extract all names from a .pod file
408 # The first sed extracts everything between "=head1 NAME" and the next =head1
409 # The second sed joins all the lines into one
410 # The third sed removes the description and turns all commas into spaces
411 # Voilà , you have a space separated list of names!
412 EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
413 sed -e ':a;{N;s/\n/ /;ba}' | \
414 sed -e 's/ - .*$$//;s/,/ /g'
417 here=`cd $(SRCDIR); pwd`; \
418 point=$$here/util/point.sh; \
419 for ds in apps:1 crypto:3 ssl:3; do \
420 defdir=`echo $$ds | cut -f1 -d:`; \
421 defsec=`echo $$ds | cut -f2 -d:`; \
422 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
423 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
424 [ -z "$$SEC" ] && SEC=$$defsec; \
425 fn=`basename $$p .pod`; \
426 NAME=`echo $$fn | tr [a-z] [A-Z]`; \
427 suf=`eval "echo $$OUTSUFFIX"`; \
428 top=`eval "echo $$OUTTOP"`; \
429 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
430 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
431 cat $$p | eval "$$GENERATE" \
432 > $$top/man$$SEC/$$fn$$suf; \
433 names=`cat $$p | $(EXTRACT_NAMES)`; \
434 ( cd $$top/man$$SEC; \
435 for n in $$names; do \
438 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
439 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
440 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
443 if [ "$$comp_n" != "$$comp_fn" ]; then \
444 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
445 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
452 here=`cd $(SRCDIR); pwd`; \
453 for ds in apps:1 crypto:3 ssl:3; do \
454 defdir=`echo $$ds | cut -f1 -d:`; \
455 defsec=`echo $$ds | cut -f2 -d:`; \
456 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
457 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
458 [ -z "$$SEC" ] && SEC=$$defsec; \
459 fn=`basename $$p .pod`; \
460 suf=`eval "echo $$OUTSUFFIX"`; \
461 top=`eval "echo $$OUTTOP"`; \
462 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
463 $(RM) $$top/man$$SEC/$$fn$$suf; \
464 names=`cat $$p | $(EXTRACT_NAMES)`; \
465 for n in $$names; do \
468 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
469 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
470 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
473 if [ "$$comp_n" != "$$comp_fn" ]; then \
474 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
475 $(RM) $$top/man$$SEC/$$n$$suf; \
478 ( $(RMDIR) $$top/man$$SEC 2>/dev/null || exit 0 ); \
483 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
484 @echo "*** Installing manpages"
486 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
487 OUTTOP="$(DESTDIR)$(MANDIR)"; \
488 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
492 @echo "*** Uninstalling manpages"
494 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
495 OUTTOP="$(DESTDIR)$(MANDIR)"; \
499 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
500 @echo "*** Installing HTML manpages"
502 OUTSUFFIX='.$(HTMLSUFFIX)'; \
503 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
504 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
505 --podpath=apps:crypto:ssl \
506 | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \
510 @echo "*** Uninstalling manpages"
512 OUTSUFFIX='.$(HTMLSUFFIX)'; \
513 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
517 # Developer targets (note: these are only available on Unix) #########
519 update: generate errors ordinals
521 generate: generate_apps generate_crypto_bn generate_crypto_objects
523 # Test coverage is a good idea for the future
524 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
527 # Currently disabled, util/selftest.pl needs a rewrite
529 # SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl
532 lint -DLINT $(INCLUDES) $(SRCS)
534 generate_apps: $(SRCDIR)/apps/openssl-vms.cnf $(SRCDIR)/apps/progs.h
536 generate_crypto_bn: $(SRCDIR)/crypto/bn/bn_prime.h
538 generate_crypto_objects: $(SRCDIR)/crypto/objects/obj_dat.h \
539 $(SRCDIR)/include/openssl/obj_mac.h \
540 $(SRCDIR)/crypto/objects/obj_xref.h
543 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
544 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
545 ( cd $(SRCDIR)/engines; \
547 $(PERL) ../util/mkerr.pl -conf $$e \
548 -nostatic -staticloader -write *.c; \
550 ( cd $(SRCDIR)/crypto/ct; \
551 $(PERL) ../../util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c )
554 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
555 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
559 SRCTOP=../$(SRCDIR) \
560 BLDTOP=../$(BLDDIR) \
561 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
566 -etags `find . -name '*.[ch]' -o -name '*.pm'`
568 # Release targets (note: only available on Unix) #####################
571 TMPDIR=/var/tmp/openssl-copy.$$$$; \
572 DISTDIR=openssl-$(VERSION); \
573 mkdir -p $$TMPDIR/$$DISTDIR; \
575 git ls-tree -r --name-only --full-tree HEAD \
577 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
578 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
581 [ -n "$(PREPARE_CMD)" ] && $(PREPARE_CMD); \
582 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
583 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
584 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
585 $(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - $$DISTDIR) \
586 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
588 cd $(SRCDIR); ls -l $(TARFILE).gz
591 @$(MAKE) PREPARE_CMD='./Configure dist' tar
593 # Helper targets #####################################################
595 rehash: link-utils copy-certs build_apps_nodep
596 @if [ -z "$(CROSS_COMPILE)" ]; then \
597 (OPENSSL="$(BLDDIR)/util/shlib_wrap.sh apps/openssl"; \
598 [ -x "$(BLDDIR)/openssl.exe" ] && OPENSSL="$(BLDDIR)/openssl.exe" || :; \
599 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
600 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
601 $$OPENSSL rehash certs/demo \
602 || $(PERL) tools/c_rehash certs/demo) && \
606 link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
608 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
609 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
610 mkdir -p "$(BLDDIR)/util"; \
611 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
613 $(BLDDIR)/util/shlib_wrap.sh: configdata.pm
614 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
615 mkdir -p "$(BLDDIR)/util"; \
616 ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
620 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
621 cp -R "$(SRCDIR)/certs" "$(BLDDIR)/"; \
624 $(SRCDIR)/apps/openssl-vms.cnf: $(SRCDIR)/apps/openssl.cnf
625 $(PERL) $(SRCDIR)/VMS/VMSify-conf.pl \
626 < $(SRCDIR)/apps/openssl.cnf > $(SRCDIR)/apps/openssl-vms.cnf
628 {- # because the program apps/openssl has object files as sources, and
629 # they then have the corresponding C files as source, we need to chain
630 # the lookups in %unified_info
631 my $apps_openssl = catfile("apps","openssl");
632 our @openssl_source = map { @{$unified_info{sources}->{$_}} }
633 @{$unified_info{sources}->{$apps_openssl}};
635 $(SRCDIR)/apps/progs.h:
637 $(PERL) $(SRCDIR)/apps/progs.pl {- join(" ", @openssl_source) -} > $@
639 $(SRCDIR)/crypto/bn/bn_prime.h: $(SRCDIR)/crypto/bn/bn_prime.pl
640 $(PERL) $(SRCDIR)/crypto/bn/bn_prime.pl > $(SRCDIR)/crypto/bn/bn_prime.h
642 $(SRCDIR)/crypto/objects/obj_dat.h: $(SRCDIR)/crypto/objects/obj_dat.pl \
643 $(SRCDIR)/include/openssl/obj_mac.h
644 $(PERL) $(SRCDIR)/crypto/objects/obj_dat.pl \
645 $(SRCDIR)/include/openssl/obj_mac.h \
646 $(SRCDIR)/crypto/objects/obj_dat.h
648 # objects.pl both reads and writes obj_mac.num
649 $(SRCDIR)/include/openssl/obj_mac.h: $(SRCDIR)/crypto/objects/objects.pl \
650 $(SRCDIR)/crypto/objects/objects.txt \
651 $(SRCDIR)/crypto/objects/obj_mac.num
652 $(PERL) $(SRCDIR)/crypto/objects/objects.pl \
653 $(SRCDIR)/crypto/objects/objects.txt \
654 $(SRCDIR)/crypto/objects/obj_mac.num \
655 $(SRCDIR)/include/openssl/obj_mac.h
656 @sleep 1; touch $(SRCDIR)/include/openssl/obj_mac.h; sleep 1
658 $(SRCDIR)/crypto/objects/obj_xref.h: $(SRCDIR)/crypto/objects/objxref.pl \
659 $(SRCDIR)/crypto/objects/obj_xref.txt \
660 $(SRCDIR)/crypto/objects/obj_mac.num
661 $(PERL) $(SRCDIR)/crypto/objects/objxref.pl \
662 $(SRCDIR)/crypto/objects/obj_mac.num \
663 $(SRCDIR)/crypto/objects/obj_xref.txt \
664 > $(SRCDIR)/crypto/objects/obj_xref.h
665 @sleep 1; touch $(SRCDIR)/crypto/objects/obj_xref.h; sleep 1
669 # Building targets ###################################################
671 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS)
673 @ ( echo 'prefix=$(INSTALLTOP)'; \
674 echo 'exec_prefix=$${prefix}'; \
675 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
676 echo 'includedir=$${prefix}/include'; \
678 echo 'Name: OpenSSL-libcrypto'; \
679 echo 'Description: OpenSSL cryptography library'; \
680 echo 'Version: '$(VERSION); \
681 echo 'Libs: -L$${libdir} -lcrypto'; \
682 echo 'Libs.private: $(EX_LIBS)'; \
683 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
686 @ ( echo 'prefix=$(INSTALLTOP)'; \
687 echo 'exec_prefix=$${prefix}'; \
688 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
689 echo 'includedir=$${prefix}/include'; \
691 echo 'Name: OpenSSL-libssl'; \
692 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
693 echo 'Version: '$(VERSION); \
694 echo 'Requires.private: libcrypto'; \
695 echo 'Libs: -L$${libdir} -lssl'; \
696 echo 'Libs.private: $(EX_LIBS)'; \
697 echo 'Cflags: -I$${includedir}' ) > libssl.pc
700 @ ( echo 'prefix=$(INSTALLTOP)'; \
701 echo 'exec_prefix=$${prefix}'; \
702 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
703 echo 'includedir=$${prefix}/include'; \
705 echo 'Name: OpenSSL'; \
706 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
707 echo 'Version: '$(VERSION); \
708 echo 'Requires: libssl libcrypto' ) > openssl.pc
710 # Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which
711 # wasn't passed down automatically. It's quite safe to use it like we do
712 # below; if it doesn't exist, the result will be empty and 'make' will pick
713 # up $(MAKEFLAGS) which is passed down as an environment variable.
714 configdata.pm: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/config
715 @echo "Detected changed: $?"
716 @echo "Reconfiguring..."
717 $(SRCDIR)/Configure reconf
718 @echo "**************************************************"
720 @echo "*** Please run the same make command again ***"
722 @echo "**************************************************"
727 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
729 # Helper function to figure out dependencies on libraries
730 # It takes a list of library names and outputs a list of dependencies
731 sub compute_lib_depends {
732 if ($config{no_shared}) {
733 return map { $_."\$(LIB_EXT)" } @_;
736 # Depending on shared libraries:
737 # On Windows POSIX layers, we depend on {libname}.dll.a
738 # On Unix platforms, we depend on {shlibname}.so
739 return map { if (windowsdll()) {
740 "$_\$(SHLIB_EXT_IMPORT)"
743 $unified_info{sharednames}->{$_} || $_;
744 "$libname\$(SHLIB_EXT_SIMPLE)"
750 my $obj = $args{obj};
751 my $srcs = join(" ", @{$args{srcs}});
752 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
753 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
754 my $makedepprog = $config{makedepprog};
755 if ($makedepprog eq "makedepend") {
757 $obj\$(DEP_EXT): $deps
758 rm -f \$\@.tmp; touch \$\@.tmp
759 \$(MAKEDEPEND) -f\$\@.tmp -o"|$obj" -- \$(CFLAGS)$incs -- $srcs \\
761 sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$\$/d' -e '/^\\(#.*\\| *\\)\$\$/d' \$\@.tmp > \$\@
763 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
764 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
768 $obj\$(DEP_EXT): $deps
769 \$(CC) \$(CFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
770 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
771 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
774 # On Unix, we build shlibs from static libs, so we're ignoring the
775 # object file array. We *know* this routine is only called when we've
776 # configure 'shared'.
779 my $lib = $args{lib};
780 my $shlib = $args{shlib};
781 my $libd = dirname($lib);
782 my $libn = basename($lib);
783 (my $libname = $libn) =~ s/^lib//;
784 my $linklibs = join("", map { my $d = dirname($_);
785 my $f = basename($_);
786 (my $l = $f) =~ s/^lib//;
787 " -L$d -l$l" } @{$args{deps}});
788 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
789 my $shlib_target = $target{shared_target};
790 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
791 my $shlibtarget = windowsdll() ?
792 "$lib\$(SHLIB_EXT_IMPORT)" : "$shlib\$(SHLIB_EXT_SIMPLE)";
794 # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
795 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
796 # With all other Unix platforms, we often build a shared library with the
797 # SO version built into the file name and a symlink without the SO version
798 # It's not necessary to have both as targets. The choice falls on the
799 # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
800 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
801 $shlibtarget: $lib\$(LIB_EXT) $deps $ordinalsfile
802 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
803 PLATFORM=\$(PLATFORM) \\
804 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
805 INSTALLTOP="\$(INSTALLTOP)" LIBDIR="\$(LIBDIR)" \\
806 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
807 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
808 LIBCOMPATVERSIONS=";\$(SHLIB_VERSION_HISTORY)" \\
809 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
810 CROSS_COMPILE="\$(CROSS_COMPILE)" \\
811 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
812 SHARED_RCFLAGS="\$(SHARED_RCFLAGS)" \\
815 . (windowsdll() ? <<"EOF" : "");
816 rm -f apps/$shlib\$(SHLIB_EXT)
817 rm -f test/$shlib\$(SHLIB_EXT)
818 cp -p $shlib\$(SHLIB_EXT) apps/
819 cp -p $shlib\$(SHLIB_EXT) test/
824 my $lib = $args{lib};
825 my $libd = dirname($lib);
826 my $libn = basename($lib);
827 (my $libname = $libn) =~ s/^lib//;
828 my $shlibdeps = join("", map { my $d = dirname($_);
829 my $f = basename($_);
830 (my $l = $f) =~ s/^lib//;
831 " -L$d -l$l" } @{$args{deps}});
832 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
833 my $shlib_target = $target{shared_target};
834 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
836 $lib\$(DSO_EXT): $objs $deps
837 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
838 PLATFORM=\$(PLATFORM) \\
839 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
840 LIBDEPS="\$(PLIB_LDFLAGS) $shlibdeps \$(EX_LIBS)" \\
841 LIBNAME=$libname LDFLAGS="\$(LDFLAGS)" \\
842 CC="\$(CC)" CFLAGS="\$(CFLAGS)" \\
843 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" \\
844 SHLIB_EXT=\$(DSO_EXT) \\
851 my $lib = $args{lib};
852 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
854 $lib\$(LIB_EXT): $objs
856 \$(RANLIB) \$\@ || echo Never mind.
861 my $bin = $args{bin};
862 my $bind = dirname($bin);
863 my $binn = basename($bin);
864 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
865 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
866 my $linklibs = join("", map { my $d = dirname($_);
867 my $f = basename($_);
868 $d = "." if $d eq $f;
869 (my $l = $f) =~ s/^lib//;
870 " -L$d -l$l" } @{$args{deps}});
871 my $shlib_target = $config{no_shared} ? "" : $target{shared_target};
873 $bin\$(EXE_EXT): $objs $deps
874 \$(RM) $bin\$(EXE_EXT)
875 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
876 PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
877 APPNAME=$bin OBJECTS="$objs" \\
878 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
879 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
880 LIBRPATH="\$(INSTALLTOP)/\$(LIBDIR)" \\
881 link_app.$shlib_target
886 my $script = $args{script};
887 my $sources = join(" ", @{$args{sources}});
888 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
889 "util", "dofile.pl")),
890 rel2abs($config{builddir}));
893 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
894 "-o$target{build_file}" $sources > "$script"
898 "" # Important! This becomes part of the template result.