2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
8 # shlib and shlib_simple both take a static library name and figure
9 # out what the shlib name should be.
11 # When OpenSSL is configured "no-shared", these functions will just
12 # return empty lists, making them suitable to join().
14 # With Windows DLL producers, shlib($libname) will return the shared
15 # library name (which usually is different from the static library
16 # name) with the default shared extension appended to it, while
17 # shlib_simple($libname) will return the static library name with
18 # the shared extension followed by ".a" appended to it. The former
19 # result is used as the runtime shared library while the latter is
20 # used as the DLL import library.
22 # On all Unix systems, shlib($libname) will return the library name
23 # with the default shared extension, while shlib_simple($libname)
24 # will return the name from shlib($libname) with any SO version number
25 # removed. On some systems, they may therefore return the exact same
28 return () if $config{no_shared};
30 return $unified_info{sharednames}->{$lib} . '$(SHLIB_EXT)';
33 return () if $config{no_shared};
37 return $lib . '$(SHLIB_EXT_IMPORT)';
39 return $lib . '$(SHLIB_EXT_SIMPLE)';
42 # dso is a complement to shlib / shlib_simple that returns the
43 # given libname with the simple shared extension (possible SO version
44 # removed). This differs from shlib_simple() by being unconditional.
46 return () if $config{no_shared};
49 return $engine . '$(DSO_EXT)';
52 PLATFORM={- $config{target} -}
53 OPTIONS={- $config{options} -}
54 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
55 SRCDIR={- $config{sourcedir} -}
56 BLDDIR={- $config{builddir} -}
58 VERSION={- $config{version} -}
59 MAJOR={- $config{major} -}
60 MINOR={- $config{minor} -}
61 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
62 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
63 SHLIB_MAJOR={- $config{shlib_major} -}
64 SHLIB_MINOR={- $config{shlib_minor} -}
65 SHLIB_TARGET={- $target{shared_target} -}
67 EXE_EXT={- $target{exe_extension} || "" -}
68 LIB_EXT={- $target{lib_extension} || ".a" -}
69 SHLIB_EXT={- $target{shared_extension} || ".so" -}
70 SHLIB_EXT_SIMPLE={- $target{shared_extension_simple} || ".so" -}
71 SHLIB_EXT_IMPORT={- $target{shared_import_extension} || "" -}
72 DSO_EXT={- $target{dso_extension} || ".so" -}
73 OBJ_EXT={- $target{obj_extension} || ".o" -}
74 DEP_EXT={- $target{dep_extension} || ".d" -}
76 LIBS={- join(" ", map { $_."\$(LIB_EXT)" } @{$unified_info{libraries}}) -}
77 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
78 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
79 PROGRAMS={- join(" ", map { $_."\$(EXE_EXT)" } grep { !m|^test/| } @{$unified_info{programs}}) -}
80 TESTPROGS={- join(" ", map { $_."\$(EXE_EXT)" } grep { m|^test/| } @{$unified_info{programs}}) -}
81 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
82 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
83 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
84 keys %{$unified_info{sources}}); -}
86 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
87 MISC_SCRIPTS=$(SRCDIR)/tools/c_hash $(SRCDIR)/tools/c_info \
88 $(SRCDIR)/tools/c_issuer $(SRCDIR)/tools/c_name \
89 $(BLDDIR)/apps/CA.pl $(SRCDIR)/apps/tsget
91 # DESTDIR is for package builders so that they can configure for, say,
92 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
93 # Normally it is left empty.
96 # Do not edit these manually. Use Configure with --prefix or --openssldir
97 # to change this! Short explanation in the top comment in Configure
98 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
100 our $prefix = $config{prefix} || "/usr/local";
103 # The logic here is that if no --openssldir was given,
104 # OPENSSLDIR will get the value from $prefix plus "/ssl".
105 # If --openssldir was given and the value is an absolute
106 # path, OPENSSLDIR will get its value without change.
107 # If the value from --openssldir is a relative path,
108 # OPENSSLDIR will get $prefix with the --openssldir
109 # value appended as a subdirectory.
111 use File::Spec::Functions;
113 $config{openssldir} ?
114 (file_name_is_absolute($config{openssldir}) ?
116 : catdir($prefix, $config{openssldir}))
117 : catdir($prefix, "ssl");
120 # if $prefix/lib$target{multilib} is not an existing
121 # directory, then assume that it's not searched by linker
122 # automatically, in which case adding $target{multilib} suffix
123 # causes more grief than we're ready to tolerate, so don't...
125 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
126 our $libdir = $config{libdir} || "lib$multilib";
128 ENGINESDIR={- use File::Spec::Functions;
129 catdir($prefix,$libdir,"engines") -}
131 MANDIR=$(INSTALLTOP)/share/man
132 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
133 HTMLDIR=$(DOCDIR)/html
135 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
136 # appended after the manpage file section number. "ssl" is popular,
137 # resulting in files such as config.5ssl rather than config.5.
143 CROSS_COMPILE= {- $config{cross_compile_prefix} -}
144 CC= $(CROSS_COMPILE){- $target{cc} -}
145 CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $config{cflags} -}
146 CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
147 LDFLAGS= {- $config{lflags} -}
148 PLIB_LDFLAGS= {- $config{plib_lflags} -}
149 EX_LIBS= {- $config{ex_libs} -}
150 SHARED_LDFLAGS={- $target{shared_ldflag}
151 # Unlike other OSes (like Solaris, Linux, Tru64,
152 # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
153 # and FreeBSD) "demand" RPATH set on .so objects.
154 # Apparently application RPATH is not global and
155 # does not apply to .so linked with other .so.
156 # Problem manifests itself when libssl.so fails to
157 # load libcrypto.so. One can argue that we should
158 # engrave this into Makefile.shared rules or into
159 # BSD-* config lines above. Meanwhile let's try to
160 # be cautious and pass -rpath to linker only when
161 # $prefix is not /usr.
162 . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
163 ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
164 SHARED_RCFLAGS={- $target{shared_rcflag} -}
166 PERL={- $config{perl} -}
168 ARFLAGS= {- $target{arflags} -}
169 AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
170 RANLIB= {- $target{ranlib} -}
171 NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
173 TAR= {- $target{tar} || "tar" -}
174 TARFLAGS= {- $target{tarflags} -}
175 MAKEDEPEND=$(CROSS_COMPILE){- $config{makedepprog} -}
178 NAME= $(BASENAME)-$(VERSION)
179 TARFILE= ../$(NAME).tar
181 # We let the C compiler driver to take care of .s files. This is done in
182 # order to be excused from maintaining a separate set of architecture
183 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
184 # gcc, then the driver will automatically translate it to -xarch=v8plus
185 # and pass it down to assembler.
188 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
190 # For x86 assembler: Set PROCESSOR to 386 if you want to support
192 PROCESSOR= {- $config{processor} -}
194 # The main targets ###################################################
196 all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep \
199 build_libs: configdata.pm build_libs_nodep depend
200 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
201 build_engines: configdata.pm build_engines_nodep depend
202 build_engines_nodep: $(ENGINES)
203 build_apps: configdata.pm build_apps_nodep depend
204 build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
205 build_tests: configdata.pm build_tests_nodep depend
206 build_tests_nodep: $(TESTPROGS)
208 test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend rehash
210 SRCTOP=../$(SRCDIR) \
211 BLDTOP=../$(BLDDIR) \
213 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
216 @TOP=$(SRCDIR) PERL=$(PERL) $(PERL) $(SRCDIR)/test/run_tests.pl list
219 -rm -f `find $(BLDDIR) -name '*$(LIB_EXT)' -o -name '*$(SHLIB_EXT)'`
221 install: install_sw install_ssldirs install_docs
223 uninstall: uninstall_docs uninstall_sw
226 rm -f $(PROGRAMS) $(TESTPROGS)
227 rm -f `find $(BLDDIR) -name '*$(DEP_EXT)'`
228 rm -f `find $(BLDDIR) -name '*$(OBJ_EXT)'`
229 rm -f $(BLDDIR)/core $(BLDDIR)/rehash.time
230 rm -f $(BLDDIR)/tags $(BLDDIR)/TAGS
231 rm -f $(BLDDIR)/openssl.pc $(BLDDIR)/libcrypto.pc $(BLDDIR)/libssl.pc
232 -rm -f `find $(BLDDIR) -type l`
235 # This exists solely for those who still type 'make depend'
238 @( sed -e '/^# DO NOT DELETE THIS LINE.*/,$$d' < Makefile; \
239 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
241 for d in $(DEPS); do \
242 if [ -f $$d ]; then cat $$d; fi; \
243 done ) > Makefile.new
244 @if ! cmp Makefile.new Makefile >/dev/null 2>&1; then \
245 mv -f Makefile.new Makefile; \
248 # Install helper targets #############################################
250 install_sw: all install_dev install_engines install_runtime
252 uninstall_sw: uninstall_dev uninstall_engines uninstall_runtime
254 install_docs: install_man_docs install_html_docs
256 uninstall_docs: uninstall_man_docs uninstall_html_docs
257 $(RM) -r -v $(DESTDIR)$(DOCDIR)
260 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
261 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
264 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
265 @echo "*** Installing development files"
266 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
267 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
268 $(BLDDIR)/include/openssl/*.h; do \
270 echo "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
271 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
272 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
274 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
275 @set -e; for l in $(LIBS); do \
277 echo "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
278 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
279 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
280 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
281 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
282 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
284 @ : {- output_off() if $config{no_shared}; "" -}
285 @set -e; for s in $(SHLIBS); do \
287 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
288 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
289 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
290 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
291 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
292 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
293 echo "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
294 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
295 ln -sf $$fn $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
297 : {- output_off() unless windowsdll(); "" -}; \
298 echo "install $$s.a -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
299 cp $$s.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
300 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
301 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \
302 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
303 : {- output_on() unless windowsdll(); "" -}; \
305 @ : {- output_on() if $config{no_shared}; "" -}
306 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
307 @echo "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
308 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
309 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
310 @echo "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
311 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
312 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
313 @echo "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
314 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
315 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
318 @echo "*** Uninstalling development files"
319 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
320 $(BLDDIR)/include/openssl/*.h; do \
322 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
323 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
325 @set -e; for l in $(LIBS); do \
327 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
328 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
330 @set -e; for s in $(SHLIBS); do \
332 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
333 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
334 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
335 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
337 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
338 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
339 : {- output_off() unless windowsdll(); "" -}; \
340 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
341 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
342 : {- output_on() unless windowsdll(); "" -}; \
344 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
345 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
346 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
347 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
348 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
349 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
352 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
353 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/
354 @echo "*** Installing engines"
355 @set -e; for e in $(ENGINES); do \
357 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
360 echo "install $$e -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn"; \
361 cp $$e $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
362 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
363 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \
364 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
368 @echo "*** Uninstalling engines"
369 @set -e; for e in $(ENGINES); do \
371 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
374 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn"; \
375 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
379 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
380 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
381 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
382 @echo "*** Installing runtime files"
383 : {- output_off() unless windowsdll(); "" -};
384 @set -e; for s in $(SHLIBS); do \
386 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
387 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
388 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
389 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
390 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
392 : {- output_on() unless windowsdll(); "" -};
393 @set -e; for x in $(PROGRAMS); do \
395 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
396 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
397 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
398 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
399 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
401 @set -e; for x in $(BIN_SCRIPTS); do \
403 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
404 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
405 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
406 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
407 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
409 @set -e; for x in $(MISC_SCRIPTS); do \
411 echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
412 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
413 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
414 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
415 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
417 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"
418 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
419 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
420 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
423 @echo "*** Uninstalling runtime files"
424 @set -e; for x in $(PROGRAMS); \
427 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
428 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
430 @set -e; for x in $(BIN_SCRIPTS); \
433 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
434 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
436 @set -e; for x in $(MISC_SCRIPTS); \
439 echo "$(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
440 $(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
442 : {- output_off() unless windowsdll(); "" -};
443 @set -e; for s in $(SHLIBS); do \
445 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
446 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
448 : {- output_on() unless windowsdll(); "" -};
449 $(RM) $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
451 # A method to extract all names from a .pod file
452 # The first sed extracts everything between "=head1 NAME" and the next =head1
453 # The second sed joins all the lines into one
454 # The third sed removes the description and turns all commas into spaces
455 # Voilà , you have a space separated list of names!
456 EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
457 sed -e ':a;{N;s/\n/ /;ba}' | \
458 sed -e 's/ - .*$$//;s/,/ /g'
461 here=`cd $(SRCDIR); pwd`; \
462 point=$$here/util/point.sh; \
463 for ds in apps:1 crypto:3 ssl:3; do \
464 defdir=`echo $$ds | cut -f1 -d:`; \
465 defsec=`echo $$ds | cut -f2 -d:`; \
466 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
467 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
468 [ -z "$$SEC" ] && SEC=$$defsec; \
469 fn=`basename $$p .pod`; \
470 NAME=`echo $$fn | tr [a-z] [A-Z]`; \
471 suf=`eval "echo $$OUTSUFFIX"`; \
472 top=`eval "echo $$OUTTOP"`; \
473 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
474 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
475 cat $$p | eval "$$GENERATE" \
476 > $$top/man$$SEC/$$fn$$suf; \
477 names=`cat $$p | $(EXTRACT_NAMES)`; \
478 ( cd $$top/man$$SEC; \
479 for n in $$names; do \
482 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
483 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
484 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
487 if [ "$$comp_n" != "$$comp_fn" ]; then \
488 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
489 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
496 here=`cd $(SRCDIR); pwd`; \
497 for ds in apps:1 crypto:3 ssl:3; do \
498 defdir=`echo $$ds | cut -f1 -d:`; \
499 defsec=`echo $$ds | cut -f2 -d:`; \
500 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
501 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
502 [ -z "$$SEC" ] && SEC=$$defsec; \
503 fn=`basename $$p .pod`; \
504 suf=`eval "echo $$OUTSUFFIX"`; \
505 top=`eval "echo $$OUTTOP"`; \
506 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
507 $(RM) $$top/man$$SEC/$$fn$$suf; \
508 names=`cat $$p | $(EXTRACT_NAMES)`; \
509 for n in $$names; do \
512 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
513 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
514 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
517 if [ "$$comp_n" != "$$comp_fn" ]; then \
518 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
519 $(RM) $$top/man$$SEC/$$n$$suf; \
522 ( $(RMDIR) $$top/man$$SEC 2>/dev/null || exit 0 ); \
527 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
528 @echo "*** Installing manpages"
530 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
531 OUTTOP="$(DESTDIR)$(MANDIR)"; \
532 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
536 @echo "*** Uninstalling manpages"
538 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
539 OUTTOP="$(DESTDIR)$(MANDIR)"; \
543 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
544 @echo "*** Installing HTML manpages"
546 OUTSUFFIX='.$(HTMLSUFFIX)'; \
547 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
548 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
549 --podpath=apps:crypto:ssl \
550 | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \
554 @echo "*** Uninstalling manpages"
556 OUTSUFFIX='.$(HTMLSUFFIX)'; \
557 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
561 # Developer targets (note: these are only available on Unix) #########
563 update: generate errors ordinals
565 generate: generate_apps generate_crypto_bn generate_crypto_objects
567 # Test coverage is a good idea for the future
568 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
571 # Currently disabled, util/selftest.pl needs a rewrite
573 # SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl
576 lint -DLINT $(INCLUDES) $(SRCS)
578 generate_apps: $(SRCDIR)/apps/openssl-vms.cnf $(SRCDIR)/apps/progs.h
580 generate_crypto_bn: $(SRCDIR)/crypto/bn/bn_prime.h
582 generate_crypto_objects: $(SRCDIR)/crypto/objects/obj_dat.h \
583 $(SRCDIR)/include/openssl/obj_mac.h \
584 $(SRCDIR)/crypto/objects/obj_xref.h
587 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
588 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
589 ( cd $(SRCDIR)/engines; \
591 $(PERL) ../util/mkerr.pl -conf $$e \
592 -nostatic -staticloader -write *.c; \
594 ( cd $(SRCDIR)/crypto/ct; \
595 $(PERL) ../../util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c )
598 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
599 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
603 SRCTOP=../$(SRCDIR) \
604 BLDTOP=../$(BLDDIR) \
605 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
610 -etags `find . -name '*.[ch]' -o -name '*.pm'`
612 # Release targets (note: only available on Unix) #####################
615 TMPDIR=/var/tmp/openssl-copy.$$$$; \
616 DISTDIR=openssl-$(VERSION); \
617 mkdir -p $$TMPDIR/$$DISTDIR; \
619 git ls-tree -r --name-only --full-tree HEAD \
621 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
622 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
625 [ -n "$(PREPARE_CMD)" ] && $(PREPARE_CMD); \
626 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
627 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
628 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
629 $(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - $$DISTDIR) \
630 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
632 cd $(SRCDIR); ls -l $(TARFILE).gz
635 @$(MAKE) PREPARE_CMD='./Configure dist' tar
637 # Helper targets #####################################################
639 rehash: link-utils copy-certs build_apps_nodep
640 @if [ -z "$(CROSS_COMPILE)" ]; then \
641 (OPENSSL="$(BLDDIR)/util/shlib_wrap.sh apps/openssl"; \
642 [ -x "$(BLDDIR)/openssl.exe" ] && OPENSSL="$(BLDDIR)/openssl.exe" || :; \
643 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
644 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
645 $$OPENSSL rehash certs/demo \
646 || $(PERL) tools/c_rehash certs/demo) && \
650 link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
652 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
653 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
654 mkdir -p "$(BLDDIR)/util"; \
655 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
657 $(BLDDIR)/util/shlib_wrap.sh: configdata.pm
658 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
659 mkdir -p "$(BLDDIR)/util"; \
660 ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
664 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
665 cp -R "$(SRCDIR)/certs" "$(BLDDIR)/"; \
668 $(SRCDIR)/apps/openssl-vms.cnf: $(SRCDIR)/apps/openssl.cnf
669 $(PERL) $(SRCDIR)/VMS/VMSify-conf.pl \
670 < $(SRCDIR)/apps/openssl.cnf > $(SRCDIR)/apps/openssl-vms.cnf
672 {- # because the program apps/openssl has object files as sources, and
673 # they then have the corresponding C files as source, we need to chain
674 # the lookups in %unified_info
675 my $apps_openssl = catfile("apps","openssl");
676 our @openssl_source = map { @{$unified_info{sources}->{$_}} }
677 @{$unified_info{sources}->{$apps_openssl}};
679 $(SRCDIR)/apps/progs.h:
681 $(PERL) $(SRCDIR)/apps/progs.pl {- join(" ", @openssl_source) -} > $@
683 $(SRCDIR)/crypto/bn/bn_prime.h: $(SRCDIR)/crypto/bn/bn_prime.pl
684 $(PERL) $(SRCDIR)/crypto/bn/bn_prime.pl > $(SRCDIR)/crypto/bn/bn_prime.h
686 $(SRCDIR)/crypto/objects/obj_dat.h: $(SRCDIR)/crypto/objects/obj_dat.pl \
687 $(SRCDIR)/include/openssl/obj_mac.h
688 $(PERL) $(SRCDIR)/crypto/objects/obj_dat.pl \
689 $(SRCDIR)/include/openssl/obj_mac.h \
690 $(SRCDIR)/crypto/objects/obj_dat.h
692 # objects.pl both reads and writes obj_mac.num
693 $(SRCDIR)/include/openssl/obj_mac.h: $(SRCDIR)/crypto/objects/objects.pl \
694 $(SRCDIR)/crypto/objects/objects.txt \
695 $(SRCDIR)/crypto/objects/obj_mac.num
696 $(PERL) $(SRCDIR)/crypto/objects/objects.pl \
697 $(SRCDIR)/crypto/objects/objects.txt \
698 $(SRCDIR)/crypto/objects/obj_mac.num \
699 $(SRCDIR)/include/openssl/obj_mac.h
700 @sleep 1; touch $(SRCDIR)/include/openssl/obj_mac.h; sleep 1
702 $(SRCDIR)/crypto/objects/obj_xref.h: $(SRCDIR)/crypto/objects/objxref.pl \
703 $(SRCDIR)/crypto/objects/obj_xref.txt \
704 $(SRCDIR)/crypto/objects/obj_mac.num
705 $(PERL) $(SRCDIR)/crypto/objects/objxref.pl \
706 $(SRCDIR)/crypto/objects/obj_mac.num \
707 $(SRCDIR)/crypto/objects/obj_xref.txt \
708 > $(SRCDIR)/crypto/objects/obj_xref.h
709 @sleep 1; touch $(SRCDIR)/crypto/objects/obj_xref.h; sleep 1
713 # Building targets ###################################################
715 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS)
717 @ ( echo 'prefix=$(INSTALLTOP)'; \
718 echo 'exec_prefix=$${prefix}'; \
719 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
720 echo 'includedir=$${prefix}/include'; \
722 echo 'Name: OpenSSL-libcrypto'; \
723 echo 'Description: OpenSSL cryptography library'; \
724 echo 'Version: '$(VERSION); \
725 echo 'Libs: -L$${libdir} -lcrypto'; \
726 echo 'Libs.private: $(EX_LIBS)'; \
727 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
730 @ ( echo 'prefix=$(INSTALLTOP)'; \
731 echo 'exec_prefix=$${prefix}'; \
732 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
733 echo 'includedir=$${prefix}/include'; \
735 echo 'Name: OpenSSL-libssl'; \
736 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
737 echo 'Version: '$(VERSION); \
738 echo 'Requires.private: libcrypto'; \
739 echo 'Libs: -L$${libdir} -lssl'; \
740 echo 'Libs.private: $(EX_LIBS)'; \
741 echo 'Cflags: -I$${includedir}' ) > libssl.pc
744 @ ( echo 'prefix=$(INSTALLTOP)'; \
745 echo 'exec_prefix=$${prefix}'; \
746 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
747 echo 'includedir=$${prefix}/include'; \
749 echo 'Name: OpenSSL'; \
750 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
751 echo 'Version: '$(VERSION); \
752 echo 'Requires: libssl libcrypto' ) > openssl.pc
754 # Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which
755 # wasn't passed down automatically. It's quite safe to use it like we do
756 # below; if it doesn't exist, the result will be empty and 'make' will pick
757 # up $(MAKEFLAGS) which is passed down as an environment variable.
758 configdata.pm: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/config
759 @echo "Detected changed: $?"
760 @echo "Reconfiguring..."
761 $(SRCDIR)/Configure reconf
762 @echo "**************************************************"
764 @echo "*** Please run the same make command again ***"
766 @echo "**************************************************"
771 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
773 # Helper function to figure out dependencies on libraries
774 # It takes a list of library names and outputs a list of dependencies
775 sub compute_lib_depends {
776 if ($config{no_shared}) {
777 return map { $_."\$(LIB_EXT)" } @_;
780 # Depending on shared libraries:
781 # On Windows POSIX layers, we depend on {libname}.dll.a
782 # On Unix platforms, we depend on {shlibname}.so
783 return map { shlib_simple($_) } @_;
788 my $obj = $args{obj};
789 my $srcs = join(" ", @{$args{srcs}});
790 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
791 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
792 my $makedepprog = $config{makedepprog};
793 if ($makedepprog eq "makedepend") {
795 $obj\$(DEP_EXT): $deps
796 rm -f \$\@.tmp; touch \$\@.tmp
797 \$(MAKEDEPEND) -f\$\@.tmp -o"|$obj" -- \$(CFLAGS)$incs -- $srcs \\
799 sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$\$/d' -e '/^\\(#.*\\| *\\)\$\$/d' \$\@.tmp > \$\@
801 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
802 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
806 $obj\$(DEP_EXT): $deps
807 \$(CC) \$(CFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
808 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
809 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
812 # On Unix, we build shlibs from static libs, so we're ignoring the
813 # object file array. We *know* this routine is only called when we've
814 # configure 'shared'.
817 my $lib = $args{lib};
818 my $shlib = $args{shlib};
819 my $libd = dirname($lib);
820 my $libn = basename($lib);
821 (my $libname = $libn) =~ s/^lib//;
822 my $linklibs = join("", map { my $d = dirname($_);
823 my $f = basename($_);
824 (my $l = $f) =~ s/^lib//;
825 " -L$d -l$l" } @{$args{deps}});
826 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
827 my $shlib_target = $target{shared_target};
828 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
829 my $target = shlib_simple($lib);
831 # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
832 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
833 # With all other Unix platforms, we often build a shared library with the
834 # SO version built into the file name and a symlink without the SO version
835 # It's not necessary to have both as targets. The choice falls on the
836 # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
837 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
838 $target : $lib\$(LIB_EXT) $deps $ordinalsfile
839 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
840 PLATFORM=\$(PLATFORM) \\
841 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
842 INSTALLTOP="\$(INSTALLTOP)" LIBDIR="\$(LIBDIR)" \\
843 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
844 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
845 LIBCOMPATVERSIONS=";\$(SHLIB_VERSION_HISTORY)" \\
846 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
847 CROSS_COMPILE="\$(CROSS_COMPILE)" \\
848 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
849 SHARED_RCFLAGS="\$(SHARED_RCFLAGS)" \\
852 . (windowsdll() ? <<"EOF" : "");
853 rm -f apps/$shlib\$(SHLIB_EXT)
854 rm -f test/$shlib\$(SHLIB_EXT)
855 cp -p $shlib\$(SHLIB_EXT) apps/
856 cp -p $shlib\$(SHLIB_EXT) test/
861 my $lib = $args{lib};
862 my $libd = dirname($lib);
863 my $libn = basename($lib);
864 (my $libname = $libn) =~ s/^lib//;
865 my $shlibdeps = join("", map { my $d = dirname($_);
866 my $f = basename($_);
867 (my $l = $f) =~ s/^lib//;
868 " -L$d -l$l" } @{$args{deps}});
869 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
870 my $shlib_target = $target{shared_target};
871 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
872 my $target = dso($lib);
875 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
876 PLATFORM=\$(PLATFORM) \\
877 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
878 LIBDEPS="\$(PLIB_LDFLAGS) $shlibdeps \$(EX_LIBS)" \\
879 LIBNAME=$libname LDFLAGS="\$(LDFLAGS)" \\
880 CC="\$(CC)" CFLAGS="\$(CFLAGS)" \\
881 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" \\
882 SHLIB_EXT=\$(DSO_EXT) \\
889 my $lib = $args{lib};
890 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
892 $lib\$(LIB_EXT): $objs
894 \$(RANLIB) \$\@ || echo Never mind.
899 my $bin = $args{bin};
900 my $bind = dirname($bin);
901 my $binn = basename($bin);
902 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
903 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
904 my $linklibs = join("", map { my $d = dirname($_);
905 my $f = basename($_);
906 $d = "." if $d eq $f;
907 (my $l = $f) =~ s/^lib//;
908 " -L$d -l$l" } @{$args{deps}});
909 my $shlib_target = $config{no_shared} ? "" : $target{shared_target};
911 $bin\$(EXE_EXT): $objs $deps
912 \$(RM) $bin\$(EXE_EXT)
913 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
914 PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
915 APPNAME=$bin OBJECTS="$objs" \\
916 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
917 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
918 LIBRPATH="\$(INSTALLTOP)/\$(LIBDIR)" \\
919 link_app.$shlib_target
924 my $script = $args{script};
925 my $sources = join(" ", @{$args{sources}});
926 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
927 "util", "dofile.pl")),
928 rel2abs($config{builddir}));
931 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
932 "-o$target{build_file}" $sources > "$script"
936 "" # Important! This becomes part of the template result.