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 echo "install $$e -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
316 cp $$e $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
317 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
318 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \
319 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
323 @echo "*** Uninstalling engines"
324 @set -e; for e in $(ENGINES); do \
326 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
327 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
331 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
332 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
333 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
334 @echo "*** Installing runtime files"
335 : {- output_off() unless windowsdll(); "" -};
336 @set -e; for s in $(SHLIBS); do \
338 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
339 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
340 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
341 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
342 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
344 : {- output_on() unless windowsdll(); "" -};
345 @set -e; for x in $(PROGRAMS); do \
347 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
348 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
349 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
350 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
351 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
353 @set -e; for x in $(BIN_SCRIPTS); do \
355 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
356 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
357 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
358 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
359 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
361 @set -e; for x in $(MISC_SCRIPTS); do \
363 echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
364 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
365 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
366 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
367 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
369 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"
370 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
371 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
372 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
375 @echo "*** Uninstalling runtime files"
376 @set -e; for x in $(PROGRAMS); \
379 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
380 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
382 @set -e; for x in $(BIN_SCRIPTS); \
385 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
386 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
388 @set -e; for x in $(MISC_SCRIPTS); \
391 echo "$(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
392 $(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
394 : {- output_off() unless windowsdll(); "" -};
395 @set -e; for s in $(SHLIBS); do \
397 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
398 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
400 : {- output_on() unless windowsdll(); "" -};
401 $(RM) $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
403 # A method to extract all names from a .pod file
404 # The first sed extracts everything between "=head1 NAME" and the next =head1
405 # The second sed joins all the lines into one
406 # The third sed removes the description and turns all commas into spaces
407 # Voilà , you have a space separated list of names!
408 EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
409 sed -e ':a;{N;s/\n/ /;ba}' | \
410 sed -e 's/ - .*$$//;s/,/ /g'
413 here=`cd $(SRCDIR); pwd`; \
414 point=$$here/util/point.sh; \
415 for ds in apps:1 crypto:3 ssl:3; do \
416 defdir=`echo $$ds | cut -f1 -d:`; \
417 defsec=`echo $$ds | cut -f2 -d:`; \
418 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
419 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
420 [ -z "$$SEC" ] && SEC=$$defsec; \
421 fn=`basename $$p .pod`; \
422 NAME=`echo $$fn | tr [a-z] [A-Z]`; \
423 suf=`eval "echo $$OUTSUFFIX"`; \
424 top=`eval "echo $$OUTTOP"`; \
425 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
426 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
427 cat $$p | eval "$$GENERATE" \
428 > $$top/man$$SEC/$$fn$$suf; \
429 names=`cat $$p | $(EXTRACT_NAMES)`; \
430 ( cd $$top/man$$SEC; \
431 for n in $$names; do \
434 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
435 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
436 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
439 if [ "$$comp_n" != "$$comp_fn" ]; then \
440 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
441 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
448 here=`cd $(SRCDIR); pwd`; \
449 for ds in apps:1 crypto:3 ssl:3; do \
450 defdir=`echo $$ds | cut -f1 -d:`; \
451 defsec=`echo $$ds | cut -f2 -d:`; \
452 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
453 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
454 [ -z "$$SEC" ] && SEC=$$defsec; \
455 fn=`basename $$p .pod`; \
456 suf=`eval "echo $$OUTSUFFIX"`; \
457 top=`eval "echo $$OUTTOP"`; \
458 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
459 $(RM) $$top/man$$SEC/$$fn$$suf; \
460 names=`cat $$p | $(EXTRACT_NAMES)`; \
461 for n in $$names; do \
464 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
465 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
466 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
469 if [ "$$comp_n" != "$$comp_fn" ]; then \
470 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
471 $(RM) $$top/man$$SEC/$$n$$suf; \
474 ( $(RMDIR) $$top/man$$SEC 2>/dev/null || exit 0 ); \
479 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
480 @echo "*** Installing manpages"
482 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
483 OUTTOP="$(DESTDIR)$(MANDIR)"; \
484 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
488 @echo "*** Uninstalling manpages"
490 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
491 OUTTOP="$(DESTDIR)$(MANDIR)"; \
495 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
496 @echo "*** Installing HTML manpages"
498 OUTSUFFIX='.$(HTMLSUFFIX)'; \
499 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
500 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
501 --podpath=apps:crypto:ssl \
502 | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \
506 @echo "*** Uninstalling manpages"
508 OUTSUFFIX='.$(HTMLSUFFIX)'; \
509 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
513 # Developer targets (note: these are only available on Unix) #########
515 update: generate errors ordinals
517 generate: generate_apps generate_crypto_bn generate_crypto_objects
519 # Test coverage is a good idea for the future
520 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
523 # Currently disabled, util/selftest.pl needs a rewrite
525 # SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl
528 lint -DLINT $(INCLUDES) $(SRCS)
530 generate_apps: $(SRCDIR)/apps/openssl-vms.cnf $(SRCDIR)/apps/progs.h
532 generate_crypto_bn: $(SRCDIR)/crypto/bn/bn_prime.h
534 generate_crypto_objects: $(SRCDIR)/crypto/objects/obj_dat.h \
535 $(SRCDIR)/include/openssl/obj_mac.h \
536 $(SRCDIR)/crypto/objects/obj_xref.h
539 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
540 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
541 ( cd $(SRCDIR)/engines; \
543 $(PERL) ../util/mkerr.pl -conf $$e \
544 -nostatic -staticloader -write *.c; \
546 ( cd $(SRCDIR)/crypto/ct; \
547 $(PERL) ../../util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c )
550 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
551 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
555 SRCTOP=../$(SRCDIR) \
556 BLDTOP=../$(BLDDIR) \
557 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
562 -etags `find . -name '*.[ch]' -o -name '*.pm'`
564 # Release targets (note: only available on Unix) #####################
567 TMPDIR=/var/tmp/openssl-copy.$$$$; \
568 DISTDIR=openssl-$(VERSION); \
569 mkdir -p $$TMPDIR/$$DISTDIR; \
571 git ls-tree -r --name-only --full-tree HEAD \
573 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
574 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
577 [ -n "$(PREPARE_CMD)" ] && $(PREPARE_CMD); \
578 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
579 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
580 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
581 $(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - $$DISTDIR) \
582 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
584 cd $(SRCDIR); ls -l $(TARFILE).gz
587 @$(MAKE) PREPARE_CMD='./Configure dist' tar
589 # Helper targets #####################################################
591 rehash: link-utils copy-certs build_apps_nodep
592 @if [ -z "$(CROSS_COMPILE)" ]; then \
593 (OPENSSL="$(BLDDIR)/util/shlib_wrap.sh apps/openssl"; \
594 [ -x "$(BLDDIR)/openssl.exe" ] && OPENSSL="$(BLDDIR)/openssl.exe" || :; \
595 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
596 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
597 $$OPENSSL rehash certs/demo \
598 || $(PERL) tools/c_rehash certs/demo) && \
602 link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
604 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
605 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
606 mkdir -p "$(BLDDIR)/util"; \
607 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
609 $(BLDDIR)/util/shlib_wrap.sh: configdata.pm
610 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
611 mkdir -p "$(BLDDIR)/util"; \
612 ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
616 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
617 cp -R "$(SRCDIR)/certs" "$(BLDDIR)/"; \
620 $(SRCDIR)/apps/openssl-vms.cnf: $(SRCDIR)/apps/openssl.cnf
621 $(PERL) $(SRCDIR)/VMS/VMSify-conf.pl \
622 < $(SRCDIR)/apps/openssl.cnf > $(SRCDIR)/apps/openssl-vms.cnf
624 {- # because the program apps/openssl has object files as sources, and
625 # they then have the corresponding C files as source, we need to chain
626 # the lookups in %unified_info
627 my $apps_openssl = catfile("apps","openssl");
628 our @openssl_source = map { @{$unified_info{sources}->{$_}} }
629 @{$unified_info{sources}->{$apps_openssl}};
631 $(SRCDIR)/apps/progs.h:
633 $(PERL) $(SRCDIR)/apps/progs.pl {- join(" ", @openssl_source) -} > $@
635 $(SRCDIR)/crypto/bn/bn_prime.h: $(SRCDIR)/crypto/bn/bn_prime.pl
636 $(PERL) $(SRCDIR)/crypto/bn/bn_prime.pl > $(SRCDIR)/crypto/bn/bn_prime.h
638 $(SRCDIR)/crypto/objects/obj_dat.h: $(SRCDIR)/crypto/objects/obj_dat.pl \
639 $(SRCDIR)/include/openssl/obj_mac.h
640 $(PERL) $(SRCDIR)/crypto/objects/obj_dat.pl \
641 $(SRCDIR)/include/openssl/obj_mac.h \
642 $(SRCDIR)/crypto/objects/obj_dat.h
644 # objects.pl both reads and writes obj_mac.num
645 $(SRCDIR)/include/openssl/obj_mac.h: $(SRCDIR)/crypto/objects/objects.pl \
646 $(SRCDIR)/crypto/objects/objects.txt \
647 $(SRCDIR)/crypto/objects/obj_mac.num
648 $(PERL) $(SRCDIR)/crypto/objects/objects.pl \
649 $(SRCDIR)/crypto/objects/objects.txt \
650 $(SRCDIR)/crypto/objects/obj_mac.num \
651 $(SRCDIR)/include/openssl/obj_mac.h
652 @sleep 1; touch $(SRCDIR)/include/openssl/obj_mac.h; sleep 1
654 $(SRCDIR)/crypto/objects/obj_xref.h: $(SRCDIR)/crypto/objects/objxref.pl \
655 $(SRCDIR)/crypto/objects/obj_xref.txt \
656 $(SRCDIR)/crypto/objects/obj_mac.num
657 $(PERL) $(SRCDIR)/crypto/objects/objxref.pl \
658 $(SRCDIR)/crypto/objects/obj_mac.num \
659 $(SRCDIR)/crypto/objects/obj_xref.txt \
660 > $(SRCDIR)/crypto/objects/obj_xref.h
661 @sleep 1; touch $(SRCDIR)/crypto/objects/obj_xref.h; sleep 1
665 # Building targets ###################################################
667 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS)
669 @ ( echo 'prefix=$(INSTALLTOP)'; \
670 echo 'exec_prefix=$${prefix}'; \
671 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
672 echo 'includedir=$${prefix}/include'; \
674 echo 'Name: OpenSSL-libcrypto'; \
675 echo 'Description: OpenSSL cryptography library'; \
676 echo 'Version: '$(VERSION); \
677 echo 'Libs: -L$${libdir} -lcrypto'; \
678 echo 'Libs.private: $(EX_LIBS)'; \
679 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
682 @ ( echo 'prefix=$(INSTALLTOP)'; \
683 echo 'exec_prefix=$${prefix}'; \
684 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
685 echo 'includedir=$${prefix}/include'; \
687 echo 'Name: OpenSSL-libssl'; \
688 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
689 echo 'Version: '$(VERSION); \
690 echo 'Requires.private: libcrypto'; \
691 echo 'Libs: -L$${libdir} -lssl'; \
692 echo 'Libs.private: $(EX_LIBS)'; \
693 echo 'Cflags: -I$${includedir}' ) > libssl.pc
696 @ ( echo 'prefix=$(INSTALLTOP)'; \
697 echo 'exec_prefix=$${prefix}'; \
698 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
699 echo 'includedir=$${prefix}/include'; \
701 echo 'Name: OpenSSL'; \
702 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
703 echo 'Version: '$(VERSION); \
704 echo 'Requires: libssl libcrypto' ) > openssl.pc
706 # Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which
707 # wasn't passed down automatically. It's quite safe to use it like we do
708 # below; if it doesn't exist, the result will be empty and 'make' will pick
709 # up $(MAKEFLAGS) which is passed down as an environment variable.
710 configdata.pm: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/config
711 @echo "Detected changed: $?"
712 @echo "Reconfiguring..."
713 $(SRCDIR)/Configure reconf
714 @echo "**************************************************"
716 @echo "*** Please run the same make command again ***"
718 @echo "**************************************************"
723 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
725 # Helper function to figure out dependencies on libraries
726 # It takes a list of library names and outputs a list of dependencies
727 sub compute_lib_depends {
728 if ($config{no_shared}) {
729 return map { $_."\$(LIB_EXT)" } @_;
732 # Depending on shared libraries:
733 # On Windows POSIX layers, we depend on {libname}.dll.a
734 # On Unix platforms, we depend on {shlibname}.so
735 return map { if (windowsdll()) {
736 "$_\$(SHLIB_EXT_SIMPLE).a"
739 $unified_info{sharednames}->{$_} || $_;
740 "$libname\$(SHLIB_EXT_SIMPLE)"
746 my $obj = $args{obj};
747 my $srcs = join(" ", @{$args{srcs}});
748 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
749 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
750 my $makedepprog = $config{makedepprog};
751 if ($makedepprog eq "makedepend") {
753 $obj\$(DEP_EXT): $deps
754 rm -f \$\@.tmp; touch \$\@.tmp
755 \$(MAKEDEPEND) -f\$\@.tmp -o"|$obj" -- \$(CFLAGS)$incs -- $srcs \\
757 sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$\$/d' -e '/^\\(#.*\\| *\\)\$\$/d' \$\@.tmp > \$\@
759 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
760 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
764 $obj\$(DEP_EXT): $deps
765 \$(CC) \$(CFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
766 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
767 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
770 # On Unix, we build shlibs from static libs, so we're ignoring the
771 # object file array. We *know* this routine is only called when we've
772 # configure 'shared'.
775 my $lib = $args{lib};
776 my $shlib = $args{shlib};
777 my $libd = dirname($lib);
778 my $libn = basename($lib);
779 (my $libname = $libn) =~ s/^lib//;
780 my $linklibs = join("", map { my $d = dirname($_);
781 my $f = basename($_);
782 (my $l = $f) =~ s/^lib//;
783 " -L$d -l$l" } @{$args{deps}});
784 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
785 my $shlib_target = $target{shared_target};
786 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
787 my $shlibtarget = windowsdll() ?
788 "$lib\$(SHLIB_EXT_SIMPLE).a" : "$shlib\$(SHLIB_EXT_SIMPLE)";
790 # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
791 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
792 # With all other Unix platforms, we often build a shared library with the
793 # SO version built into the file name and a symlink without the SO version
794 # It's not necessary to have both as targets. The choice falls on the
795 # simplest, {libname}\$(SHLIB_EXT_SIMPLE).a for Windows POSIX layers and
796 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
797 $shlibtarget: $lib\$(LIB_EXT) $deps $ordinalsfile
798 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
799 PLATFORM=\$(PLATFORM) \\
800 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
801 INSTALLTOP="\$(INSTALLTOP)" LIBDIR="\$(LIBDIR)" \\
802 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
803 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
804 LIBCOMPATVERSIONS=";\$(SHLIB_VERSION_HISTORY)" \\
805 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
806 CROSS_COMPILE="\$(CROSS_COMPILE)" \\
807 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
808 SHARED_RCFLAGS="\$(SHARED_RCFLAGS)" \\
811 . (windowsdll() ? <<"EOF" : "");
812 rm -f apps/$shlib\$(SHLIB_EXT)
813 rm -f test/$shlib\$(SHLIB_EXT)
814 cp -p $shlib\$(SHLIB_EXT) apps/
815 cp -p $shlib\$(SHLIB_EXT) test/
820 my $lib = $args{lib};
821 my $libd = dirname($lib);
822 my $libn = basename($lib);
823 (my $libname = $libn) =~ s/^lib//;
824 my $shlibdeps = join("", map { my $d = dirname($_);
825 my $f = basename($_);
826 (my $l = $f) =~ s/^lib//;
827 " -L$d -l$l" } @{$args{deps}});
828 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
829 my $shlib_target = $target{shared_target};
830 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
832 $lib\$(SHLIB_EXT_SIMPLE): $objs $deps
833 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
834 PLATFORM=\$(PLATFORM) \\
835 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
836 LIBDEPS="\$(PLIB_LDFLAGS) $shlibdeps \$(EX_LIBS)" \\
837 LIBNAME=$libname LDFLAGS="\$(LDFLAGS)" \\
838 CC="\$(CC)" CFLAGS="\$(CFLAGS)" \\
839 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" \\
840 SHLIB_EXT=\$(SHLIB_EXT_SIMPLE) \\
847 my $lib = $args{lib};
848 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
850 $lib\$(LIB_EXT): $objs
852 \$(RANLIB) \$\@ || echo Never mind.
857 my $bin = $args{bin};
858 my $bind = dirname($bin);
859 my $binn = basename($bin);
860 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
861 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
862 my $linklibs = join("", map { my $d = dirname($_);
863 my $f = basename($_);
864 $d = "." if $d eq $f;
865 (my $l = $f) =~ s/^lib//;
866 " -L$d -l$l" } @{$args{deps}});
867 my $shlib_target = $config{no_shared} ? "" : $target{shared_target};
869 $bin\$(EXE_EXT): $objs $deps
870 \$(RM) $bin\$(EXE_EXT)
871 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
872 PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
873 APPNAME=$bin OBJECTS="$objs" \\
874 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
875 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
876 LIBRPATH="\$(INSTALLTOP)/\$(LIBDIR)" \\
877 link_app.$shlib_target
882 my $script = $args{script};
883 my $sources = join(" ", @{$args{sources}});
884 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
885 "util", "dofile.pl")),
886 rel2abs($config{builddir}));
889 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
890 "-o$target{build_file}" $sources > "$script"
894 "" # Important! This becomes part of the template result.