2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 our $objext = $target{obj_extension} || ".o";
7 our $depext = $target{dep_extension} || ".d";
8 our $exeext = $target{exe_extension} || "";
9 our $libext = $target{lib_extension} || ".a";
10 our $shlibext = $target{shared_extension} || ".so";
11 our $shlibextsimple = $target{shared_extension_simple} || ".so";
12 our $shlibextimport = $target{shared_import_extension} || "";
13 our $dsoext = $target{dso_extension} || ".so";
15 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
17 our $sover = $config{target} =~ /^mingw/
18 ? $config{shlib_major}."_".$config{shlib_minor}
19 : $config{shlib_major}.".".$config{shlib_minor};
21 # shlib and shlib_simple both take a static library name and figure
22 # out what the shlib name should be.
24 # When OpenSSL is configured "no-shared", these functions will just
25 # return empty lists, making them suitable to join().
27 # With Windows DLL producers, shlib($libname) will return the shared
28 # library name (which usually is different from the static library
29 # name) with the default shared extension appended to it, while
30 # shlib_simple($libname) will return the static library name with
31 # the shared extension followed by ".a" appended to it. The former
32 # result is used as the runtime shared library while the latter is
33 # used as the DLL import library.
35 # On all Unix systems, shlib($libname) will return the library name
36 # with the default shared extension, while shlib_simple($libname)
37 # will return the name from shlib($libname) with any SO version number
38 # removed. On some systems, they may therefore return the exact same
41 return () if $disabled{shared};
43 return $unified_info{sharednames}->{$lib} . $shlibext;
46 return () if $disabled{shared};
50 return $lib . $shlibextimport;
52 return $lib . $shlibextsimple;
55 # dso is a complement to shlib / shlib_simple that returns the
56 # given libname with the simple shared extension (possible SO version
57 # removed). This differs from shlib_simple() by being unconditional.
61 return $engine . $dsoext;
63 # This makes sure things get built in the order they need
68 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
72 PLATFORM={- $config{target} -}
73 OPTIONS={- $config{options} -}
74 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
75 SRCDIR={- $config{sourcedir} -}
76 BLDDIR={- $config{builddir} -}
78 VERSION={- $config{version} -}
79 MAJOR={- $config{major} -}
80 MINOR={- $config{minor} -}
81 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
82 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
83 SHLIB_MAJOR={- $config{shlib_major} -}
84 SHLIB_MINOR={- $config{shlib_minor} -}
85 SHLIB_TARGET={- $target{shared_target} -}
87 LIBS={- join(" ", map { $_.$libext } @{$unified_info{libraries}}) -}
88 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
89 SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
90 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
91 PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
92 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
93 {- output_off() if $disabled{makedepend}; "" -}
94 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
95 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
96 keys %{$unified_info{sources}}); -}
97 {- output_on() if $disabled{makedepend}; "" -}
98 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
99 GENERATED={- join(" ",
100 ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
101 grep { defined $unified_info{generate}->{$_} }
102 map { @{$unified_info{sources}->{$_}} }
103 grep { /\.o$/ } keys %{$unified_info{sources}} ),
104 ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -}
106 INSTALL_LIBS={- join(" ", map { $_.$libext } @{$unified_info{install}->{libraries}}) -}
107 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
108 INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
109 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
110 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
111 {- output_off() if $disabled{apps}; "" -}
112 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
113 MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
114 {- output_on() if $disabled{apps}; "" -}
116 # DESTDIR is for package builders so that they can configure for, say,
117 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
118 # Normally it is left empty.
121 # Do not edit these manually. Use Configure with --prefix or --openssldir
122 # to change this! Short explanation in the top comment in Configure
123 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
125 our $prefix = $config{prefix} || "/usr/local";
128 # The logic here is that if no --openssldir was given,
129 # OPENSSLDIR will get the value from $prefix plus "/ssl".
130 # If --openssldir was given and the value is an absolute
131 # path, OPENSSLDIR will get its value without change.
132 # If the value from --openssldir is a relative path,
133 # OPENSSLDIR will get $prefix with the --openssldir
134 # value appended as a subdirectory.
136 use File::Spec::Functions;
138 $config{openssldir} ?
139 (file_name_is_absolute($config{openssldir}) ?
141 : catdir($prefix, $config{openssldir}))
142 : catdir($prefix, "ssl");
145 # if $prefix/lib$target{multilib} is not an existing
146 # directory, then assume that it's not searched by linker
147 # automatically, in which case adding $target{multilib} suffix
148 # causes more grief than we're ready to tolerate, so don't...
150 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
151 our $libdir = $config{libdir} || "lib$multilib";
153 ENGINESDIR={- use File::Spec::Functions;
154 catdir($prefix,$libdir,"engines-$sover") -}
156 MANDIR=$(INSTALLTOP)/share/man
157 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
158 HTMLDIR=$(DOCDIR)/html
160 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
161 # appended after the manpage file section number. "ssl" is popular,
162 # resulting in files such as config.5ssl rather than config.5.
168 CROSS_COMPILE= {- $config{cross_compile_prefix} -}
169 CC= $(CROSS_COMPILE){- $target{cc} -}
170 CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -}
171 CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
172 CXX= $(CROSS_COMPILE){- $target{cxx} -}
173 CXXFLAGS={- our $cxxflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cxxflags} -} {- $config{cxxflags} -}
174 LDFLAGS= {- $target{lflags} -}
175 PLIB_LDFLAGS= {- $target{plib_lflags} -}
176 EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
177 LIB_CFLAGS={- $target{shared_cflag} || "" -}
178 LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -}
179 LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag}
180 # Unlike other OSes (like Solaris, Linux, Tru64,
181 # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
182 # and FreeBSD) "demand" RPATH set on .so objects.
183 # Apparently application RPATH is not global and
184 # does not apply to .so linked with other .so.
185 # Problem manifests itself when libssl.so fails to
186 # load libcrypto.so. One can argue that we should
187 # engrave this into Makefile.shared rules or into
188 # BSD-* config lines above. Meanwhile let's try to
189 # be cautious and pass -rpath to linker only when
190 # $prefix is not /usr.
191 . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
192 ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
193 DSO_CFLAGS={- $target{shared_cflag} || "" -}
194 DSO_CXXFLAGS={- $target{shared_cxxflag} || "" -}
195 DSO_LDFLAGS=$(LIB_LDFLAGS)
196 BIN_CFLAGS={- $target{bin_cflags} -}
197 BIN_CXXFLAGS={- $target{bin_cxxflag} || "" -}
199 PERL={- $config{perl} -}
201 ARFLAGS= {- $target{arflags} -}
202 AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
203 RANLIB= {- $target{ranlib} -}
204 NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
205 RCFLAGS={- $target{shared_rcflag} -}
206 RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
209 TAR= {- $target{tar} || "tar" -}
210 TARFLAGS= {- $target{tarflags} -}
211 MAKEDEPEND={- $config{makedepprog} -}
214 NAME= $(BASENAME)-$(VERSION)
215 TARFILE= ../$(NAME).tar
217 # We let the C compiler driver to take care of .s files. This is done in
218 # order to be excused from maintaining a separate set of architecture
219 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
220 # gcc, then the driver will automatically translate it to -xarch=v8plus
221 # and pass it down to assembler.
224 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
226 # For x86 assembler: Set PROCESSOR to 386 if you want to support
228 PROCESSOR= {- $config{processor} -}
230 # We want error [and other] messages in English. Trouble is that make(1)
231 # doesn't pass macros down as environment variables unless there already
232 # was corresponding variable originally set. In other words we can only
233 # reassign environment variables, but not set new ones, not in portable
234 # manner that is. That's why we reassign several, just to be sure...
239 # The main targets ###################################################
241 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
242 {- dependmagic('build_libs'); -}: build_libs_nodep
243 {- dependmagic('build_engines'); -}: build_engines_nodep
244 {- dependmagic('build_programs'); -}: build_programs_nodep
246 build_generated: $(GENERATED_MANDATORY)
247 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
248 build_engines_nodep: $(ENGINES)
249 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
251 # Kept around for backward compatibility
252 build_apps build_tests: build_programs
255 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
256 @ : {- output_off() if $disabled{tests}; "" -}
258 SRCTOP=../$(SRCDIR) \
259 BLDTOP=../$(BLDDIR) \
261 EXE_EXT={- $exeext -} \
262 OPENSSL_ENGINES=../$(BLDDIR)/engines \
263 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
264 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
265 @echo "Tests are not supported with your chosen Configure options"
266 @ : {- output_on() if !$disabled{tests}; "" -}
269 @ : {- output_off() if $disabled{tests}; "" -}
270 @SRCTOP="$(SRCDIR)" \
271 $(PERL) $(SRCDIR)/test/run_tests.pl list
272 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
273 @echo "Tests are not supported with your chosen Configure options"
274 @ : {- output_on() if !$disabled{tests}; "" -}
276 install: install_sw install_ssldirs install_docs
278 uninstall: uninstall_docs uninstall_sw
281 @set -e; for s in $(SHLIB_INFO); do \
282 s1=`echo "$$s" | cut -f1 -d";"`; \
283 s2=`echo "$$s" | cut -f2 -d";"`; \
286 if [ "$$s1" != "$$s2" ]; then \
295 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
297 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
298 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
301 $(RM) openssl.pc libcrypto.pc libssl.pc
302 -$(RM) `find . -type l -a \! -path "./.git/*"`
309 # We check if any depfile is newer than Makefile and decide to
310 # concatenate only if that is true.
312 @: {- output_off() if $disabled{makedepend}; "" -}
313 @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
314 ( sed -e '/^# DO NOT DELETE THIS LINE.*/,$$d' < Makefile; \
315 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
317 for f in $(DEPS); do \
318 if [ -f $$f ]; then cat $$f; fi; \
319 done ) > Makefile.new; \
320 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
321 rm -f Makefile.new; \
323 mv -f Makefile.new Makefile; \
326 @: {- output_on() if $disabled{makedepend}; "" -}
328 # Install helper targets #############################################
330 install_sw: all install_dev install_engines install_runtime
332 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
334 install_docs: install_man_docs install_html_docs
336 uninstall_docs: uninstall_man_docs uninstall_html_docs
337 $(RM) -r -v $(DESTDIR)$(DOCDIR)
340 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
341 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
342 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
343 @set -e; for x in dummy $(MISC_SCRIPTS); do \
344 if [ "$$x" = "dummy" ]; then continue; fi; \
346 echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
347 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
348 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
349 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
350 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
352 @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
353 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
354 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
355 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
356 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
357 echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
358 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
359 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
361 @echo "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
362 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
363 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
364 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
365 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
366 echo "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
367 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
368 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
372 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
373 @echo "*** Installing development files"
374 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
375 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
376 @echo "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
377 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
378 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
379 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
380 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
381 $(BLDDIR)/include/openssl/*.h; do \
383 echo "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
384 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
385 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
387 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
388 @set -e; for l in $(INSTALL_LIBS); do \
390 echo "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
391 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
392 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
393 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
394 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
395 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
397 @ : {- output_off() if $disabled{shared}; "" -}
398 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
399 s1=`echo "$$s" | cut -f1 -d";"`; \
400 s2=`echo "$$s" | cut -f2 -d";"`; \
401 fn1=`basename $$s1`; \
402 fn2=`basename $$s2`; \
403 : {- output_off() if windowsdll(); "" -}; \
404 echo "install $$s1 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
405 cp $$s1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
406 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
407 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new \
408 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
409 if [ "$$fn1" != "$$fn2" ]; then \
410 echo "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
411 ln -sf $$fn1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
413 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
414 echo "install $$s2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
415 cp $$s2 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
416 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
417 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new \
418 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
419 : {- output_on() unless windowsdll(); "" -}; \
421 @ : {- output_on() if $disabled{shared}; "" -}
422 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
423 @echo "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
424 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
425 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
426 @echo "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
427 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
428 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
429 @echo "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
430 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
431 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
434 @echo "*** Uninstalling development files"
435 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
436 @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
437 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
438 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
439 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
440 $(BLDDIR)/include/openssl/*.h; do \
442 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
443 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
445 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
446 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
447 @set -e; for l in $(INSTALL_LIBS); do \
449 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
450 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
452 @ : {- output_off() if $disabled{shared}; "" -}
453 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
454 s1=`echo "$$s" | cut -f1 -d";"`; \
455 s2=`echo "$$s" | cut -f2 -d";"`; \
456 fn1=`basename $$s1`; \
457 fn2=`basename $$s2`; \
458 : {- output_off() if windowsdll(); "" -}; \
459 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
460 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
461 if [ "$$fn1" != "$$fn2" ]; then \
462 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
463 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
465 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
466 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
467 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
468 : {- output_on() unless windowsdll(); "" -}; \
470 @ : {- output_on() if $disabled{shared}; "" -}
471 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
472 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
473 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
474 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
475 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
478 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
479 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
480 @echo "*** Installing engines"
481 @set -e; for e in dummy $(INSTALL_ENGINES); do \
482 if [ "$$e" = "dummy" ]; then continue; fi; \
484 echo "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
485 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
486 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
487 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
488 $(DESTDIR)$(ENGINESDIR)/$$fn; \
492 @echo "*** Uninstalling engines"
493 @set -e; for e in dummy $(INSTALL_ENGINES); do \
494 if [ "$$e" = "dummy" ]; then continue; fi; \
496 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
499 echo "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
500 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
502 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
505 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
506 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
507 @ : {- output_off() if windowsdll(); "" -}
508 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
509 @ : {- output_on() if windowsdll(); "" -}
510 @echo "*** Installing runtime files"
511 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
512 if [ "$$s" = "dummy" ]; then continue; fi; \
514 : {- output_off() unless windowsdll(); "" -}; \
515 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
516 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
517 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
518 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
519 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
520 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
521 echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
522 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
523 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
524 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
525 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
526 : {- output_on() if windowsdll(); "" -}; \
528 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
529 if [ "$$x" = "dummy" ]; then continue; fi; \
531 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
532 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
533 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
534 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
535 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
537 @set -e; for x in dummy $(BIN_SCRIPTS); do \
538 if [ "$$x" = "dummy" ]; then continue; fi; \
540 echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
541 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
542 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
543 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
544 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
548 @echo "*** Uninstalling runtime files"
549 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
551 if [ "$$x" = "dummy" ]; then continue; fi; \
553 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
554 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
556 @set -e; for x in dummy $(BIN_SCRIPTS); \
558 if [ "$$x" = "dummy" ]; then continue; fi; \
560 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
561 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
563 @ : {- output_off() unless windowsdll(); "" -}
564 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
565 if [ "$$s" = "dummy" ]; then continue; fi; \
567 echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
568 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
570 @ : {- output_on() unless windowsdll(); "" -}
571 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
573 # A method to extract all names from a .pod file
574 # The first sed extracts everything between "=head1 NAME" and the next =head1
575 # The perl command joins all the lines into one
576 # The second sed removes the description and turns all commas into spaces
577 # Voilà , you have a space separated list of names!
578 EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \
579 $(PERL) -p -0 -e 's/\n/ /g; END {print "\n"}' | \
580 sed -e 's/ - .*$$//;s/,/ /g'
583 here=`cd $(SRCDIR); pwd`; \
584 point=$$here/util/point.sh; \
585 for ds in apps:1 crypto:3 ssl:3; do \
586 defdir=`echo $$ds | cut -f1 -d:`; \
587 defsec=`echo $$ds | cut -f2 -d:`; \
588 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
589 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
590 [ -z "$$SEC" ] && SEC=$$defsec; \
591 fn=`basename $$p .pod`; \
593 NAME=`echo $$fn | tr '[a-z]' '[A-Z]'`; \
594 suf=`eval "echo $$OUTSUFFIX"`; \
595 top=`eval "echo $$OUTTOP"`; \
596 $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \
597 echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \
598 cat $$p | eval "$$GENERATE" \
599 > $$top/man$$SEC/$$fn$$suf; \
600 names=`cat $$p | $(EXTRACT_NAMES)`; \
601 ( cd $$top/man$$SEC; \
602 for n in $$names; do \
605 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
606 comp_n=`echo "$$n" | tr '[A-Z]' '[a-z]'`; \
607 comp_fn=`echo "$$fn" | tr '[A-Z]' '[a-z]'`; \
610 if [ "$$comp_n" != "$$comp_fn" ]; then \
611 echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \
612 PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \
619 here=`cd $(SRCDIR); pwd`; \
620 for ds in apps:1 crypto:3 ssl:3; do \
621 defdir=`echo $$ds | cut -f1 -d:`; \
622 defsec=`echo $$ds | cut -f2 -d:`; \
623 for p in $(SRCDIR)/doc/$$defdir/*.pod; do \
624 SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \
625 [ -z "$$SEC" ] && SEC=$$defsec; \
626 fn=`basename $$p .pod`; \
627 suf=`eval "echo $$OUTSUFFIX"`; \
628 top=`eval "echo $$OUTTOP"`; \
629 echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \
630 $(RM) $$top/man$$SEC/$$fn$$suf; \
631 names=`cat $$p | $(EXTRACT_NAMES)`; \
632 for n in $$names; do \
635 case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
636 comp_n=`echo "$$n" | tr '[A-Z]' '[a-z]'`; \
637 comp_fn=`echo "$$fn" | tr '[A-Z]' '[a-z]'`; \
640 if [ "$$comp_n" != "$$comp_fn" ]; then \
641 echo "$(RM) $$top/man$$SEC/$$n$$suf"; \
642 $(RM) $$top/man$$SEC/$$n$$suf; \
645 ( $(RMDIR) $$top/man$$SEC 2>/dev/null || exit 0 ); \
650 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
651 @echo "*** Installing manpages"
653 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
654 OUTTOP="$(DESTDIR)$(MANDIR)"; \
655 GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \
659 @echo "*** Uninstalling manpages"
661 OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \
662 OUTTOP="$(DESTDIR)$(MANDIR)"; \
666 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
667 @echo "*** Installing HTML manpages"
669 OUTSUFFIX='.$(HTMLSUFFIX)'; \
670 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
671 GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \
672 --podpath=apps:crypto:ssl --title=\$$Name \
673 | perl -pe 's|href=\"http://man.he.net/man|href=\"../man|g; s|href=\"(.*/man.*)(?<!\.html)\">|href=\"\$$1.html\">|g;'"; \
677 @echo "*** Uninstalling manpages"
679 OUTSUFFIX='.$(HTMLSUFFIX)'; \
680 OUTTOP="$(DESTDIR)$(HTMLDIR)"; \
684 # Developer targets (note: these are only available on Unix) #########
686 update: generate errors ordinals
688 generate: generate_apps generate_crypto_bn generate_crypto_objects \
689 generate_crypto_conf generate_crypto_asn1
691 # Test coverage is a good idea for the future
692 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
696 lint -DLINT $(INCLUDES) $(SRCS)
698 {- # because the program apps/openssl has object files as sources, and
699 # they then have the corresponding C files as source, we need to chain
700 # the lookups in %unified_info
701 my $apps_openssl = catfile("apps","openssl");
702 our @openssl_source = map { @{$unified_info{sources}->{$_}} }
703 @{$unified_info{sources}->{$apps_openssl}};
706 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
707 < apps/openssl.cnf > apps/openssl-vms.cnf )
708 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b apps/progs.pl \
709 {- join(" ", @openssl_source) -} \
713 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
715 generate_crypto_objects:
716 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
717 crypto/objects/objects.txt \
718 crypto/objects/obj_mac.num \
719 include/openssl/obj_mac.h )
720 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
721 include/openssl/obj_mac.h \
722 crypto/objects/obj_dat.h )
723 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
724 crypto/objects/obj_mac.num \
725 crypto/objects/obj_xref.txt \
726 > crypto/objects/obj_xref.h )
728 generate_crypto_conf:
729 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
730 > crypto/conf/conf_def.h )
732 generate_crypto_asn1:
733 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
734 > crypto/asn1/charmap.h )
737 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
738 ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write )
739 ( cd $(SRCDIR)/engines; \
741 $(PERL) ../util/mkerr.pl -conf $$e \
742 -nostatic -staticloader -write *.c; \
746 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
747 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
751 SRCTOP=../$(SRCDIR) \
752 BLDTOP=../$(BLDDIR) \
753 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
758 -etags `find . -name '*.[ch]' -o -name '*.pm'`
760 # Release targets (note: only available on Unix) #####################
762 TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
765 TMPDIR=/var/tmp/openssl-copy.$$$$; \
767 mkdir -p $$TMPDIR/$$DISTDIR; \
769 git ls-tree -r --name-only --full-tree HEAD \
770 | grep -v '^fuzz/corpora' \
772 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
773 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
777 find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \
778 find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \
779 find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \
780 $(TAR_COMMAND) $$DISTDIR) \
781 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
783 cd $(SRCDIR); ls -l $(TARFILE).gz
786 @$(MAKE) PREPARE_CMD='./Configure dist' tar
788 # Helper targets #####################################################
790 link-utils: $(BLDDIR)/util/opensslwrap.sh
792 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
793 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
794 mkdir -p "$(BLDDIR)/util"; \
795 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
800 # Building targets ###################################################
802 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
804 @ ( echo 'prefix=$(INSTALLTOP)'; \
805 echo 'exec_prefix=$${prefix}'; \
806 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
807 echo 'includedir=$${prefix}/include'; \
808 echo 'enginesdir=$${libdir}/engines-{- $sover -}'; \
810 echo 'Name: OpenSSL-libcrypto'; \
811 echo 'Description: OpenSSL cryptography library'; \
812 echo 'Version: '$(VERSION); \
813 echo 'Libs: -L$${libdir} -lcrypto'; \
814 echo 'Libs.private: $(EX_LIBS)'; \
815 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
818 @ ( echo 'prefix=$(INSTALLTOP)'; \
819 echo 'exec_prefix=$${prefix}'; \
820 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
821 echo 'includedir=$${prefix}/include'; \
823 echo 'Name: OpenSSL-libssl'; \
824 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
825 echo 'Version: '$(VERSION); \
826 echo 'Requires.private: libcrypto'; \
827 echo 'Libs: -L$${libdir} -lssl'; \
828 echo 'Libs.private: $(EX_LIBS)'; \
829 echo 'Cflags: -I$${includedir}' ) > libssl.pc
832 @ ( echo 'prefix=$(INSTALLTOP)'; \
833 echo 'exec_prefix=$${prefix}'; \
834 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
835 echo 'includedir=$${prefix}/include'; \
837 echo 'Name: OpenSSL'; \
838 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
839 echo 'Version: '$(VERSION); \
840 echo 'Requires: libssl libcrypto' ) > openssl.pc
842 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
843 @echo "Detected changed: $?"
844 @echo "Reconfiguring..."
845 $(SRCDIR)/Configure reconf
846 @echo "**************************************************"
848 @echo "*** Please run the same make command again ***"
850 @echo "**************************************************"
855 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
857 # Helper function to figure out dependencies on libraries
858 # It takes a list of library names and outputs a list of dependencies
859 sub compute_lib_depends {
860 if ($disabled{shared}) {
861 return map { $_.$libext } @_;
864 # Depending on shared libraries:
865 # On Windows POSIX layers, we depend on {libname}.dll.a
866 # On Unix platforms, we depend on {shlibname}.so
867 return map { shlib_simple($_) } @_;
872 my $generator = join(" ", @{$args{generator}});
873 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
874 my $incs = join("", map { " -I".$_ } @{$args{incs}});
875 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
877 if ($args{src} !~ /\.[sS]$/) {
878 if ($args{generator}->[0] =~ m|^.*\.in$|) {
879 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
880 "util", "dofile.pl")),
881 rel2abs($config{builddir}));
883 $args{src}: $args{generator}->[0] $deps
884 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
885 "-o$target{build_file}" $generator > \$@
889 $args{src}: $args{generator}->[0] $deps
890 \$(PERL)$generator_incs $generator > \$@
894 if ($args{generator}->[0] =~ /\.pl$/) {
895 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
896 } elsif ($args{generator}->[0] =~ /\.m4$/) {
897 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
898 } elsif ($args{generator}->[0] =~ /\.S$/) {
901 die "Generator type for $args{src} unknown: $generator\n";
904 if (defined($generator)) {
905 # If the target is named foo.S in build.info, we want to
906 # end up generating foo.s in two steps.
907 if ($args{src} =~ /\.S$/) {
908 (my $target = $args{src}) =~ s|\.S$|.s|;
910 $target: $args{generator}->[0] $deps
911 ( trap "rm -f \$@.*" INT 0; \\
913 \$(CC) $incs \$(CFLAGS) -E \$@.S | \\
914 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
920 $args{src}: $args{generator}->[0] $deps
925 $args{src}: $args{generator}->[0] $deps
926 \$(CC) $incs \$(CFLAGS) -E \$< | \\
927 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
932 # Should one wonder about the end of the Perl snippet, it's because this
933 # second regexp eats up line endings as well, if the removed path is the
934 # last in the line. We may therefore need to put back a line ending.
937 my $obj = $args{obj};
938 my @srcs = map { if ($unified_info{generate}->{$_}) {
939 (my $x = $_) =~ s/\.S$/.s/; $x
943 } ( @{$args{srcs}} );
944 my $srcs = join(" ", @srcs);
945 my $deps = join(" ", @srcs, @{$args{deps}});
946 my $incs = join("", map { " -I".$_ } @{$args{incs}});
947 unless ($disabled{zlib}) {
948 if ($withargs{zlib_include}) {
949 $incs .= " -I".$withargs{zlib_include};
953 my $cflags = '$(CFLAGS)';
954 if (grep /\.(cc|cpp)$/, @srcs) {
956 $cflags = '$(CXXFLAGS)';
957 $cflags .= ' ' . { lib => '$(LIB_CXXFLAGS)',
958 dso => '$(DSO_CXXFLAGS)',
959 bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}};
961 $cflags .= ' ' . { lib => '$(LIB_CFLAGS)',
962 dso => '$(DSO_CFLAGS)',
963 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
965 my $makedepprog = $config{makedepprog};
966 my $recipe = <<"EOF";
969 if (!$disabled{makedepend} && $makedepprog !~ /\/makedepend/) {
971 $cc $incs $cflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
972 \@touch $obj$depext.tmp
973 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
974 rm -f $obj$depext.tmp; \\
976 mv $obj$depext.tmp $obj$depext; \\
981 $cc $incs $cflags -c -o \$\@ $srcs
983 if (!$disabled{makedepend} && $makedepprog =~ /\/makedepend/) {
985 -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cflags -- $srcs \\
986 >$obj$depext.tmp 2>/dev/null
987 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
988 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
989 rm -f $obj$depext.tmp; \\
991 mv $obj$depext.tmp $obj$depext; \\
998 # On Unix, we build shlibs from static libs, so we're ignoring the
999 # object file array. We *know* this routine is only called when we've
1000 # configure 'shared'.
1003 my $lib = $args{lib};
1004 my $shlib = $args{shlib};
1005 my $libd = dirname($lib);
1006 my $libn = basename($lib);
1007 (my $libname = $libn) =~ s/^lib//;
1008 my $linklibs = join("", map { my $d = dirname($_);
1009 my $f = basename($_);
1010 (my $l = $f) =~ s/^lib//;
1011 " -L$d -l$l" } @{$args{deps}});
1012 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1013 my $shlib_target = $target{shared_target};
1014 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
1015 my $target = shlib_simple($lib);
1017 # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
1018 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
1019 # With all other Unix platforms, we often build a shared library with the
1020 # SO version built into the file name and a symlink without the SO version
1021 # It's not necessary to have both as targets. The choice falls on the
1022 # simplest, {libname}$shlibextimport for Windows POSIX layers and
1023 # {libname}$shlibextsimple for the Unix platforms.
1024 $target: $lib$libext $deps $ordinalsfile
1025 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
1026 PLATFORM=\$(PLATFORM) \\
1027 PERL="\$(PERL)" SRCDIR='\$(SRCDIR)' DSTDIR="$libd" \\
1028 INSTALLTOP='\$(INSTALLTOP)' LIBDIR='\$(LIBDIR)' \\
1029 LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
1030 LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\
1031 LIBCOMPATVERSIONS=';\$(SHLIB_VERSION_HISTORY)' \\
1032 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(LIB_CFLAGS)' \\
1033 LDFLAGS='\$(LDFLAGS)' \\
1034 SHARED_LDFLAGS='\$(LIB_LDFLAGS)' SHLIB_EXT=$shlibext \\
1035 RC='\$(RC)' SHARED_RCFLAGS='\$(RCFLAGS)' \\
1036 link_shlib.$shlib_target
1038 . (windowsdll() ? <<"EOF" : "");
1039 rm -f apps/$shlib$shlibext
1040 rm -f test/$shlib$shlibext
1041 cp -p $shlib$shlibext apps/
1042 cp -p $shlib$shlibext test/
1047 my $lib = $args{lib};
1048 my $libd = dirname($lib);
1049 my $libn = basename($lib);
1050 (my $libname = $libn) =~ s/^lib//;
1051 my $shlibdeps = join("", map { my $d = dirname($_);
1052 my $f = basename($_);
1053 (my $l = $f) =~ s/^lib//;
1054 " -L$d -l$l" } @{$args{deps}});
1055 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1056 my $shlib_target = $target{shared_target};
1057 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
1058 my $target = dso($lib);
1060 $target: $objs $deps
1061 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
1062 PLATFORM=\$(PLATFORM) \\
1063 PERL="\$(PERL)" SRCDIR='\$(SRCDIR)' DSTDIR="$libd" \\
1064 LIBDEPS='\$(PLIB_LDFLAGS) '"$shlibdeps"' \$(EX_LIBS)' \\
1065 LIBNAME=$libname LDFLAGS='\$(LDFLAGS)' \\
1066 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(DSO_CFLAGS)' \\
1067 SHARED_LDFLAGS='\$(DSO_LDFLAGS)' \\
1068 SHLIB_EXT=$dsoext \\
1069 LIBEXTRAS="$objs" \\
1070 link_dso.$shlib_target
1075 my $lib = $args{lib};
1076 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
1080 \$(RANLIB) \$\@ || echo Never mind.
1085 my $bin = $args{bin};
1086 my $bind = dirname($bin);
1087 my $binn = basename($bin);
1088 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
1089 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1090 my $linklibs = join("", map { my $d = dirname($_);
1091 my $f = basename($_);
1092 $d = "." if $d eq $f;
1093 (my $l = $f) =~ s/^lib//;
1094 " -L$d -l$l" } @{$args{deps}});
1095 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
1097 my $cflags = '$(CFLAGS) $(BIN_CFLAGS)';
1098 if (grep /_cc$/, @{$args{objs}}) {
1100 $cflags = '$(CXXFLAGS) $(BIN_CXXFLAGS)';
1103 $bin$exeext: $objs $deps
1105 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
1106 PERL="\$(PERL)" SRCDIR=\$(SRCDIR) \\
1107 APPNAME=$bin$exeext OBJECTS="$objs" \\
1108 LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
1109 CC='$cc' CFLAGS='$cflags' \\
1110 LDFLAGS='\$(LDFLAGS)' LIBRPATH='\$(INSTALLTOP)/\$(LIBDIR)' \\
1111 link_app.$shlib_target
1116 my $script = $args{script};
1117 my $sources = join(" ", @{$args{sources}});
1118 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1119 "util", "dofile.pl")),
1120 rel2abs($config{builddir}));
1123 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1124 "-o$target{build_file}" $sources > "$script"
1130 my $dir = $args{dir};
1131 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1133 my %extinfo = ( dso => $dsoext,
1137 foreach my $type (("dso", "lib", "bin", "script")) {
1138 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1139 # For lib object files, we could update the library. However, it
1140 # was decided that it's enough to build the directory local object
1141 # files, so we don't need to add any actions, and the dependencies
1142 # are already taken care of.
1143 if ($type ne "lib") {
1144 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1145 if (dirname($prod) eq $dir) {
1146 push @deps, $prod.$extinfo{$type};
1148 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1154 my $deps = join(" ", @deps);
1155 my $actions = join("\n", "", @actions);
1157 $args{dir} $args{dir}/: $deps$actions
1160 "" # Important! This becomes part of the template result.