2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
7 sub shlib_ext { $target{shared_extension} || ".so" }
8 sub shlib_ext_simple { (my $x = $target{shared_extension})
9 =~ s/\.\$\(SHLIB_MAJOR\)\.\$\(SHLIB_MINOR\)//;
12 PLATFORM={- $config{target} -}
13 OPTIONS={- $config{options} -}
14 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
15 SRCDIR={- $config{sourcedir} -}
16 BLDDIR={- $config{builddir} -}
18 VERSION={- $config{version} -}
19 MAJOR={- $config{major} -}
20 MINOR={- $config{minor} -}
21 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
22 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
23 SHLIB_MAJOR={- $config{shlib_major} -}
24 SHLIB_MINOR={- $config{shlib_minor} -}
25 SHLIB_TARGET={- $target{shared_target} -}
27 EXE_EXT={- $target{exe_extension} || "" -}
28 LIB_EXT={- $target{lib_extension} || ".a" -}
29 SHLIB_EXT={- shlib_ext() -}
30 SHLIB_EXT_SIMPLE={- shlib_ext_simple() -}
31 OBJ_EXT={- $target{obj_extension} || ".o" -}
32 DEP_EXT={- $target{dep_extension} || ".d" -}
34 LIBS={- join(" ", map { $_."\$(LIB_EXT)" } @{$unified_info{libraries}}) -}
35 SHLIBS={- join(" ", map { $_."\$(SHLIB_EXT)" } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}}) -}
36 ENGINES={- join(" ", map { $_."\$(SHLIB_EXT_SIMPLE)" } @{$unified_info{engines}}) -}
37 PROGRAMS={- join(" ", map { $_."\$(EXE_EXT)" } grep { !m|^test/| } @{$unified_info{programs}}) -}
38 TESTPROGS={- join(" ", map { $_."\$(EXE_EXT)" } grep { m|^test/| } @{$unified_info{programs}}) -}
39 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
40 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
41 MISC_SCRIPTS=$(SRCDIR)/tools/c_hash $(SRCDIR)/tools/c_info \
42 $(SRCDIR)/tools/c_issuer $(SRCDIR)/tools/c_name \
43 $(BLDDIR)/apps/CA.pl $(SRCDIR)/apps/tsget
45 # DESTDIR is for package builders so that they can configure for, say,
46 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
47 # Normally it is left empty.
50 # Do not edit these manually. Use Configure with --prefix or --openssldir
51 # to change this! Short explanation in the top comment in Configure
52 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
54 our $prefix = $config{prefix} || "/usr/local";
57 # The logic here is that if no --openssldir was given,
58 # OPENSSLDIR will get the value from $prefix plus "/ssl".
59 # If --openssldir was given and the value is an absolute
60 # path, OPENSSLDIR will get its value without change.
61 # If the value from --openssldir is a relative path,
62 # OPENSSLDIR will get $prefix with the --openssldir
63 # value appended as a subdirectory.
65 use File::Spec::Functions;
68 (file_name_is_absolute($config{openssldir}) ?
70 : catdir($prefix, $config{openssldir}))
71 : catdir($prefix, "ssl");
74 # if $prefix/lib$target{multilib} is not an existing
75 # directory, then assume that it's not searched by linker
76 # automatically, in which case adding $target{multilib} suffix
77 # causes more grief than we're ready to tolerate, so don't...
79 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
80 our $libdir = $config{libdir} || "lib$multilib";
82 ENGINESDIR={- use File::Spec::Functions;
83 catdir($prefix,$libdir,"engines") -}
85 MANDIR=$(INSTALLTOP)/share/man
86 HTMLDIR=$(INSTALLTOP)/share/doc/$(BASENAME)/html
88 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
89 # appended after the manpage file section number. "ssl" is popular,
90 # resulting in files such as config.5ssl rather than config.5.
96 CROSS_COMPILE= {- $config{cross_compile_prefix} -}
97 CC= $(CROSS_COMPILE){- $target{cc} -}
98 CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $config{cflags} -}
99 CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
100 DEPFLAGS= {- join(" ",map { "-D".$_} @{$config{depdefines}}) -}
101 LDFLAGS= {- $config{lflags} -}
102 PLIB_LDFLAGS= {- $config{plib_lflags} -}
103 EX_LIBS= {- $config{ex_libs} -}
104 SHARED_LDFLAGS={- $target{shared_ldflag}
105 # Unlike other OSes (like Solaris, Linux, Tru64,
106 # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
107 # and FreeBSD) "demand" RPATH set on .so objects.
108 # Apparently application RPATH is not global and
109 # does not apply to .so linked with other .so.
110 # Problem manifests itself when libssl.so fails to
111 # load libcrypto.so. One can argue that we should
112 # engrave this into Makefile.shared rules or into
113 # BSD-* config lines above. Meanwhile let's try to
114 # be cautious and pass -rpath to linker only when
115 # $prefix is not /usr.
116 . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
117 ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
118 SHARED_RCFLAGS={- $target{shared_rcflag} -}
120 PERL={- $config{perl} -}
122 ARFLAGS= {- $target{arflags} -}
123 AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
124 RANLIB= {- $target{ranlib} -}
125 NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
127 TAR= {- $target{tar} || "tar" -}
128 TARFLAGS= {- $target{tarflags} -}
131 NAME= $(BASENAME)-$(VERSION)
132 TARFILE= ../$(NAME).tar
134 # We let the C compiler driver to take care of .s files. This is done in
135 # order to be excused from maintaining a separate set of architecture
136 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
137 # gcc, then the driver will automatically translate it to -xarch=v8plus
138 # and pass it down to assembler.
141 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
143 # For x86 assembler: Set PROCESSOR to 386 if you want to support
145 PROCESSOR= {- $config{processor} -}
147 # The main targets ###################################################
149 all: build_libs build_engines build_apps link-utils
151 # The pkg-config files depend on the libraries as well as Makefile
152 build_libs: libcrypto.pc libssl.pc openssl.pc
153 build_engines: $(ENGINES)
154 build_apps: $(PROGRAMS) $(SCRIPTS)
155 build_tests: $(TESTPROGS)
157 test tests: build_tests build_apps build_engines rehash
159 SRCTOP=../$(SRCDIR) \
160 BLDTOP=../$(BLDDIR) \
161 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
164 @TOP=$(SRCDIR) PERL=$(PERL) $(PERL) $(SRCDIR)/test/run_tests.pl list
167 -rm -f `find $(BLDDIR) -name '*$(LIB_EXT)' -o -name '*$(SHLIB_EXT)'`
169 install: install_sw install_ssldirs install_docs
171 uninstall: uninstall_docs uninstall_sw
174 rm -f $(PROGRAMS) $(TESTPROGS)
175 rm -f `find $(BLDDIR) -name '*$(DEP_EXT)'`
176 rm -f `find $(BLDDIR) -name '*$(OBJ_EXT)'`
177 rm -f $(BLDDIR)/core $(BLDDIR)/rehash.time
178 rm -f $(BLDDIR)/tags $(BLDDIR)/TAGS
179 rm -f $(BLDDIR)/openssl.pc $(BLDDIR)/libcrypto.pc $(BLDDIR)/libssl.pc
180 -rm -f `find $(BLDDIR) -type l`
183 DCLEAN_CMD=sed -e '/^DO NOT DELETE.*/,$$d'
185 $(DCLEAN_CMD) < Makefile >Makefile.new
186 mv -f Makefile.new Makefile
188 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
189 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
190 keys %{$unified_info{sources}}); -}
192 ( $(DCLEAN_CMD) < Makefile; \
193 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
195 cat `find . -name '*$(DEP_EXT)'` ) > Makefile.new
196 mv -f Makefile.new Makefile
198 # Install helper targets #############################################
200 install_sw: all install_dev install_engines install_runtime
202 uninstall_sw: uninstall_dev uninstall_engines uninstall_runtime
204 install_docs: install_man_docs install_html_docs
206 uninstall_docs: uninstall_man_docs uninstall_html_docs
209 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
210 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
213 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
214 @echo "*** Installing development files"
215 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
216 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
217 $(BLDDIR)/include/openssl/*.h; do \
219 echo "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
220 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
221 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
223 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
224 @set -e; for l in $(LIBS); do \
226 echo "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
227 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
228 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
229 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
230 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
231 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
233 @ : {- output_off() if $config{no_shared}; "" -}
234 @set -e; for s in $(SHLIBS); do \
236 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
237 cp $$s $(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; \
241 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
242 echo "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
243 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
244 ln -sf $$fn $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
246 : {- output_off() unless windowsdll(); "" -}; \
247 echo "install $$s.a -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
248 cp $$s.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
249 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
250 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \
251 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
252 : {- output_on() unless windowsdll(); "" -}; \
254 @ : {- output_on() if $config{no_shared}; "" -}
255 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
256 @echo "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
257 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
258 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
259 @echo "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
260 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
261 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
262 @echo "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
263 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
264 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
267 @echo "*** Uninstalling development files"
268 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
269 $(BLDDIR)/include/openssl/*.h; do \
271 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
272 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
274 @set -e; for l in $(LIBS); do \
276 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
277 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
279 @set -e; for s in $(SHLIBS); do \
281 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
282 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
283 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
284 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
286 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
287 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
288 : {- output_off() unless windowsdll(); "" -}; \
289 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
290 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
291 : {- output_on() unless windowsdll(); "" -}; \
293 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
294 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
295 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
296 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
297 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
298 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
301 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
302 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/
303 @echo "*** Installing engines"
304 @set -e; for e in $(ENGINES); do \
306 echo "install $$e -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
307 cp $$e $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
308 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
309 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \
310 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
314 @echo "*** Uninstalling engines"
315 @set -e; for e in $(ENGINES); do \
317 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
318 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
322 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
323 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
324 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
325 @echo "*** Installing runtime files"
326 : {- output_off() unless windowsdll(); "" -};
327 @set -e; for s in $(SHLIBS); do \
329 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
330 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
331 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
332 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
333 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
335 : {- output_on() unless windowsdll(); "" -};
336 @set -e; for x in $(PROGRAMS); do \
338 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
339 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
340 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
341 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
342 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
344 @set -e; for x in $(BIN_SCRIPTS); do \
346 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
347 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
348 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
349 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
350 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
352 @set -e; for x in $(MISC_SCRIPTS); do \
354 echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
355 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
356 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
357 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
358 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
360 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"
361 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
362 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
363 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
366 @echo "*** Uninstalling runtime files"
367 @set -e; for x in $(PROGRAMS); \
370 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
371 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
373 @set -e; for x in $(BIN_SCRIPTS); \
376 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
377 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
379 @set -e; for x in $(MISC_SCRIPTS); \
382 echo "$(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
383 $(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
385 : {- output_off() unless windowsdll(); "" -};
386 @set -e; for s in $(SHLIBS); do \
388 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
389 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
391 : {- output_on() unless windowsdll(); "" -};
392 $(RM) $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
394 # A method to extract all names from a .pod file
395 # The first sed extracts everything between "=head1 NAME" and the next =head1
396 # The second sed joins all the lines into one
397 # The third sed removes the description and turns all commas into spaces
398 # Voilà , you have a space separated list of names!
399 EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
400 sed -e ':a;{N;s/\n/ /;ba}' | \
401 sed -e 's/ - .*$$//;s/,/ /g'
404 here=`cd $(SRCDIR); pwd`; \
405 point=$$here/util/point.sh; \
406 for ds in apps:1 crypto:3 ssl:3; do \
407 defdir=`echo $$ds | cut -f1 -d:`; \
408 defsec=`echo $$ds | cut -f2 -d:`; \
409 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
410 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
411 [ -z "$$SEC" ] && SEC=$$defsec; \
412 fn=`basename $$p .pod`; \
413 NAME=`echo $$fn | tr [a-z] [A-Z]`; \
414 suf=`eval "echo $$OUTSUFFIX"`; \
415 top=`eval "echo $$OUTTOP"`; \
416 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
417 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
418 cat $$p | eval "$$GENERATE" \
419 > $$top/man$$SEC/$$fn$$suf; \
420 names=`cat $$p | $(EXTRACT_NAMES)`; \
421 ( cd $$top/man$$SEC; \
422 for n in $$names; do \
425 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
426 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
427 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
430 if [ "$$comp_n" != "$$comp_fn" ]; then \
431 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
432 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
439 here=`cd $(SRCDIR); pwd`; \
440 for ds in apps:1 crypto:3 ssl:3; do \
441 defdir=`echo $$ds | cut -f1 -d:`; \
442 defsec=`echo $$ds | cut -f2 -d:`; \
443 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
444 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
445 [ -z "$$SEC" ] && SEC=$$defsec; \
446 fn=`basename $$p .pod`; \
447 suf=`eval "echo $$OUTSUFFIX"`; \
448 top=`eval "echo $$OUTTOP"`; \
449 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
450 $(RM) $$top/man$$SEC/$$fn$$suf; \
451 names=`cat $$p | $(EXTRACT_NAMES)`; \
452 for n in $$names; do \
455 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
456 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
457 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
460 if [ "$$comp_n" != "$$comp_fn" ]; then \
461 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
462 $(RM) $$top/man$$SEC/$$n$$suf; \
469 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
470 @echo "*** Installing manpages"
472 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
473 OUTTOP="$(DESTDIR)$(MANDIR)"; \
474 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
478 @echo "*** Uninstalling manpages"
480 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
481 OUTTOP="$(DESTDIR)$(MANDIR)"; \
485 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
486 @echo "*** Installing HTML manpages"
488 OUTSUFFIX='.$(HTMLSUFFIX)'; \
489 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
490 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
491 --podpath=apps:crypto:ssl \
492 | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \
496 @echo "*** Uninstalling manpages"
498 OUTSUFFIX='.$(HTMLSUFFIX)'; \
499 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
503 # Developer targets (note: these are only available on Unix) #########
505 update: generate errors ordinals
507 generate: generate_apps generate_crypto_bn generate_crypto_objects
509 # Test coverage is a good idea for the future
510 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
513 # Currently disabled, util/selftest.pl needs a rewrite
515 # SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl
518 lint -DLINT $(INCLUDES) $(SRCS)
520 generate_apps: $(SRCDIR)/apps/openssl-vms.cnf $(SRCDIR)/apps/progs.h
522 generate_crypto_bn: $(SRCDIR)/crypto/bn/bn_prime.h
524 generate_crypto_objects: $(SRCDIR)/crypto/objects/obj_dat.h \
525 $(SRCDIR)/include/openssl/obj_mac.h \
526 $(SRCDIR)/crypto/objects/obj_xref.h
529 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
530 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
531 ( cd $(SRCDIR)/engines; \
533 $(PERL) ../util/mkerr.pl -conf $$e \
534 -nostatic -staticloader -write *.c; \
536 ( cd $(SRCDIR)/crypto/ct; \
537 $(PERL) ../../util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c )
540 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
541 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
545 SRCTOP=../$(SRCDIR) \
546 BLDTOP=../$(BLDDIR) \
547 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
552 -etags `find . -name '*.[ch]' -o -name '*.pm'`
554 # Release targets (note: only available on Unix) #####################
557 TMPDIR=/var/tmp/openssl-copy.$$$$; \
558 DISTDIR=openssl-$(VERSION); \
559 mkdir -p $$TMPDIR/$$DISTDIR; \
561 git ls-tree -r --name-only --full-tree HEAD \
563 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
564 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
567 [ -n "$(PREPARE_CMD)" ] && $(PREPARE_CMD); \
568 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
569 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
570 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
571 $(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - $$DISTDIR) \
572 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
574 cd $(SRCDIR); ls -l $(TARFILE).gz
577 @$(MAKE) PREPARE_CMD='./Configure dist' tar
579 # Helper targets #####################################################
581 rehash: link-utils copy-certs build_apps
582 @if [ -z "$(CROSS_COMPILE)" ]; then \
583 (OPENSSL="$(BLDDIR)/util/shlib_wrap.sh apps/openssl"; \
584 [ -x "$(BLDDIR)/openssl.exe" ] && OPENSSL="$(BLDDIR)/openssl.exe" || :; \
585 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
586 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
587 $$OPENSSL rehash certs/demo \
588 || $(PERL) tools/c_rehash certs/demo) && \
592 link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
594 $(BLDDIR)/util/opensslwrap.sh: Makefile
595 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
596 mkdir -p "$(BLDDIR)/util"; \
597 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
599 $(BLDDIR)/util/shlib_wrap.sh: Makefile
600 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
601 mkdir -p "$(BLDDIR)/util"; \
602 ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
606 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
607 cp -R "$(SRCDIR)/certs" "$(BLDDIR)/"; \
610 $(SRCDIR)/apps/openssl-vms.cnf: $(SRCDIR)/apps/openssl.cnf
611 $(PERL) $(SRCDIR)/VMS/VMSify-conf.pl \
612 < $(SRCDIR)/apps/openssl.cnf > $(SRCDIR)/apps/openssl-vms.cnf
614 {- # because the program apps/openssl has object files as sources, and
615 # they then have the corresponding C files as source, we need to chain
616 # the lookups in %unified_info
617 my $apps_openssl = catfile("apps","openssl");
618 our @openssl_source = map { @{$unified_info{sources}->{$_}} }
619 @{$unified_info{sources}->{$apps_openssl}};
621 $(SRCDIR)/apps/progs.h:
623 $(PERL) $(SRCDIR)/apps/progs.pl {- join(" ", @openssl_source) -} > $@
625 $(SRCDIR)/crypto/bn/bn_prime.h: $(SRCDIR)/crypto/bn/bn_prime.pl
626 $(PERL) $(SRCDIR)/crypto/bn/bn_prime.pl > $(SRCDIR)/crypto/bn/bn_prime.h
628 $(SRCDIR)/crypto/objects/obj_dat.h: $(SRCDIR)/crypto/objects/obj_dat.pl \
629 $(SRCDIR)/include/openssl/obj_mac.h
630 $(PERL) $(SRCDIR)/crypto/objects/obj_dat.pl \
631 $(SRCDIR)/include/openssl/obj_mac.h \
632 $(SRCDIR)/crypto/objects/obj_dat.h
634 # objects.pl both reads and writes obj_mac.num
635 $(SRCDIR)/include/openssl/obj_mac.h: $(SRCDIR)/crypto/objects/objects.pl \
636 $(SRCDIR)/crypto/objects/objects.txt \
637 $(SRCDIR)/crypto/objects/obj_mac.num
638 $(PERL) $(SRCDIR)/crypto/objects/objects.pl \
639 $(SRCDIR)/crypto/objects/objects.txt \
640 $(SRCDIR)/crypto/objects/obj_mac.num \
641 $(SRCDIR)/include/openssl/obj_mac.h
642 @sleep 1; touch $(SRCDIR)/include/openssl/obj_mac.h; sleep 1
644 $(SRCDIR)/crypto/objects/obj_xref.h: $(SRCDIR)/crypto/objects/objxref.pl \
645 $(SRCDIR)/crypto/objects/obj_xref.txt \
646 $(SRCDIR)/crypto/objects/obj_mac.num
647 $(PERL) $(SRCDIR)/crypto/objects/objxref.pl \
648 $(SRCDIR)/crypto/objects/obj_mac.num \
649 $(SRCDIR)/crypto/objects/obj_xref.txt \
650 > $(SRCDIR)/crypto/objects/obj_xref.h
651 @sleep 1; touch $(SRCDIR)/crypto/objects/obj_xref.h; sleep 1
655 # Building targets ###################################################
657 libcrypto.pc libssl.pc openssl.pc: Makefile $(LIBS)
659 @ ( echo 'prefix=$(INSTALLTOP)'; \
660 echo 'exec_prefix=$${prefix}'; \
661 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
662 echo 'includedir=$${prefix}/include'; \
664 echo 'Name: OpenSSL-libcrypto'; \
665 echo 'Description: OpenSSL cryptography library'; \
666 echo 'Version: '$(VERSION); \
667 echo 'Libs: -L$${libdir} -lcrypto'; \
668 echo 'Libs.private: $(EX_LIBS)'; \
669 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
672 @ ( echo 'prefix=$(INSTALLTOP)'; \
673 echo 'exec_prefix=$${prefix}'; \
674 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
675 echo 'includedir=$${prefix}/include'; \
677 echo 'Name: OpenSSL-libssl'; \
678 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
679 echo 'Version: '$(VERSION); \
680 echo 'Requires.private: libcrypto'; \
681 echo 'Libs: -L$${libdir} -lssl'; \
682 echo 'Libs.private: $(EX_LIBS)'; \
683 echo 'Cflags: -I$${includedir}' ) > libssl.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'; \
692 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
693 echo 'Version: '$(VERSION); \
694 echo 'Requires: libssl libcrypto' ) > openssl.pc
696 # Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which
697 # wasn't passed down automatically. It's quite safe to use it like we do
698 # below; if it doesn't exist, the result will be empty and 'make' will pick
699 # up $(MAKEFLAGS) which is passed down as an environment variable.
700 Makefile: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/config
701 @echo "Makefile is older than {- $config{build_file_template} -}, $(SRCDIR)/Configure or $(SRCDIR)/config."
702 @echo "Reconfiguring..."
703 $(SRCDIR)/Configure reconf
704 @echo "**************************************************"
706 @echo "*** Please run the same make command again ***"
708 @echo "**************************************************"
713 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
715 # Helper function to figure out dependencies on libraries
716 # It takes a list of library names and outputs a list of dependencies
717 sub compute_lib_depends {
718 if ($config{no_shared}) {
719 return map { $_."\$(LIB_EXT)" } @_;
722 # Depending on shared libraries:
723 # On Windows POSIX layers, we depend on {libname}.dll.a
724 # On Unix platforms, we depend on {shlibname}.so
725 return map { if (windowsdll()) {
726 "$_\$(SHLIB_EXT_SIMPLE).a"
729 $unified_info{sharednames}->{$_} || $_;
730 "$libname\$(SHLIB_EXT_SIMPLE)"
736 my $dep = $args{obj}.'$(DEP_EXT)';
737 my $obj = $args{obj}.'$(OBJ_EXT)';
738 my $srcs = join(" ", @{$args{srcs}});
739 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
740 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
741 my $makedepprog = $config{makedepprog};
742 if ($makedepprog eq "makedepend") {
745 rm -f \$\@.tmp; touch \$\@.tmp
746 \$(MAKEDEPEND) -f\$\@.tmp -o"|$obj"\
747 -- -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs \
749 sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$/d' -e '/^\\(#.*\\| *\\)\$/d' \$\@.tmp > \$\@
754 $dep : $deps Makefile
755 \$(CC) -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
760 my $obj = $args{obj}.'$(OBJ_EXT)';
761 my $srcs = join(" ", @{$args{srcs}});
762 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
763 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
766 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
769 # On Unix, we build shlibs from static libs, so we're ignoring the
770 # object file array. We *know* this routine is only called when we've
771 # configure 'shared'.
774 my $lib = $args{lib};
775 my $shlib = $args{shlib};
776 my $libd = dirname($lib);
777 my $libn = basename($lib);
778 (my $libname = $libn) =~ s/^lib//;
779 my $linklibs = join("", map { my $d = dirname($_);
780 my $f = basename($_);
781 (my $l = $f) =~ s/^lib//;
782 " -L$d -l$l" } @{$args{deps}});
783 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
784 my $shlib_target = $target{shared_target};
785 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
786 my $shlibtarget = windowsdll() ?
787 "$lib\$(SHLIB_EXT_SIMPLE).a" : "$shlib\$(SHLIB_EXT_SIMPLE)";
789 # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
790 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
791 # With all other Unix platforms, we often build a shared library with the
792 # SO version built into the file name and a symlink without the SO version
793 # It's not necessary to have both as targets. The choice falls on the
794 # simplest, {libname}\$(SHLIB_EXT_SIMPLE).a for Windows POSIX layers and
795 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
796 $shlibtarget : $lib\$(LIB_EXT) $deps $ordinalsfile
797 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
798 PLATFORM=\$(PLATFORM) \\
799 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
800 INSTALLTOP="\$(INSTALLTOP)" LIBDIR="\$(LIBDIR)" \\
801 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
802 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
803 LIBCOMPATVERSIONS=";\$(SHLIB_VERSION_HISTORY)" \\
804 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
805 CROSS_COMPILE="\$(CROSS_COMPILE)" \\
806 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
807 SHARED_RCFLAGS="\$(SHARED_RCFLAGS)" \\
810 . (windowsdll() ? <<"EOF" : "");
811 rm -f apps/$shlib\$(SHLIB_EXT)
812 rm -f test/$shlib\$(SHLIB_EXT)
813 cp -p $shlib\$(SHLIB_EXT) apps/
814 cp -p $shlib\$(SHLIB_EXT) test/
819 my $lib = $args{lib};
820 my $libd = dirname($lib);
821 my $libn = basename($lib);
822 (my $libname = $libn) =~ s/^lib//;
823 my $shlibdeps = join("", map { my $d = dirname($_);
824 my $f = basename($_);
825 (my $l = $f) =~ s/^lib//;
826 " -L$d -l$l" } @{$args{deps}});
827 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
828 my $shlib_target = $target{shared_target};
829 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
831 $lib\$(SHLIB_EXT_SIMPLE): $objs $deps
832 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
833 PLATFORM=\$(PLATFORM) \\
834 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
835 LIBDEPS="\$(PLIB_LDFLAGS) $shlibdeps \$(EX_LIBS)" \\
836 LIBNAME=$libname LDFLAGS="\$(LDFLAGS)" \\
837 CC="\$(CC)" CFLAGS="\$(CFLAGS)" \\
838 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" \\
839 SHLIB_EXT=\$(SHLIB_EXT_SIMPLE) \\
846 my $lib = $args{lib};
847 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
849 $lib\$(LIB_EXT) : $objs
851 \$(RANLIB) \$\@ || echo Never mind.
856 my $bin = $args{bin};
857 my $bind = dirname($bin);
858 my $binn = basename($bin);
859 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
860 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
861 my $linklibs = join("", map { my $d = dirname($_);
862 my $f = basename($_);
863 $d = "." if $d eq $f;
864 (my $l = $f) =~ s/^lib//;
865 " -L$d -l$l" } @{$args{deps}});
866 my $shlib_target = $config{no_shared} ? "" : $target{shared_target};
868 $bin\$(EXE_EXT) : $objs $deps
869 \$(RM) $bin\$(EXE_EXT)
870 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
871 PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
872 APPNAME=$bin OBJECTS="$objs" \\
873 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
874 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
875 LIBRPATH="\$(INSTALLTOP)/\$(LIBDIR)" \\
876 link_app.$shlib_target
881 my $script = $args{script};
882 my $sources = join(" ", @{$args{sources}});
883 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
884 "util", "dofile.pl")),
885 rel2abs($config{builddir}));
888 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
889 "-o$target{build_file}" $sources > "$script"
893 "" # Important! This becomes part of the template result.