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(" ",
188 (map { "-D".$_} @{$config{defines}}),
189 (map { "-I".$_} @{$config{includes}}),
190 @{$config{cppflags}}) -}
191 CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -}
192 CC= $(CROSS_COMPILE){- $config{cc} -}
193 CFLAGS={- join(' ', @{$config{cflags}}) -}
194 CXX={- $config{cxx} ? "\$(CROSS_COMPILE)$config{cxx}" : '' -}
195 CXXFLAGS={- join(' ', @{$config{cxxflags}}) -}
196 LDFLAGS= {- join(' ', @{$config{lflags}}) -}
197 PLIB_LDFLAGS= {- join(' ', @{$config{plib_lflags}}) -}
198 EX_LIBS= {- join(' ', @{$config{ex_libs}}) -}
200 LIB_CPPFLAGS={- join(' ', '$(CPPFLAGS)',
201 $target{shared_cppflag} || (),
203 ('OPENSSLDIR="\"$(OPENSSLDIR)\""',
204 'ENGINESDIR="\"$(ENGINESDIR)\""'))) -}
205 LIB_CFLAGS={- join(' ', '$(CFLAGS)', $target{shared_cflag} || ()) -}
206 LIB_CXXFLAGS={- join(' ', '$(CXXFLAGS)', $target{shared_cxxflag} || ()) -}
207 LIB_LDFLAGS={- join(' ', '$(LDFLAGS)', $target{shared_ldflag} || (), $config{shared_ldflag} || ()) -}
208 DSO_CPPFLAGS={- join(' ', '$(CPPFLAGS)', $target{dso_cppflags} || ()) -}
209 DSO_CFLAGS={- join(' ', '$(CFLAGS)', $target{dso_cflags} || ()) -}
210 DSO_CXXFLAGS={- join(' ', '$(CXXFLAGS)', $target{dso_cxxflags} || ()) -}
211 DSO_LDFLAGS={- join(' ', '$(LDFLAGS)', $target{dso_lflags} || ()) -}
212 BIN_CPPFLAGS={- join(' ', '$(CPPFLAGS)', $target{bin_cppflags} || ()) -}
213 BIN_CFLAGS={- join(' ', '$(CFLAGS)', $target{bin_cflags} || ()) -}
214 BIN_CXXFLAGS={- join(' ', '$(CXXFLAGS)', $target{bin_cxxflags} || ()) -}
215 BIN_LDFLAGS={- join(' ', '$(LDFLAGS)', $target{bin_lflags} || ()) -}
217 PERL={- $config{perl} -}
219 AR=$(CROSS_COMPILE){- $config{ar} -}
220 ARFLAGS= {- join(' ', @{$config{arflags}}) -}
221 RANLIB={- $config{ranlib} ? "\$(CROSS_COMPILE)$config{ranlib}" : "true"; -}
222 RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
223 RCFLAGS={- join(' ', @{$config{rcflags}}) -} {- $target{shared_rcflag} -}
226 TAR= {- $target{tar} || "tar" -}
227 TARFLAGS= {- $target{tarflags} -}
228 MAKEDEPEND={- $config{makedepprog} -}
231 NAME= $(BASENAME)-$(VERSION)
232 TARFILE= ../$(NAME).tar
234 # We let the C compiler driver to take care of .s files. This is done in
235 # order to be excused from maintaining a separate set of architecture
236 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
237 # gcc, then the driver will automatically translate it to -xarch=v8plus
238 # and pass it down to assembler.
239 AS={- $config{as} ? "\$(CROSS_COMPILE)$config{as}" : '$(CC) -c' -}
240 ASFLAGS={- join(' ', @{$config{asflags}}) || '$(CFLAGS)' -}
241 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
243 # For x86 assembler: Set PROCESSOR to 386 if you want to support
245 PROCESSOR= {- $config{processor} -}
247 # We want error [and other] messages in English. Trouble is that make(1)
248 # doesn't pass macros down as environment variables unless there already
249 # was corresponding variable originally set. In other words we can only
250 # reassign environment variables, but not set new ones, not in portable
251 # manner that is. That's why we reassign several, just to be sure...
256 # The main targets ###################################################
258 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
259 {- dependmagic('build_libs'); -}: build_libs_nodep
260 {- dependmagic('build_engines'); -}: build_engines_nodep
261 {- dependmagic('build_programs'); -}: build_programs_nodep
263 build_generated: $(GENERATED_MANDATORY)
264 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
265 build_engines_nodep: $(ENGINES)
266 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
268 # Kept around for backward compatibility
269 build_apps build_tests: build_programs
271 # Convenience target to prebuild all generated files, not just the mandatory
273 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
276 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
277 @ : {- output_off() if $disabled{tests}; "" -}
279 mkdir -p test-runs; \
280 SRCTOP=../$(SRCDIR) \
281 BLDTOP=../$(BLDDIR) \
284 EXE_EXT={- $exeext -} \
285 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines; pwd` \
286 OPENSSL_DEBUG_MEMORY=on \
287 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
288 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
289 @echo "Tests are not supported with your chosen Configure options"
290 @ : {- output_on() if !$disabled{tests}; "" -}
293 @ : {- output_off() if $disabled{tests}; "" -}
294 @SRCTOP="$(SRCDIR)" \
295 $(PERL) $(SRCDIR)/test/run_tests.pl list
296 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
297 @echo "Tests are not supported with your chosen Configure options"
298 @ : {- output_on() if !$disabled{tests}; "" -}
300 install: install_sw install_ssldirs install_docs
302 uninstall: uninstall_docs uninstall_sw
305 @set -e; for s in $(SHLIB_INFO); do \
306 s1=`echo "$$s" | cut -f1 -d";"`; \
307 s2=`echo "$$s" | cut -f2 -d";"`; \
308 $(ECHO) $(RM) $$s1; \
310 if [ "$$s1" != "$$s2" ]; then \
311 $(ECHO) $(RM) $$s2; \
319 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
321 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
322 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
324 $(RM) tags TAGS doc-nits
325 $(RM) -r test/test-runs
326 $(RM) openssl.pc libcrypto.pc libssl.pc
327 -$(RM) `find . -type l -a \! -path "./.git/*"`
334 # We check if any depfile is newer than Makefile and decide to
335 # concatenate only if that is true.
337 @: {- output_off() if $disabled{makedepend}; "" -}
338 @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
339 ( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
340 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
342 for f in $(DEPS); do \
343 if [ -f $$f ]; then cat $$f; fi; \
344 done ) > Makefile.new; \
345 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
346 rm -f Makefile.new; \
348 mv -f Makefile.new Makefile; \
351 @: {- output_on() if $disabled{makedepend}; "" -}
353 # Install helper targets #############################################
355 install_sw: all install_dev install_engines install_runtime
357 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
359 install_docs: install_man_docs install_html_docs
361 uninstall_docs: uninstall_man_docs uninstall_html_docs
362 $(RM) -r -v $(DESTDIR)$(DOCDIR)
365 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
366 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
367 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
368 @set -e; for x in dummy $(MISC_SCRIPTS); do \
369 if [ "$$x" = "dummy" ]; then continue; fi; \
371 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
372 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
373 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
374 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
375 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
377 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
378 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
379 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
380 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
381 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
382 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
383 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
384 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
386 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
387 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
388 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
389 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
390 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
391 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
392 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
393 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
397 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
398 @$(ECHO) "*** Installing development files"
399 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
400 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
401 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
402 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
403 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
404 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
405 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
406 $(BLDDIR)/include/openssl/*.h; do \
408 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
409 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
410 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
412 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
413 @set -e; for l in $(INSTALL_LIBS); do \
415 $(ECHO) "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
416 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
417 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
418 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
419 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
420 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
422 @ : {- output_off() if $disabled{shared}; "" -}
423 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
424 s1=`echo "$$s" | cut -f1 -d";"`; \
425 s2=`echo "$$s" | cut -f2 -d";"`; \
426 fn1=`basename $$s1`; \
427 fn2=`basename $$s2`; \
428 : {- output_off() if windowsdll(); "" -}; \
429 $(ECHO) "install $$s1 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
430 cp $$s1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
431 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
432 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new \
433 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
434 if [ "$$fn1" != "$$fn2" ]; then \
435 $(ECHO) "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
436 ln -sf $$fn1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
438 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
439 $(ECHO) "install $$s2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
440 cp $$s2 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
441 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
442 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new \
443 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
444 : {- output_on() unless windowsdll(); "" -}; \
446 @ : {- output_on() if $disabled{shared}; "" -}
447 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
448 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
449 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
450 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
451 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
452 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
453 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
454 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
455 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
456 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
459 @$(ECHO) "*** Uninstalling development files"
460 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
461 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
462 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
463 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
464 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
465 $(BLDDIR)/include/openssl/*.h; do \
467 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
468 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
470 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
471 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
472 @set -e; for l in $(INSTALL_LIBS); do \
474 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
475 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
477 @ : {- output_off() if $disabled{shared}; "" -}
478 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
479 s1=`echo "$$s" | cut -f1 -d";"`; \
480 s2=`echo "$$s" | cut -f2 -d";"`; \
481 fn1=`basename $$s1`; \
482 fn2=`basename $$s2`; \
483 : {- output_off() if windowsdll(); "" -}; \
484 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
485 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
486 if [ "$$fn1" != "$$fn2" ]; then \
487 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
488 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
490 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
491 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
492 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
493 : {- output_on() unless windowsdll(); "" -}; \
495 @ : {- output_on() if $disabled{shared}; "" -}
496 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
497 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
498 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
499 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
500 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
503 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
504 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
505 @$(ECHO) "*** Installing engines"
506 @set -e; for e in dummy $(INSTALL_ENGINES); do \
507 if [ "$$e" = "dummy" ]; then continue; fi; \
509 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
510 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
511 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
512 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
513 $(DESTDIR)$(ENGINESDIR)/$$fn; \
517 @$(ECHO) "*** Uninstalling engines"
518 @set -e; for e in dummy $(INSTALL_ENGINES); do \
519 if [ "$$e" = "dummy" ]; then continue; fi; \
521 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
524 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
525 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
527 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
530 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
531 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
532 @ : {- output_off() if windowsdll(); "" -}
533 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
534 @ : {- output_on() if windowsdll(); "" -}
535 @$(ECHO) "*** Installing runtime files"
536 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
537 if [ "$$s" = "dummy" ]; then continue; fi; \
539 : {- output_off() unless windowsdll(); "" -}; \
540 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
541 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
542 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
543 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
544 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
545 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
546 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
547 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
548 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
549 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
550 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
551 : {- output_on() if windowsdll(); "" -}; \
553 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
554 if [ "$$x" = "dummy" ]; then continue; fi; \
556 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
557 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
558 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
559 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
560 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
562 @set -e; for x in dummy $(BIN_SCRIPTS); do \
563 if [ "$$x" = "dummy" ]; then continue; fi; \
565 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
566 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
567 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
568 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
569 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
573 @$(ECHO) "*** Uninstalling runtime files"
574 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
576 if [ "$$x" = "dummy" ]; then continue; fi; \
578 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
579 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
581 @set -e; for x in dummy $(BIN_SCRIPTS); \
583 if [ "$$x" = "dummy" ]; then continue; fi; \
585 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
586 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
588 @ : {- output_off() unless windowsdll(); "" -}
589 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
590 if [ "$$s" = "dummy" ]; then continue; fi; \
592 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
593 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
595 @ : {- output_on() unless windowsdll(); "" -}
596 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
600 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
601 @$(ECHO) "*** Installing manpages"
602 $(PERL) $(SRCDIR)/util/process_docs.pl \
603 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
606 @$(ECHO) "*** Uninstalling manpages"
607 $(PERL) $(SRCDIR)/util/process_docs.pl \
608 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
612 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
613 @$(ECHO) "*** Installing HTML manpages"
614 $(PERL) $(SRCDIR)/util/process_docs.pl \
615 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
618 @$(ECHO) "*** Uninstalling manpages"
619 $(PERL) $(SRCDIR)/util/process_docs.pl \
620 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
623 # Developer targets (note: these are only available on Unix) #########
625 update: generate errors ordinals
627 generate: generate_apps generate_crypto_bn generate_crypto_objects \
628 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
631 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
632 if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
634 # Test coverage is a good idea for the future
635 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
639 lint -DLINT $(INCLUDES) $(SRCS)
642 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
643 < apps/openssl.cnf > apps/openssl-vms.cnf )
646 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
648 generate_crypto_objects:
649 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
650 crypto/objects/objects.txt \
651 crypto/objects/obj_mac.num \
652 include/openssl/obj_mac.h )
653 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
654 include/openssl/obj_mac.h \
655 crypto/objects/obj_dat.h )
656 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
657 crypto/objects/obj_mac.num \
658 crypto/objects/obj_xref.txt \
659 > crypto/objects/obj_xref.h )
661 generate_crypto_conf:
662 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
663 > crypto/conf/conf_def.h )
665 generate_crypto_asn1:
666 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
667 > crypto/asn1/charmap.h )
670 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
671 crypto/objects/obj_dat.h \
674 # Set to -force to force a rebuild
677 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
678 ( b=`pwd`; cd $(SRCDIR); \
679 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
680 ( b=`pwd`; cd $(SRCDIR)/engines; \
682 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
683 -conf $$E `basename $$E .ec`.c ; \
687 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
688 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
692 SRCTOP=../$(SRCDIR) \
693 BLDTOP=../$(BLDDIR) \
694 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
699 -etags `find . -name '*.[ch]' -o -name '*.pm'`
701 # Release targets (note: only available on Unix) #####################
703 # If your tar command doesn't support --owner and --group, make sure to
704 # use one that does, for example GNU tar
705 TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
709 TMPDIR=/var/tmp/openssl-copy.$$$$; \
711 mkdir -p $$TMPDIR/$$DISTDIR; \
713 excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
714 excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
716 git ls-tree -r --name-only --full-tree HEAD \
717 | egrep -v "$$excl_re" \
719 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
720 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
722 (cd $$TMPDIR/$$DISTDIR; \
724 find . -type d -print | xargs chmod 755; \
725 find . -type f -print | xargs chmod a+r; \
726 find . -type f -perm -0100 -print | xargs chmod a+x); \
727 (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
728 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
730 cd $(SRCDIR); ls -l $(TARFILE).gz
733 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
735 # Helper targets #####################################################
737 link-utils: $(BLDDIR)/util/opensslwrap.sh
739 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
740 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
741 mkdir -p "$(BLDDIR)/util"; \
742 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
747 # Building targets ###################################################
749 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
751 @ ( echo 'prefix=$(INSTALLTOP)'; \
752 echo 'exec_prefix=$${prefix}'; \
753 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
754 echo 'includedir=$${prefix}/include'; \
755 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
757 echo 'Name: OpenSSL-libcrypto'; \
758 echo 'Description: OpenSSL cryptography library'; \
759 echo 'Version: '$(VERSION); \
760 echo 'Libs: -L$${libdir} -lcrypto'; \
761 echo 'Libs.private: $(EX_LIBS)'; \
762 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
765 @ ( echo 'prefix=$(INSTALLTOP)'; \
766 echo 'exec_prefix=$${prefix}'; \
767 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
768 echo 'includedir=$${prefix}/include'; \
770 echo 'Name: OpenSSL-libssl'; \
771 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
772 echo 'Version: '$(VERSION); \
773 echo 'Requires.private: libcrypto'; \
774 echo 'Libs: -L$${libdir} -lssl'; \
775 echo 'Cflags: -I$${includedir}' ) > libssl.pc
778 @ ( echo 'prefix=$(INSTALLTOP)'; \
779 echo 'exec_prefix=$${prefix}'; \
780 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
781 echo 'includedir=$${prefix}/include'; \
783 echo 'Name: OpenSSL'; \
784 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
785 echo 'Version: '$(VERSION); \
786 echo 'Requires: libssl libcrypto' ) > openssl.pc
788 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
789 @echo "Detected changed: $?"
790 $(PERL) configdata.pm -r -v
791 @echo "**************************************************"
793 @echo "*** Please run the same make command again ***"
795 @echo "**************************************************"
799 $(PERL) configdata.pm -r -v
803 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
805 # Helper function to figure out dependencies on libraries
806 # It takes a list of library names and outputs a list of dependencies
807 sub compute_lib_depends {
808 if ($disabled{shared}) {
809 return map { lib($_) } @_;
812 # Depending on shared libraries:
813 # On Windows POSIX layers, we depend on {libname}.dll.a
814 # On Unix platforms, we depend on {shlibname}.so
815 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
820 my $generator = join(" ", @{$args{generator}});
821 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
822 my $incs = join("", map { " -I".$_ } @{$args{incs}});
823 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
825 if ($args{src} !~ /\.[sS]$/) {
826 if ($args{generator}->[0] =~ m|^.*\.in$|) {
827 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
828 "util", "dofile.pl")),
829 rel2abs($config{builddir}));
831 $args{src}: $args{generator}->[0] $deps
832 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
833 "-o$target{build_file}" $generator > \$@
837 $args{src}: $args{generator}->[0] $deps
838 \$(PERL)$generator_incs $generator > \$@
842 if ($args{generator}->[0] =~ /\.pl$/) {
843 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
844 } elsif ($args{generator}->[0] =~ /\.m4$/) {
845 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
846 } elsif ($args{generator}->[0] =~ /\.S$/) {
849 die "Generator type for $args{src} unknown: $generator\n";
853 lib => '$(LIB_CPPFLAGS)',
854 dso => '$(DSO_CPPFLAGS)',
855 bin => '$(BIN_CPPFLAGS)'
856 } -> {$args{intent}};
857 if (defined($generator)) {
858 # If the target is named foo.S in build.info, we want to
859 # end up generating foo.s in two steps.
860 if ($args{src} =~ /\.S$/) {
861 (my $target = $args{src}) =~ s|\.S$|.s|;
863 $target: $args{generator}->[0] $deps
864 ( trap "rm -f \$@.*" INT 0; \\
866 \$(CPP) $incs $cppflags \$@.S | \\
867 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
873 $args{src}: $args{generator}->[0] $deps
878 $args{src}: $args{generator}->[0] $deps
879 \$(CPP) $incs $cppflags $args{generator}->[0] | \\
880 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
885 # Should one wonder about the end of the Perl snippet, it's because this
886 # second regexp eats up line endings as well, if the removed path is the
887 # last in the line. We may therefore need to put back a line ending.
890 (my $obj = $args{obj}) =~ s|\.o$||;
891 my @srcs = map { if ($unified_info{generate}->{$_}) {
892 (my $x = $_) =~ s/\.S$/.s/; $x
896 } ( @{$args{srcs}} );
897 my $srcs = join(" ", @srcs);
898 my $deps = join(" ", @srcs, @{$args{deps}});
899 my $incs = join("", map { " -I".$_ } @{$args{incs}});
903 my $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
904 if (grep /\.rc$/, @srcs) {
906 $cmdflags = '$(RCFLAGS)';
908 $makedepprog = undef;
909 } elsif (grep /\.(cc|cpp)$/, @srcs) {
913 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
914 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
915 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
916 } -> {$args{intent}};
921 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
922 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
923 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
924 } -> {$args{intent}};
926 $cmdflags .= $cmdcompile;
927 my $recipe = <<"EOF";
930 if (defined $makedepprog && $makedepprog !~ /\/makedepend/) {
932 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
933 \@touch $obj$depext.tmp
934 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
935 rm -f $obj$depext.tmp; \\
937 mv $obj$depext.tmp $obj$depext; \\
942 $cmd $incs $cmdflags -o \$\@ $srcs
944 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
946 -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cmdflags -- $srcs \\
947 >$obj$depext.tmp 2>/dev/null
948 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
949 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
950 rm -f $obj$depext.tmp; \\
952 mv $obj$depext.tmp $obj$depext; \\
959 # On Unix, we build shlibs from static libs, so we're ignoring the
960 # object file array. We *know* this routine is only called when we've
961 # configure 'shared'.
964 my $lib = $args{lib};
965 my $shlib = $args{shlib};
966 my $libd = dirname($lib);
967 my $libn = basename($lib);
968 (my $libname = $libn) =~ s/^lib//;
970 foreach (@{args{deps}}) {
972 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
974 my $linkflags = join("", map { "-L$_ " } @linkdirs);
975 my $linklibs = join("", map { my $f = basename($_);
976 (my $l = $f) =~ s/^lib//;
977 " -l$l" } @{$args{deps}});
978 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
979 grep { $_ =~ m|\.o$| }
981 my @defs = grep { $_ =~ /\.(def|map)$/ } @{$args{objs}};
982 my @deps = compute_lib_depends(@{$args{deps}});
983 die "More than one exported symbol map" if scalar @defs > 1;
984 my $objs = join(" ", @objs);
985 my $deps = join(" ", @objs, @defs, @deps);
986 my $target = shlib_simple($lib);
987 my $target_full = shlib($lib);
988 my $shared_soname = "";
989 $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
990 if defined $target{shared_sonameflag};
992 $shared_imp .= ' '.$target{shared_impflag}.basename($target)
993 if defined $target{shared_impflag};
994 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
995 my $recipe = <<"EOF";
996 # When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
997 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
998 # With all other Unix platforms, we often build a shared library with the
999 # SO version built into the file name and a symlink without the SO version
1000 # It's not necessary to have both as targets. The choice falls on the
1001 # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
1002 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
1004 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1005 -o $target_full$shared_def $objs \\
1006 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
1010 rm -f apps/$shlib'\$(SHLIB_EXT)'
1011 rm -f test/$shlib'\$(SHLIB_EXT)'
1012 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
1013 cp -p $shlib'\$(SHLIB_EXT)' apps/
1014 cp -p $shlib'\$(SHLIB_EXT)' test/
1015 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1019 if [ '$target' != '$target_full' ]; then \\
1021 ln -s $target_full $target; \\
1028 my $dso = $args{lib};
1029 my $dsod = dirname($dso);
1030 my $dson = basename($dso);
1032 foreach (@{args{deps}}) {
1033 my $d = dirname($_);
1034 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1036 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1037 my $linklibs = join("", map { my $f = basename($_);
1038 (my $l = $f) =~ s/^lib//;
1039 " -l$l" } @{$args{deps}});
1040 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1041 my @deps = compute_lib_depends(@{$args{deps}});
1042 my $objs = join(" ", @objs);
1043 my $deps = join(" ", @deps);
1044 my $target = dso($dso);
1046 $target: $objs $deps
1047 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1049 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
1054 (my $lib = $args{lib}) =~ s/\.a$//;
1055 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1056 my $objs = join(" ", @objs);
1059 \$(AR) \$(ARFLAGS) \$\@ \$\?
1060 \$(RANLIB) \$\@ || echo Never mind.
1065 my $bin = $args{bin};
1066 my $bind = dirname($bin);
1067 my $binn = basename($bin);
1068 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$|$objext|; $x }
1070 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1072 foreach (@{args{deps}}) {
1073 next if $_ =~ /\.a$/;
1074 my $d = dirname($_);
1075 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1077 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1078 my $linklibs = join("", map { if ($_ =~ /\.a$/) {
1081 my $f = basename($_);
1082 (my $l = $f) =~ s/^lib//;
1087 my $cmdflags = '$(BIN_CFLAGS)';
1088 if (grep /_cc\.o$/, @{$args{objs}}) {
1090 $cmdflags = '$(BIN_CXXFLAGS)';
1093 $bin$exeext: $objs $deps
1095 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1096 -o $bin$exeext $objs \\
1097 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
1102 my $script = $args{script};
1103 my $sources = join(" ", @{$args{sources}});
1104 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1105 "util", "dofile.pl")),
1106 rel2abs($config{builddir}));
1109 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1110 "-o$target{build_file}" $sources > "$script"
1116 my $dir = $args{dir};
1117 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1119 my %extinfo = ( dso => $dsoext,
1123 foreach my $type (("dso", "lib", "bin", "script")) {
1124 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1125 # For lib object files, we could update the library. However, it
1126 # was decided that it's enough to build the directory local object
1127 # files, so we don't need to add any actions, and the dependencies
1128 # are already taken care of.
1129 if ($type ne "lib") {
1130 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1131 if (dirname($prod) eq $dir) {
1132 push @deps, $prod.$extinfo{$type};
1134 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1140 my $deps = join(" ", @deps);
1141 my $actions = join("\n", "", @actions);
1143 $args{dir} $args{dir}/: $deps$actions
1146 "" # Important! This becomes part of the template result.