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 $shlibvariant = $target{shlib_variant} || "";
12 our $shlibextsimple = $target{shared_extension_simple} || ".so";
13 our $shlibextimport = $target{shared_import_extension} || "";
14 our $dsoext = $target{dso_extension} || ".so";
16 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
18 our $sover_dirname = $config{shlib_version_number};
19 $sover_dirname =~ s|\.|_|g
20 if $config{target} =~ /^mingw/;
22 # shlib and shlib_simple both take a static library name and figure
23 # out what the shlib name should be.
25 # When OpenSSL is configured "no-shared", these functions will just
26 # return empty lists, making them suitable to join().
28 # With Windows DLL producers, shlib($libname) will return the shared
29 # library name (which usually is different from the static library
30 # name) with the default shared extension appended to it, while
31 # shlib_simple($libname) will return the static library name with
32 # the shared extension followed by ".a" appended to it. The former
33 # result is used as the runtime shared library while the latter is
34 # used as the DLL import library.
36 # On all Unix systems, shlib($libname) will return the library name
37 # with the default shared extension, while shlib_simple($libname)
38 # will return the name from shlib($libname) with any SO version number
39 # removed. On some systems, they may therefore return the exact same
43 return () if $disabled{shared} || $lib =~ /\.a$/;
44 return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)';
48 return () if $disabled{shared} || $lib =~ /\.a$/;
51 return $lib . '$(SHLIB_EXT_IMPORT)';
53 return $lib . '$(SHLIB_EXT_SIMPLE)';
56 # Easy fixing of static library names
58 (my $lib = shift) =~ s/\.a$//;
59 return $lib . $libext;
62 # dso is a complement to shlib / shlib_simple that returns the
63 # given libname with the simple shared extension (possible SO version
64 # removed). This differs from shlib_simple() by being unconditional.
68 return $engine . $dsoext;
70 # This makes sure things get built in the order they need
75 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
79 PLATFORM={- $config{target} -}
80 OPTIONS={- $config{options} -}
81 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
82 SRCDIR={- $config{sourcedir} -}
83 BLDDIR={- $config{builddir} -}
85 VERSION={- $config{version} -}
86 MAJOR={- $config{major} -}
87 MINOR={- $config{minor} -}
88 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
89 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
90 SHLIB_MAJOR={- $config{shlib_major} -}
91 SHLIB_MINOR={- $config{shlib_minor} -}
92 SHLIB_TARGET={- $target{shared_target} -}
93 SHLIB_EXT={- $shlibext -}
94 SHLIB_EXT_SIMPLE={- $shlibextsimple -}
95 SHLIB_EXT_IMPORT={- $shlibextimport -}
97 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
98 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
99 SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
100 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
101 PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
102 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
103 {- output_off() if $disabled{makedepend}; "" -}
104 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
105 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
106 keys %{$unified_info{sources}}); -}
107 {- output_on() if $disabled{makedepend}; "" -}
108 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
109 GENERATED={- join(" ",
110 ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
111 grep { defined $unified_info{generate}->{$_} }
112 map { @{$unified_info{sources}->{$_}} }
113 grep { /\.o$/ } keys %{$unified_info{sources}} ),
114 ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -}
116 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
117 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
118 INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
119 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
120 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
121 {- output_off() if $disabled{apps}; "" -}
122 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
123 MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
124 {- output_on() if $disabled{apps}; "" -}
126 APPS_OPENSSL={- use File::Spec::Functions;
127 catfile("apps","openssl") -}
129 # DESTDIR is for package builders so that they can configure for, say,
130 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
131 # Normally it is left empty.
134 # Do not edit these manually. Use Configure with --prefix or --openssldir
135 # to change this! Short explanation in the top comment in Configure
136 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
138 our $prefix = $config{prefix} || "/usr/local";
141 # The logic here is that if no --openssldir was given,
142 # OPENSSLDIR will get the value from $prefix plus "/ssl".
143 # If --openssldir was given and the value is an absolute
144 # path, OPENSSLDIR will get its value without change.
145 # If the value from --openssldir is a relative path,
146 # OPENSSLDIR will get $prefix with the --openssldir
147 # value appended as a subdirectory.
149 use File::Spec::Functions;
151 $config{openssldir} ?
152 (file_name_is_absolute($config{openssldir}) ?
154 : catdir($prefix, $config{openssldir}))
155 : catdir($prefix, "ssl");
158 # if $prefix/lib$target{multilib} is not an existing
159 # directory, then assume that it's not searched by linker
160 # automatically, in which case adding $target{multilib} suffix
161 # causes more grief than we're ready to tolerate, so don't...
163 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
164 our $libdir = $config{libdir} || "lib$multilib";
166 ENGINESDIR={- use File::Spec::Functions;
167 catdir($prefix,$libdir,"engines-$sover_dirname") -}
169 # Convenience variable for those who want to set the rpath in shared
170 # libraries and applications
171 LIBRPATH=$(INSTALLTOP)/$(LIBDIR)
173 MANDIR=$(INSTALLTOP)/share/man
174 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
175 HTMLDIR=$(DOCDIR)/html
177 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
178 # appended after the manpage file section number. "ssl" is popular,
179 # resulting in files such as config.5ssl rather than config.5.
183 # For "optional" echo messages, to get "real" silence
186 CROSS_COMPILE= {- $config{cross_compile_prefix} -}
187 CPPFLAGS={- our $cppflags = join(" ",
189 @{$target{defines}}, @{$config{defines}}),
191 @{$target{includes}}, @{$config{includes}}),
192 $target{cppflags}, $config{cppflags}) -}
193 CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -}
194 CC= $(CROSS_COMPILE){- $target{cc} -}
195 CFLAGS={- $target{cflags} -} {- $config{cflags} -}
196 CXX= $(CROSS_COMPILE){- $target{cxx} -}
197 CXXFLAGS={- $target{cxxflags} -} {- $config{cxxflags} -} -std=c++11
198 LDFLAGS= {- $config{lflags} -} {- $target{lflags} -}
199 PLIB_LDFLAGS= {- $target{plib_lflags} -}
200 EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
201 LIB_CPPFLAGS={- join(" ",
203 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
204 'ENGINESDIR="\"$(ENGINESDIR)\""'),
205 $target{shared_cppflag} || "") -}
206 LIB_CFLAGS={- $target{shared_cflag} || "" -}
207 LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -}
208 LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -}
209 DSO_CPPFLAGS={- $target{dso_cppflags} || "" -}
210 DSO_CFLAGS={- $target{dso_cflags} || "" -}
211 DSO_CXXFLAGS={- $target{dso_cxxflags} || "" -}
212 DSO_LDFLAGS={- $target{dso_lflags} || "" -}
213 BIN_CPPFLAGS={- $target{bin_cppflags} || "" -}
214 BIN_CFLAGS={- $target{bin_cflags} || "" -}
215 BIN_CXXFLAGS={- $target{bin_cxxflags} || "" -}
216 BIN_LDFLAGS={- $target{bin_lflags} || "" -}
218 PERL={- $config{perl} -}
220 ARFLAGS= {- $target{arflags} -}
221 AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
222 RANLIB= {- $target{ranlib} -}
223 NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
224 RCFLAGS={- $target{shared_rcflag} -}
225 RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
228 TAR= {- $target{tar} || "tar" -}
229 TARFLAGS= {- $target{tarflags} -}
230 MAKEDEPEND={- $config{makedepprog} -}
233 NAME= $(BASENAME)-$(VERSION)
234 TARFILE= ../$(NAME).tar
236 # We let the C compiler driver to take care of .s files. This is done in
237 # order to be excused from maintaining a separate set of architecture
238 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
239 # gcc, then the driver will automatically translate it to -xarch=v8plus
240 # and pass it down to assembler.
243 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
245 # For x86 assembler: Set PROCESSOR to 386 if you want to support
247 PROCESSOR= {- $config{processor} -}
249 # We want error [and other] messages in English. Trouble is that make(1)
250 # doesn't pass macros down as environment variables unless there already
251 # was corresponding variable originally set. In other words we can only
252 # reassign environment variables, but not set new ones, not in portable
253 # manner that is. That's why we reassign several, just to be sure...
258 # The main targets ###################################################
260 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
261 {- dependmagic('build_libs'); -}: build_libs_nodep
262 {- dependmagic('build_engines'); -}: build_engines_nodep
263 {- dependmagic('build_programs'); -}: build_programs_nodep
265 build_generated: $(GENERATED_MANDATORY)
266 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
267 build_engines_nodep: $(ENGINES)
268 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
270 # Kept around for backward compatibility
271 build_apps build_tests: build_programs
273 # Convenience target to prebuild all generated files, not just the mandatory
275 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
278 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
279 @ : {- output_off() if $disabled{tests}; "" -}
281 mkdir -p test-runs; \
282 SRCTOP=../$(SRCDIR) \
283 BLDTOP=../$(BLDDIR) \
286 EXE_EXT={- $exeext -} \
287 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines; pwd` \
288 OPENSSL_DEBUG_MEMORY=on \
289 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
290 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
291 @echo "Tests are not supported with your chosen Configure options"
292 @ : {- output_on() if !$disabled{tests}; "" -}
295 @ : {- output_off() if $disabled{tests}; "" -}
296 @SRCTOP="$(SRCDIR)" \
297 $(PERL) $(SRCDIR)/test/run_tests.pl list
298 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
299 @echo "Tests are not supported with your chosen Configure options"
300 @ : {- output_on() if !$disabled{tests}; "" -}
302 install: install_sw install_ssldirs install_docs
304 uninstall: uninstall_docs uninstall_sw
307 @set -e; for s in $(SHLIB_INFO); do \
308 s1=`echo "$$s" | cut -f1 -d";"`; \
309 s2=`echo "$$s" | cut -f2 -d";"`; \
310 $(ECHO) $(RM) $$s1; \
312 if [ "$$s1" != "$$s2" ]; then \
313 $(ECHO) $(RM) $$s2; \
321 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
323 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
324 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
326 $(RM) tags TAGS doc-nits
327 $(RM) -r test/test-runs
328 $(RM) openssl.pc libcrypto.pc libssl.pc
329 -$(RM) `find . -type l -a \! -path "./.git/*"`
336 # We check if any depfile is newer than Makefile and decide to
337 # concatenate only if that is true.
339 @: {- output_off() if $disabled{makedepend}; "" -}
340 @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
341 ( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
342 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
344 for f in $(DEPS); do \
345 if [ -f $$f ]; then cat $$f; fi; \
346 done ) > Makefile.new; \
347 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
348 rm -f Makefile.new; \
350 mv -f Makefile.new Makefile; \
353 @: {- output_on() if $disabled{makedepend}; "" -}
355 # Install helper targets #############################################
357 install_sw: all install_dev install_engines install_runtime
359 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
361 install_docs: install_man_docs install_html_docs
363 uninstall_docs: uninstall_man_docs uninstall_html_docs
364 $(RM) -r -v $(DESTDIR)$(DOCDIR)
367 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
368 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
369 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
370 @set -e; for x in dummy $(MISC_SCRIPTS); do \
371 if [ "$$x" = "dummy" ]; then continue; fi; \
373 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
374 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
375 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
376 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
377 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
379 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
380 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
381 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
382 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
383 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
384 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
385 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
386 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
388 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
389 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
390 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
391 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
392 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
393 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
394 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
395 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
399 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
400 @$(ECHO) "*** Installing development files"
401 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
402 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
403 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
404 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
405 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
406 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
407 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
408 $(BLDDIR)/include/openssl/*.h; do \
410 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
411 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
412 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
414 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
415 @set -e; for l in $(INSTALL_LIBS); do \
417 $(ECHO) "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
418 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
419 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
420 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
421 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
422 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
424 @ : {- output_off() if $disabled{shared}; "" -}
425 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
426 s1=`echo "$$s" | cut -f1 -d";"`; \
427 s2=`echo "$$s" | cut -f2 -d";"`; \
428 fn1=`basename $$s1`; \
429 fn2=`basename $$s2`; \
430 : {- output_off() if windowsdll(); "" -}; \
431 $(ECHO) "install $$s1 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
432 cp $$s1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
433 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
434 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new \
435 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
436 if [ "$$fn1" != "$$fn2" ]; then \
437 $(ECHO) "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
438 ln -sf $$fn1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
440 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
441 $(ECHO) "install $$s2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
442 cp $$s2 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
443 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
444 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new \
445 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
446 : {- output_on() unless windowsdll(); "" -}; \
448 @ : {- output_on() if $disabled{shared}; "" -}
449 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
450 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
451 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
452 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
453 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
454 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
455 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
456 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
457 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
458 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
461 @$(ECHO) "*** Uninstalling development files"
462 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
463 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
464 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
465 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
466 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
467 $(BLDDIR)/include/openssl/*.h; do \
469 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
470 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
472 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
473 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
474 @set -e; for l in $(INSTALL_LIBS); do \
476 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
477 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
479 @ : {- output_off() if $disabled{shared}; "" -}
480 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
481 s1=`echo "$$s" | cut -f1 -d";"`; \
482 s2=`echo "$$s" | cut -f2 -d";"`; \
483 fn1=`basename $$s1`; \
484 fn2=`basename $$s2`; \
485 : {- output_off() if windowsdll(); "" -}; \
486 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
487 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
488 if [ "$$fn1" != "$$fn2" ]; then \
489 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
490 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
492 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
493 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
494 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
495 : {- output_on() unless windowsdll(); "" -}; \
497 @ : {- output_on() if $disabled{shared}; "" -}
498 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
499 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
500 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
501 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
502 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
505 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
506 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
507 @$(ECHO) "*** Installing engines"
508 @set -e; for e in dummy $(INSTALL_ENGINES); do \
509 if [ "$$e" = "dummy" ]; then continue; fi; \
511 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
512 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
513 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
514 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
515 $(DESTDIR)$(ENGINESDIR)/$$fn; \
519 @$(ECHO) "*** Uninstalling engines"
520 @set -e; for e in dummy $(INSTALL_ENGINES); do \
521 if [ "$$e" = "dummy" ]; then continue; fi; \
523 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
526 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
527 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
529 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
532 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
533 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
534 @ : {- output_off() if windowsdll(); "" -}
535 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
536 @ : {- output_on() if windowsdll(); "" -}
537 @$(ECHO) "*** Installing runtime files"
538 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
539 if [ "$$s" = "dummy" ]; then continue; fi; \
541 : {- output_off() unless windowsdll(); "" -}; \
542 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
543 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
544 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
545 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
546 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
547 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
548 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
549 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
550 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
551 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
552 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
553 : {- output_on() if windowsdll(); "" -}; \
555 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
556 if [ "$$x" = "dummy" ]; then continue; fi; \
558 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
559 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
560 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
561 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
562 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
564 @set -e; for x in dummy $(BIN_SCRIPTS); do \
565 if [ "$$x" = "dummy" ]; then continue; fi; \
567 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
568 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
569 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
570 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
571 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
575 @$(ECHO) "*** Uninstalling runtime files"
576 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
578 if [ "$$x" = "dummy" ]; then continue; fi; \
580 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
581 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
583 @set -e; for x in dummy $(BIN_SCRIPTS); \
585 if [ "$$x" = "dummy" ]; then continue; fi; \
587 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
588 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
590 @ : {- output_off() unless windowsdll(); "" -}
591 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
592 if [ "$$s" = "dummy" ]; then continue; fi; \
594 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
595 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
597 @ : {- output_on() unless windowsdll(); "" -}
598 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
602 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
603 @$(ECHO) "*** Installing manpages"
604 $(PERL) $(SRCDIR)/util/process_docs.pl \
605 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
608 @$(ECHO) "*** Uninstalling manpages"
609 $(PERL) $(SRCDIR)/util/process_docs.pl \
610 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
614 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
615 @$(ECHO) "*** Installing HTML manpages"
616 $(PERL) $(SRCDIR)/util/process_docs.pl \
617 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
620 @$(ECHO) "*** Uninstalling manpages"
621 $(PERL) $(SRCDIR)/util/process_docs.pl \
622 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
625 # Developer targets (note: these are only available on Unix) #########
627 update: generate errors ordinals
629 generate: generate_apps generate_crypto_bn generate_crypto_objects \
630 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
633 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
634 if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
636 # Test coverage is a good idea for the future
637 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
641 lint -DLINT $(INCLUDES) $(SRCS)
644 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
645 < apps/openssl.cnf > apps/openssl-vms.cnf )
648 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
650 generate_crypto_objects:
651 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
652 crypto/objects/objects.txt \
653 crypto/objects/obj_mac.num \
654 include/openssl/obj_mac.h )
655 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
656 include/openssl/obj_mac.h \
657 crypto/objects/obj_dat.h )
658 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
659 crypto/objects/obj_mac.num \
660 crypto/objects/obj_xref.txt \
661 > crypto/objects/obj_xref.h )
663 generate_crypto_conf:
664 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
665 > crypto/conf/conf_def.h )
667 generate_crypto_asn1:
668 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
669 > crypto/asn1/charmap.h )
672 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
673 crypto/objects/obj_dat.h \
676 # Set to -force to force a rebuild
679 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
680 ( cd $(SRCDIR); $(PERL) util/mkerr.pl $(ERROR_REBUILD) -internal )
681 ( cd $(SRCDIR)/engines; \
683 $(PERL) ../util/mkerr.pl $(ERROR_REBUILD) -static \
684 -conf $$E `basename $$E .ec`.c ; \
688 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
689 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
693 SRCTOP=../$(SRCDIR) \
694 BLDTOP=../$(BLDDIR) \
695 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
700 -etags `find . -name '*.[ch]' -o -name '*.pm'`
702 # Release targets (note: only available on Unix) #####################
704 # If your tar command doesn't support --owner and --group, make sure to
705 # use one that does, for example GNU tar
706 TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
710 TMPDIR=/var/tmp/openssl-copy.$$$$; \
712 mkdir -p $$TMPDIR/$$DISTDIR; \
714 excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
715 excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
717 git ls-tree -r --name-only --full-tree HEAD \
718 | egrep -v "$$excl_re" \
720 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
721 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
723 (cd $$TMPDIR/$$DISTDIR; \
725 find . -type d -print | xargs chmod 755; \
726 find . -type f -print | xargs chmod a+r; \
727 find . -type f -perm -0100 -print | xargs chmod a+x); \
728 (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
729 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
731 cd $(SRCDIR); ls -l $(TARFILE).gz
734 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
736 # Helper targets #####################################################
738 link-utils: $(BLDDIR)/util/opensslwrap.sh
740 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
741 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
742 mkdir -p "$(BLDDIR)/util"; \
743 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
748 # Building targets ###################################################
750 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
752 @ ( echo 'prefix=$(INSTALLTOP)'; \
753 echo 'exec_prefix=$${prefix}'; \
754 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
755 echo 'includedir=$${prefix}/include'; \
756 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
758 echo 'Name: OpenSSL-libcrypto'; \
759 echo 'Description: OpenSSL cryptography library'; \
760 echo 'Version: '$(VERSION); \
761 echo 'Libs: -L$${libdir} -lcrypto'; \
762 echo 'Libs.private: $(EX_LIBS)'; \
763 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
766 @ ( echo 'prefix=$(INSTALLTOP)'; \
767 echo 'exec_prefix=$${prefix}'; \
768 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
769 echo 'includedir=$${prefix}/include'; \
771 echo 'Name: OpenSSL-libssl'; \
772 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
773 echo 'Version: '$(VERSION); \
774 echo 'Requires.private: libcrypto'; \
775 echo 'Libs: -L$${libdir} -lssl'; \
776 echo 'Cflags: -I$${includedir}' ) > libssl.pc
779 @ ( echo 'prefix=$(INSTALLTOP)'; \
780 echo 'exec_prefix=$${prefix}'; \
781 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
782 echo 'includedir=$${prefix}/include'; \
784 echo 'Name: OpenSSL'; \
785 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
786 echo 'Version: '$(VERSION); \
787 echo 'Requires: libssl libcrypto' ) > openssl.pc
789 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
790 @echo "Detected changed: $?"
791 @echo "Reconfiguring..."
792 $(PERL) $(SRCDIR)/Configure reconf
793 @echo "**************************************************"
795 @echo "*** Please run the same make command again ***"
797 @echo "**************************************************"
802 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
804 # Helper function to figure out dependencies on libraries
805 # It takes a list of library names and outputs a list of dependencies
806 sub compute_lib_depends {
807 if ($disabled{shared}) {
808 return map { lib($_) } @_;
811 # Depending on shared libraries:
812 # On Windows POSIX layers, we depend on {libname}.dll.a
813 # On Unix platforms, we depend on {shlibname}.so
814 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
819 my $generator = join(" ", @{$args{generator}});
820 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
821 my $incs = join("", map { " -I".$_ } @{$args{incs}});
822 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
824 if ($args{src} !~ /\.[sS]$/) {
825 if ($args{generator}->[0] =~ m|^.*\.in$|) {
826 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
827 "util", "dofile.pl")),
828 rel2abs($config{builddir}));
830 $args{src}: $args{generator}->[0] $deps
831 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
832 "-o$target{build_file}" $generator > \$@
836 $args{src}: $args{generator}->[0] $deps
837 \$(PERL)$generator_incs $generator > \$@
841 if ($args{generator}->[0] =~ /\.pl$/) {
842 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
843 } elsif ($args{generator}->[0] =~ /\.m4$/) {
844 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
845 } elsif ($args{generator}->[0] =~ /\.S$/) {
848 die "Generator type for $args{src} unknown: $generator\n";
851 if (defined($generator)) {
852 # If the target is named foo.S in build.info, we want to
853 # end up generating foo.s in two steps.
854 if ($args{src} =~ /\.S$/) {
855 (my $target = $args{src}) =~ s|\.S$|.s|;
857 $target: $args{generator}->[0] $deps
858 ( trap "rm -f \$@.*" INT 0; \\
860 \$(CC) $incs \$(CFLAGS) \$(CPPFLAGS) -E \$@.S | \\
861 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
867 $args{src}: $args{generator}->[0] $deps
872 $args{src}: $args{generator}->[0] $deps
873 \$(CC) $incs \$(CFLAGS) \$(CPPFLAGS) -E $args{generator}->[0] | \\
874 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
879 # Should one wonder about the end of the Perl snippet, it's because this
880 # second regexp eats up line endings as well, if the removed path is the
881 # last in the line. We may therefore need to put back a line ending.
884 (my $obj = $args{obj}) =~ s|\.o$||;
885 my @srcs = map { if ($unified_info{generate}->{$_}) {
886 (my $x = $_) =~ s/\.S$/.s/; $x
890 } ( @{$args{srcs}} );
891 my $srcs = join(" ", @srcs);
892 my $deps = join(" ", @srcs, @{$args{deps}});
893 my $incs = join("", map { " -I".$_ } @{$args{incs}});
894 unless ($disabled{zlib}) {
895 if ($withargs{zlib_include}) {
896 $incs .= " -I".$withargs{zlib_include};
900 my $cmdflags = '$(CFLAGS)';
901 my $cmdcompile = ' -c';
902 my $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
903 if (grep /\.rc$/, @srcs) {
905 $cmdflags = '$(RCFLAGS)';
907 $makedepprog = undef;
908 } elsif (grep /\.(cc|cpp)$/, @srcs) {
910 $cmdflags = '$(CXXFLAGS)';
911 $cmdflags .= ' ' . { lib => '$(LIB_CXXFLAGS)',
912 dso => '$(DSO_CXXFLAGS)',
913 bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}};
914 $cmdflags .= ' $(CPPFLAGS)';
915 $cmdflags .= ' ' . { lib => '$(LIB_CPPFLAGS)',
916 dso => '$(DSO_CPPFLAGS)',
917 bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
919 $cmdflags .= ' ' . { lib => '$(LIB_CFLAGS)',
920 dso => '$(DSO_CFLAGS)',
921 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
922 $cmdflags .= ' $(CPPFLAGS)';
923 $cmdflags .= ' ' . { lib => '$(LIB_CPPFLAGS)',
924 dso => '$(DSO_CPPFLAGS)',
925 bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
927 $cmdflags .= $cmdcompile;
928 my $recipe = <<"EOF";
931 if (defined $makedepprog && $makedepprog !~ /\/makedepend/) {
933 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
934 \@touch $obj$depext.tmp
935 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
936 rm -f $obj$depext.tmp; \\
938 mv $obj$depext.tmp $obj$depext; \\
943 $cmd $incs $cmdflags -o \$\@ $srcs
945 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
947 -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cmdflags -- $srcs \\
948 >$obj$depext.tmp 2>/dev/null
949 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
950 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
951 rm -f $obj$depext.tmp; \\
953 mv $obj$depext.tmp $obj$depext; \\
960 # On Unix, we build shlibs from static libs, so we're ignoring the
961 # object file array. We *know* this routine is only called when we've
962 # configure 'shared'.
965 my $lib = $args{lib};
966 my $shlib = $args{shlib};
967 my $libd = dirname($lib);
968 my $libn = basename($lib);
969 (my $libname = $libn) =~ s/^lib//;
971 foreach (@{args{deps}}) {
973 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
975 my $linkflags = join("", map { "-L$_ " } @linkdirs);
976 my $linklibs = join("", map { my $f = basename($_);
977 (my $l = $f) =~ s/^lib//;
978 " -l$l" } @{$args{deps}});
979 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
980 grep { $_ =~ m|\.o$| }
982 my @defs = grep { $_ =~ /\.(def|map)$/ } @{$args{objs}};
983 my @deps = compute_lib_depends(@{$args{deps}});
984 die "More than one exported symbol map" if scalar @defs > 1;
985 my $objs = join(" ", @objs);
986 my $deps = join(" ", @objs, @defs, @deps);
987 my $target = shlib_simple($lib);
988 my $target_full = shlib($lib);
989 my $shared_soname = "";
990 $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
991 if defined $target{shared_sonameflag};
993 $shared_imp .= ' '.$target{shared_impflag}.basename($target)
994 if defined $target{shared_impflag};
995 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
996 my $recipe = <<"EOF";
997 # When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
998 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
999 # With all other Unix platforms, we often build a shared library with the
1000 # SO version built into the file name and a symlink without the SO version
1001 # It's not necessary to have both as targets. The choice falls on the
1002 # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
1003 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
1005 \$(CC) \$(CFLAGS) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1006 -o $target_full$shared_def $objs \\
1007 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
1011 rm -f apps/$shlib'\$(SHLIB_EXT)'
1012 rm -f test/$shlib'\$(SHLIB_EXT)'
1013 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
1014 cp -p $shlib'\$(SHLIB_EXT)' apps/
1015 cp -p $shlib'\$(SHLIB_EXT)' test/
1016 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1020 if [ '$target' != '$target_full' ]; then \\
1022 ln -s $target_full $target; \\
1029 my $dso = $args{lib};
1030 my $dsod = dirname($dso);
1031 my $dson = basename($dso);
1033 foreach (@{args{deps}}) {
1034 my $d = dirname($_);
1035 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1037 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1038 my $linklibs = join("", map { my $f = basename($_);
1039 (my $l = $f) =~ s/^lib//;
1040 " -l$l" } @{$args{deps}});
1041 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1042 my @deps = compute_lib_depends(@{$args{deps}});
1043 my $objs = join(" ", @objs);
1044 my $deps = join(" ", @deps);
1045 my $target = dso($dso);
1047 $target: $objs $deps
1048 \$(CC) \$(CFLAGS) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1050 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
1055 (my $lib = $args{lib}) =~ s/\.a$//;
1056 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1057 my $objs = join(" ", @objs);
1061 \$(RANLIB) \$\@ || echo Never mind.
1066 my $bin = $args{bin};
1067 my $bind = dirname($bin);
1068 my $binn = basename($bin);
1069 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$|$objext|; $x }
1071 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1073 foreach (@{args{deps}}) {
1074 next if $_ =~ /\.a$/;
1075 my $d = dirname($_);
1076 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1078 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1079 my $linklibs = join("", map { if ($_ =~ /\.a$/) {
1082 my $f = basename($_);
1083 (my $l = $f) =~ s/^lib//;
1088 my $cmdflags = '$(CFLAGS) $(BIN_CFLAGS)';
1089 if (grep /_cc\.o$/, @{$args{objs}}) {
1091 $cmdflags = '$(CXXFLAGS) $(BIN_CXXFLAGS)';
1094 $bin$exeext: $objs $deps
1096 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(LDFLAGS) \$(BIN_LDFLAGS) \\
1097 -o $bin$exeext $objs \\
1098 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
1103 my $script = $args{script};
1104 my $sources = join(" ", @{$args{sources}});
1105 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1106 "util", "dofile.pl")),
1107 rel2abs($config{builddir}));
1110 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1111 "-o$target{build_file}" $sources > "$script"
1117 my $dir = $args{dir};
1118 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1120 my %extinfo = ( dso => $dsoext,
1124 foreach my $type (("dso", "lib", "bin", "script")) {
1125 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1126 # For lib object files, we could update the library. However, it
1127 # was decided that it's enough to build the directory local object
1128 # files, so we don't need to add any actions, and the dependencies
1129 # are already taken care of.
1130 if ($type ne "lib") {
1131 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1132 if (dirname($prod) eq $dir) {
1133 push @deps, $prod.$extinfo{$type};
1135 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1141 my $deps = join(" ", @deps);
1142 my $actions = join("\n", "", @actions);
1144 $args{dir} $args{dir}/: $deps$actions
1147 "" # Important! This becomes part of the template result.