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 HTMLDIR=$(INSTALLTOP)/share/doc/$(BASENAME)/html
92 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
93 # appended after the manpage file section number. "ssl" is popular,
94 # resulting in files such as config.5ssl rather than config.5.
100 CROSS_COMPILE= {- $config{cross_compile_prefix} -}
101 CC= $(CROSS_COMPILE){- $target{cc} -}
102 CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $config{cflags} -}
103 CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
104 LDFLAGS= {- $config{lflags} -}
105 PLIB_LDFLAGS= {- $config{plib_lflags} -}
106 EX_LIBS= {- $config{ex_libs} -}
107 SHARED_LDFLAGS={- $target{shared_ldflag}
108 # Unlike other OSes (like Solaris, Linux, Tru64,
109 # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
110 # and FreeBSD) "demand" RPATH set on .so objects.
111 # Apparently application RPATH is not global and
112 # does not apply to .so linked with other .so.
113 # Problem manifests itself when libssl.so fails to
114 # load libcrypto.so. One can argue that we should
115 # engrave this into Makefile.shared rules or into
116 # BSD-* config lines above. Meanwhile let's try to
117 # be cautious and pass -rpath to linker only when
118 # $prefix is not /usr.
119 . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
120 ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
121 SHARED_RCFLAGS={- $target{shared_rcflag} -}
123 PERL={- $config{perl} -}
125 ARFLAGS= {- $target{arflags} -}
126 AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
127 RANLIB= {- $target{ranlib} -}
128 NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
130 TAR= {- $target{tar} || "tar" -}
131 TARFLAGS= {- $target{tarflags} -}
132 MAKEDEPEND=$(CROSS_COMPILE){- $config{makedepprog} -}
135 NAME= $(BASENAME)-$(VERSION)
136 TARFILE= ../$(NAME).tar
138 # We let the C compiler driver to take care of .s files. This is done in
139 # order to be excused from maintaining a separate set of architecture
140 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
141 # gcc, then the driver will automatically translate it to -xarch=v8plus
142 # and pass it down to assembler.
145 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
147 # For x86 assembler: Set PROCESSOR to 386 if you want to support
149 PROCESSOR= {- $config{processor} -}
151 # The main targets ###################################################
153 all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep \
156 build_libs: configdata.pm build_libs_nodep depend
157 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
158 build_engines: configdata.pm build_engines_nodep depend
159 build_engines_nodep: $(ENGINES)
160 build_apps: configdata.pm build_apps_nodep depend
161 build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
162 build_tests: configdata.pm build_tests_nodep depend
163 build_tests_nodep: $(TESTPROGS)
165 test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend rehash
167 SRCTOP=../$(SRCDIR) \
168 BLDTOP=../$(BLDDIR) \
170 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
173 @TOP=$(SRCDIR) PERL=$(PERL) $(PERL) $(SRCDIR)/test/run_tests.pl list
176 -rm -f `find $(BLDDIR) -name '*$(LIB_EXT)' -o -name '*$(SHLIB_EXT)'`
178 install: install_sw install_ssldirs install_docs
180 uninstall: uninstall_docs uninstall_sw
183 rm -f $(PROGRAMS) $(TESTPROGS)
184 rm -f `find $(BLDDIR) -name '*$(DEP_EXT)'`
185 rm -f `find $(BLDDIR) -name '*$(OBJ_EXT)'`
186 rm -f $(BLDDIR)/core $(BLDDIR)/rehash.time
187 rm -f $(BLDDIR)/tags $(BLDDIR)/TAGS
188 rm -f $(BLDDIR)/openssl.pc $(BLDDIR)/libcrypto.pc $(BLDDIR)/libssl.pc
189 -rm -f `find $(BLDDIR) -type l`
192 # This exists solely for those who still type 'make depend'
195 @( sed -e '/^# DO NOT DELETE THIS LINE.*/,$$d' < Makefile; \
196 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
198 for d in $(DEPS); do \
199 if [ -f $$d ]; then cat $$d; fi; \
200 done ) > Makefile.new
201 @if ! cmp Makefile.new Makefile >/dev/null 2>&1; then \
202 mv -f Makefile.new Makefile; \
205 # Install helper targets #############################################
207 install_sw: all install_dev install_engines install_runtime
209 uninstall_sw: uninstall_dev uninstall_engines uninstall_runtime
211 install_docs: install_man_docs install_html_docs
213 uninstall_docs: uninstall_man_docs uninstall_html_docs
216 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
217 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
220 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
221 @echo "*** Installing development files"
222 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
223 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
224 $(BLDDIR)/include/openssl/*.h; do \
226 echo "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
227 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
228 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
230 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
231 @set -e; for l in $(LIBS); do \
233 echo "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
234 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
235 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
236 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
237 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
238 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
240 @ : {- output_off() if $config{no_shared}; "" -}
241 @set -e; for s in $(SHLIBS); do \
243 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
244 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
245 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
246 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
247 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
248 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
249 echo "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
250 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
251 ln -sf $$fn $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
253 : {- output_off() unless windowsdll(); "" -}; \
254 echo "install $$s.a -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
255 cp $$s.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
256 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
257 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \
258 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
259 : {- output_on() unless windowsdll(); "" -}; \
261 @ : {- output_on() if $config{no_shared}; "" -}
262 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
263 @echo "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
264 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
265 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
266 @echo "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
267 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
268 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
269 @echo "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
270 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
271 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
274 @echo "*** Uninstalling development files"
275 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
276 $(BLDDIR)/include/openssl/*.h; do \
278 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
279 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
281 @set -e; for l in $(LIBS); do \
283 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
284 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
286 @set -e; for s in $(SHLIBS); do \
288 if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \
289 fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
290 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
291 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
293 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
294 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
295 : {- output_off() unless windowsdll(); "" -}; \
296 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
297 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
298 : {- output_on() unless windowsdll(); "" -}; \
300 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
301 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
302 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
303 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
304 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
305 @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
308 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
309 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/
310 @echo "*** Installing engines"
311 @set -e; for e in $(ENGINES); do \
313 echo "install $$e -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
314 cp $$e $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
315 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \
316 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \
317 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
321 @echo "*** Uninstalling engines"
322 @set -e; for e in $(ENGINES); do \
324 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
325 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \
329 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
330 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
331 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
332 @echo "*** Installing runtime files"
333 : {- output_off() unless windowsdll(); "" -};
334 @set -e; for s in $(SHLIBS); do \
336 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
337 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
338 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
339 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
340 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
342 : {- output_on() unless windowsdll(); "" -};
343 @set -e; for x in $(PROGRAMS); do \
345 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
346 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
347 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
348 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
349 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
351 @set -e; for x in $(BIN_SCRIPTS); do \
353 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
354 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
355 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
356 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
357 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
359 @set -e; for x in $(MISC_SCRIPTS); do \
361 echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
362 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
363 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
364 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
365 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
367 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"
368 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
369 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
370 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
373 @echo "*** Uninstalling runtime files"
374 @set -e; for x in $(PROGRAMS); \
377 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
378 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
380 @set -e; for x in $(BIN_SCRIPTS); \
383 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
384 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
386 @set -e; for x in $(MISC_SCRIPTS); \
389 echo "$(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
390 $(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
392 : {- output_off() unless windowsdll(); "" -};
393 @set -e; for s in $(SHLIBS); do \
395 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
396 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
398 : {- output_on() unless windowsdll(); "" -};
399 $(RM) $(DESTDIR)$(OPENSSLDIR)/openssl.cnf
401 # A method to extract all names from a .pod file
402 # The first sed extracts everything between "=head1 NAME" and the next =head1
403 # The second sed joins all the lines into one
404 # The third sed removes the description and turns all commas into spaces
405 # Voilà , you have a space separated list of names!
406 EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
407 sed -e ':a;{N;s/\n/ /;ba}' | \
408 sed -e 's/ - .*$$//;s/,/ /g'
411 here=`cd $(SRCDIR); pwd`; \
412 point=$$here/util/point.sh; \
413 for ds in apps:1 crypto:3 ssl:3; do \
414 defdir=`echo $$ds | cut -f1 -d:`; \
415 defsec=`echo $$ds | cut -f2 -d:`; \
416 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
417 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
418 [ -z "$$SEC" ] && SEC=$$defsec; \
419 fn=`basename $$p .pod`; \
420 NAME=`echo $$fn | tr [a-z] [A-Z]`; \
421 suf=`eval "echo $$OUTSUFFIX"`; \
422 top=`eval "echo $$OUTTOP"`; \
423 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
424 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
425 cat $$p | eval "$$GENERATE" \
426 > $$top/man$$SEC/$$fn$$suf; \
427 names=`cat $$p | $(EXTRACT_NAMES)`; \
428 ( cd $$top/man$$SEC; \
429 for n in $$names; do \
432 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
433 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
434 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
437 if [ "$$comp_n" != "$$comp_fn" ]; then \
438 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
439 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
446 here=`cd $(SRCDIR); pwd`; \
447 for ds in apps:1 crypto:3 ssl:3; do \
448 defdir=`echo $$ds | cut -f1 -d:`; \
449 defsec=`echo $$ds | cut -f2 -d:`; \
450 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
451 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
452 [ -z "$$SEC" ] && SEC=$$defsec; \
453 fn=`basename $$p .pod`; \
454 suf=`eval "echo $$OUTSUFFIX"`; \
455 top=`eval "echo $$OUTTOP"`; \
456 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
457 $(RM) $$top/man$$SEC/$$fn$$suf; \
458 names=`cat $$p | $(EXTRACT_NAMES)`; \
459 for n in $$names; do \
462 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
463 comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \
464 comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \
467 if [ "$$comp_n" != "$$comp_fn" ]; then \
468 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
469 $(RM) $$top/man$$SEC/$$n$$suf; \
476 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
477 @echo "*** Installing manpages"
479 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
480 OUTTOP="$(DESTDIR)$(MANDIR)"; \
481 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
485 @echo "*** Uninstalling manpages"
487 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
488 OUTTOP="$(DESTDIR)$(MANDIR)"; \
492 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
493 @echo "*** Installing HTML manpages"
495 OUTSUFFIX='.$(HTMLSUFFIX)'; \
496 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
497 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
498 --podpath=apps:crypto:ssl \
499 | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \
503 @echo "*** Uninstalling manpages"
505 OUTSUFFIX='.$(HTMLSUFFIX)'; \
506 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
510 # Developer targets (note: these are only available on Unix) #########
512 update: generate errors ordinals
514 generate: generate_apps generate_crypto_bn generate_crypto_objects
516 # Test coverage is a good idea for the future
517 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
520 # Currently disabled, util/selftest.pl needs a rewrite
522 # SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl
525 lint -DLINT $(INCLUDES) $(SRCS)
527 generate_apps: $(SRCDIR)/apps/openssl-vms.cnf $(SRCDIR)/apps/progs.h
529 generate_crypto_bn: $(SRCDIR)/crypto/bn/bn_prime.h
531 generate_crypto_objects: $(SRCDIR)/crypto/objects/obj_dat.h \
532 $(SRCDIR)/include/openssl/obj_mac.h \
533 $(SRCDIR)/crypto/objects/obj_xref.h
536 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
537 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
538 ( cd $(SRCDIR)/engines; \
540 $(PERL) ../util/mkerr.pl -conf $$e \
541 -nostatic -staticloader -write *.c; \
543 ( cd $(SRCDIR)/crypto/ct; \
544 $(PERL) ../../util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c )
547 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
548 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
552 SRCTOP=../$(SRCDIR) \
553 BLDTOP=../$(BLDDIR) \
554 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
559 -etags `find . -name '*.[ch]' -o -name '*.pm'`
561 # Release targets (note: only available on Unix) #####################
564 TMPDIR=/var/tmp/openssl-copy.$$$$; \
565 DISTDIR=openssl-$(VERSION); \
566 mkdir -p $$TMPDIR/$$DISTDIR; \
568 git ls-tree -r --name-only --full-tree HEAD \
570 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
571 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
574 [ -n "$(PREPARE_CMD)" ] && $(PREPARE_CMD); \
575 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
576 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
577 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
578 $(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - $$DISTDIR) \
579 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
581 cd $(SRCDIR); ls -l $(TARFILE).gz
584 @$(MAKE) PREPARE_CMD='./Configure dist' tar
586 # Helper targets #####################################################
588 rehash: link-utils copy-certs build_apps_nodep
589 @if [ -z "$(CROSS_COMPILE)" ]; then \
590 (OPENSSL="$(BLDDIR)/util/shlib_wrap.sh apps/openssl"; \
591 [ -x "$(BLDDIR)/openssl.exe" ] && OPENSSL="$(BLDDIR)/openssl.exe" || :; \
592 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
593 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
594 $$OPENSSL rehash certs/demo \
595 || $(PERL) tools/c_rehash certs/demo) && \
599 link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
601 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
602 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
603 mkdir -p "$(BLDDIR)/util"; \
604 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
606 $(BLDDIR)/util/shlib_wrap.sh: configdata.pm
607 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
608 mkdir -p "$(BLDDIR)/util"; \
609 ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
613 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
614 cp -R "$(SRCDIR)/certs" "$(BLDDIR)/"; \
617 $(SRCDIR)/apps/openssl-vms.cnf: $(SRCDIR)/apps/openssl.cnf
618 $(PERL) $(SRCDIR)/VMS/VMSify-conf.pl \
619 < $(SRCDIR)/apps/openssl.cnf > $(SRCDIR)/apps/openssl-vms.cnf
621 {- # because the program apps/openssl has object files as sources, and
622 # they then have the corresponding C files as source, we need to chain
623 # the lookups in %unified_info
624 my $apps_openssl = catfile("apps","openssl");
625 our @openssl_source = map { @{$unified_info{sources}->{$_}} }
626 @{$unified_info{sources}->{$apps_openssl}};
628 $(SRCDIR)/apps/progs.h:
630 $(PERL) $(SRCDIR)/apps/progs.pl {- join(" ", @openssl_source) -} > $@
632 $(SRCDIR)/crypto/bn/bn_prime.h: $(SRCDIR)/crypto/bn/bn_prime.pl
633 $(PERL) $(SRCDIR)/crypto/bn/bn_prime.pl > $(SRCDIR)/crypto/bn/bn_prime.h
635 $(SRCDIR)/crypto/objects/obj_dat.h: $(SRCDIR)/crypto/objects/obj_dat.pl \
636 $(SRCDIR)/include/openssl/obj_mac.h
637 $(PERL) $(SRCDIR)/crypto/objects/obj_dat.pl \
638 $(SRCDIR)/include/openssl/obj_mac.h \
639 $(SRCDIR)/crypto/objects/obj_dat.h
641 # objects.pl both reads and writes obj_mac.num
642 $(SRCDIR)/include/openssl/obj_mac.h: $(SRCDIR)/crypto/objects/objects.pl \
643 $(SRCDIR)/crypto/objects/objects.txt \
644 $(SRCDIR)/crypto/objects/obj_mac.num
645 $(PERL) $(SRCDIR)/crypto/objects/objects.pl \
646 $(SRCDIR)/crypto/objects/objects.txt \
647 $(SRCDIR)/crypto/objects/obj_mac.num \
648 $(SRCDIR)/include/openssl/obj_mac.h
649 @sleep 1; touch $(SRCDIR)/include/openssl/obj_mac.h; sleep 1
651 $(SRCDIR)/crypto/objects/obj_xref.h: $(SRCDIR)/crypto/objects/objxref.pl \
652 $(SRCDIR)/crypto/objects/obj_xref.txt \
653 $(SRCDIR)/crypto/objects/obj_mac.num
654 $(PERL) $(SRCDIR)/crypto/objects/objxref.pl \
655 $(SRCDIR)/crypto/objects/obj_mac.num \
656 $(SRCDIR)/crypto/objects/obj_xref.txt \
657 > $(SRCDIR)/crypto/objects/obj_xref.h
658 @sleep 1; touch $(SRCDIR)/crypto/objects/obj_xref.h; sleep 1
662 # Building targets ###################################################
664 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS)
666 @ ( echo 'prefix=$(INSTALLTOP)'; \
667 echo 'exec_prefix=$${prefix}'; \
668 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
669 echo 'includedir=$${prefix}/include'; \
671 echo 'Name: OpenSSL-libcrypto'; \
672 echo 'Description: OpenSSL cryptography library'; \
673 echo 'Version: '$(VERSION); \
674 echo 'Libs: -L$${libdir} -lcrypto'; \
675 echo 'Libs.private: $(EX_LIBS)'; \
676 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
679 @ ( echo 'prefix=$(INSTALLTOP)'; \
680 echo 'exec_prefix=$${prefix}'; \
681 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
682 echo 'includedir=$${prefix}/include'; \
684 echo 'Name: OpenSSL-libssl'; \
685 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
686 echo 'Version: '$(VERSION); \
687 echo 'Requires.private: libcrypto'; \
688 echo 'Libs: -L$${libdir} -lssl'; \
689 echo 'Libs.private: $(EX_LIBS)'; \
690 echo 'Cflags: -I$${includedir}' ) > libssl.pc
693 @ ( echo 'prefix=$(INSTALLTOP)'; \
694 echo 'exec_prefix=$${prefix}'; \
695 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
696 echo 'includedir=$${prefix}/include'; \
698 echo 'Name: OpenSSL'; \
699 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
700 echo 'Version: '$(VERSION); \
701 echo 'Requires: libssl libcrypto' ) > openssl.pc
703 # Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which
704 # wasn't passed down automatically. It's quite safe to use it like we do
705 # below; if it doesn't exist, the result will be empty and 'make' will pick
706 # up $(MAKEFLAGS) which is passed down as an environment variable.
707 configdata.pm: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/config
708 @echo "Detected changed: $?"
709 @echo "Reconfiguring..."
710 $(SRCDIR)/Configure reconf
711 @echo "**************************************************"
713 @echo "*** Please run the same make command again ***"
715 @echo "**************************************************"
720 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
722 # Helper function to figure out dependencies on libraries
723 # It takes a list of library names and outputs a list of dependencies
724 sub compute_lib_depends {
725 if ($config{no_shared}) {
726 return map { $_."\$(LIB_EXT)" } @_;
729 # Depending on shared libraries:
730 # On Windows POSIX layers, we depend on {libname}.dll.a
731 # On Unix platforms, we depend on {shlibname}.so
732 return map { if (windowsdll()) {
733 "$_\$(SHLIB_EXT_SIMPLE).a"
736 $unified_info{sharednames}->{$_} || $_;
737 "$libname\$(SHLIB_EXT_SIMPLE)"
743 my $obj = $args{obj};
744 my $srcs = join(" ", @{$args{srcs}});
745 my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
746 my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
747 my $makedepprog = $config{makedepprog};
748 if ($makedepprog eq "makedepend") {
750 $obj\$(DEP_EXT): $deps
751 rm -f \$\@.tmp; touch \$\@.tmp
752 \$(MAKEDEPEND) -f\$\@.tmp -o"|$obj" -- \$(CFLAGS)$incs -- $srcs \\
754 sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$\$/d' -e '/^\\(#.*\\| *\\)\$\$/d' \$\@.tmp > \$\@
756 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
757 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
761 $obj\$(DEP_EXT): $deps
762 \$(CC) \$(CFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
763 $obj\$(OBJ_EXT): $obj\$(DEP_EXT)
764 \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
767 # On Unix, we build shlibs from static libs, so we're ignoring the
768 # object file array. We *know* this routine is only called when we've
769 # configure 'shared'.
772 my $lib = $args{lib};
773 my $shlib = $args{shlib};
774 my $libd = dirname($lib);
775 my $libn = basename($lib);
776 (my $libname = $libn) =~ s/^lib//;
777 my $linklibs = join("", map { my $d = dirname($_);
778 my $f = basename($_);
779 (my $l = $f) =~ s/^lib//;
780 " -L$d -l$l" } @{$args{deps}});
781 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
782 my $shlib_target = $target{shared_target};
783 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
784 my $shlibtarget = windowsdll() ?
785 "$lib\$(SHLIB_EXT_SIMPLE).a" : "$shlib\$(SHLIB_EXT_SIMPLE)";
787 # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
788 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
789 # With all other Unix platforms, we often build a shared library with the
790 # SO version built into the file name and a symlink without the SO version
791 # It's not necessary to have both as targets. The choice falls on the
792 # simplest, {libname}\$(SHLIB_EXT_SIMPLE).a for Windows POSIX layers and
793 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
794 $shlibtarget: $lib\$(LIB_EXT) $deps $ordinalsfile
795 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
796 PLATFORM=\$(PLATFORM) \\
797 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
798 INSTALLTOP="\$(INSTALLTOP)" LIBDIR="\$(LIBDIR)" \\
799 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
800 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
801 LIBCOMPATVERSIONS=";\$(SHLIB_VERSION_HISTORY)" \\
802 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
803 CROSS_COMPILE="\$(CROSS_COMPILE)" \\
804 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
805 SHARED_RCFLAGS="\$(SHARED_RCFLAGS)" \\
808 . (windowsdll() ? <<"EOF" : "");
809 rm -f apps/$shlib\$(SHLIB_EXT)
810 rm -f test/$shlib\$(SHLIB_EXT)
811 cp -p $shlib\$(SHLIB_EXT) apps/
812 cp -p $shlib\$(SHLIB_EXT) test/
817 my $lib = $args{lib};
818 my $libd = dirname($lib);
819 my $libn = basename($lib);
820 (my $libname = $libn) =~ s/^lib//;
821 my $shlibdeps = join("", map { my $d = dirname($_);
822 my $f = basename($_);
823 (my $l = $f) =~ s/^lib//;
824 " -L$d -l$l" } @{$args{deps}});
825 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
826 my $shlib_target = $target{shared_target};
827 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
829 $lib\$(SHLIB_EXT_SIMPLE): $objs $deps
830 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
831 PLATFORM=\$(PLATFORM) \\
832 PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
833 LIBDEPS="\$(PLIB_LDFLAGS) $shlibdeps \$(EX_LIBS)" \\
834 LIBNAME=$libname LDFLAGS="\$(LDFLAGS)" \\
835 CC="\$(CC)" CFLAGS="\$(CFLAGS)" \\
836 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" \\
837 SHLIB_EXT=\$(SHLIB_EXT_SIMPLE) \\
844 my $lib = $args{lib};
845 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
847 $lib\$(LIB_EXT): $objs
849 \$(RANLIB) \$\@ || echo Never mind.
854 my $bin = $args{bin};
855 my $bind = dirname($bin);
856 my $binn = basename($bin);
857 my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
858 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
859 my $linklibs = join("", map { my $d = dirname($_);
860 my $f = basename($_);
861 $d = "." if $d eq $f;
862 (my $l = $f) =~ s/^lib//;
863 " -L$d -l$l" } @{$args{deps}});
864 my $shlib_target = $config{no_shared} ? "" : $target{shared_target};
866 $bin\$(EXE_EXT): $objs $deps
867 \$(RM) $bin\$(EXE_EXT)
868 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
869 PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
870 APPNAME=$bin OBJECTS="$objs" \\
871 LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\
872 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
873 LIBRPATH="\$(INSTALLTOP)/\$(LIBDIR)" \\
874 link_app.$shlib_target
879 my $script = $args{script};
880 my $sources = join(" ", @{$args{sources}});
881 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
882 "util", "dofile.pl")),
883 rel2abs($config{builddir}));
886 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
887 "-o$target{build_file}" $sources > "$script"
891 "" # Important! This becomes part of the template result.