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");
157 LIBDIR={- our $libdir = $config{libdir};
160 # if $prefix/lib$target{multilib} is not an existing
161 # directory, then assume that it's not searched by linker
162 # automatically, in which case adding $target{multilib} suffix
163 # causes more grief than we're ready to tolerate, so don't...
165 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
166 $libdir = "lib$multilib";
168 file_name_is_absolute($libdir) ? "" : $libdir -}
169 # $(libdir) is chosen to be compatible with the GNU coding standards
170 libdir={- file_name_is_absolute($libdir)
171 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
172 ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
174 # Convenience variable for those who want to set the rpath in shared
175 # libraries and applications
178 MANDIR=$(INSTALLTOP)/share/man
179 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
180 HTMLDIR=$(DOCDIR)/html
182 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
183 # appended after the manpage file section number. "ssl" is popular,
184 # resulting in files such as config.5ssl rather than config.5.
188 # For "optional" echo messages, to get "real" silence
191 ##### User defined commands and flags ################################
193 # We let the C compiler driver to take care of .s files. This is done in
194 # order to be excused from maintaining a separate set of architecture
195 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
196 # gcc, then the driver will automatically translate it to -xarch=v8plus
197 # and pass it down to assembler. In any case, we do not define AS or
198 # ASFLAGS for this reason.
200 CROSS_COMPILE={- $config{CROSS_COMPILE} -}
201 CC=$(CROSS_COMPILE){- $config{CC} -}
202 CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
203 CPPFLAGS={- our $cppflags1 = join(" ",
204 (map { "-D".$_} @{$config{CPPDEFINES}}),
205 (map { "-I".$_} @{$config{CPPINCLUDES}}),
206 @{$config{CPPFLAGS}}) -}
207 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
208 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
209 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
210 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
212 MAKEDEPEND={- $config{makedepprog} -}
214 PERL={- $config{perl} -}
216 AR=$(CROSS_COMPILE){- $config{AR} -}
217 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
218 RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
219 RC= $(CROSS_COMPILE){- $config{RC} -}
220 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
224 TAR= {- $target{TAR} || "tar" -}
225 TARFLAGS= {- $target{TARFLAGS} -}
228 NAME= $(BASENAME)-$(VERSION)
229 TARFILE= ../$(NAME).tar
231 ##### Project flags ##################################################
233 # Variables starting with CNF_ are common variables for all product types
235 CNF_CPPFLAGS={- our $cppflags2 =
236 join(' ', $target{cppflags} || (),
237 (map { "-D".$_} @{$target{defines}},
238 @{$config{defines}}),
239 (map { "-I".$_} @{$target{includes}},
240 @{$config{includes}}),
241 @{$config{cppflags}}) -}
242 CNF_CFLAGS={- join(' ', $target{cflags} || (),
243 @{$config{cflags}}) -}
244 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
245 @{$config{cxxflags}}) -}
246 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
247 @{$config{lflags}}) -}
248 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
249 @{$config{ex_libs}}) -}
251 # Variables starting with LIB_ are used to build library object files
252 # and shared libraries.
253 # Variables starting with DSO_ are used to build DSOs and their object files.
254 # Variables starting with BIN_ are used to build programs and their object
257 LIB_CPPFLAGS={- join(' ', $target{lib_cppflags} || (),
258 $target{shared_cppflag} || (),
260 @{$config{lib_defines}},
261 @{$config{shared_defines}},
262 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
263 'ENGINESDIR="\"$(ENGINESDIR)\""'),
264 @{$config{lib_cppflags}},
265 @{$config{shared_cppflag}},
266 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
267 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
268 $target{shared_cflag} || (),
269 @{$config{lib_cflags}},
270 @{$config{shared_cflag}},
271 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
272 LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
273 $target{shared_cxxflag} || (),
274 @{$config{lib_cxxflags}},
275 @{$config{shared_cxxflag}},
276 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
277 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
278 $config{shared_ldflag} || (),
279 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
280 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
281 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
282 $target{module_cppflags} || (),
283 @{$config{dso_cppflags}},
284 @{$config{module_cppflags}},
285 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
286 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
287 $target{module_cflags} || (),
288 @{$config{dso_cflags}},
289 @{$config{module_cflags}},
290 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
291 DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
292 $target{module_cxxflags} || (),
293 @{$config{dso_cxxflags}},
294 @{$config{module_cxxflag}},
295 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
296 DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
297 $target{module_ldflags} || (),
298 @{$config{dso_ldflags}},
299 @{$config{module_ldflags}},
300 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
301 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
302 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
303 @{$config{bin_cppflags}},
304 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
305 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
306 @{$config{bin_cflags}},
307 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
308 BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
309 @{$config{bin_cxxflags}},
310 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
311 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
312 @{$config{bin_lflags}},
313 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
314 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
316 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
317 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
318 $cppflags2 =~ s|([\\"])|\\$1|g;
319 join(' ', $cppflags1 || (), $cppflags2 || ()) -}
321 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
323 # For x86 assembler: Set PROCESSOR to 386 if you want to support
325 PROCESSOR= {- $config{processor} -}
327 # We want error [and other] messages in English. Trouble is that make(1)
328 # doesn't pass macros down as environment variables unless there already
329 # was corresponding variable originally set. In other words we can only
330 # reassign environment variables, but not set new ones, not in portable
331 # manner that is. That's why we reassign several, just to be sure...
336 # The main targets ###################################################
338 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
339 {- dependmagic('build_libs'); -}: build_libs_nodep
340 {- dependmagic('build_engines'); -}: build_engines_nodep
341 {- dependmagic('build_programs'); -}: build_programs_nodep
343 build_generated: $(GENERATED_MANDATORY)
344 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
345 build_engines_nodep: $(ENGINES)
346 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
348 # Kept around for backward compatibility
349 build_apps build_tests: build_programs
351 # Convenience target to prebuild all generated files, not just the mandatory
353 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
356 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
357 @ : {- output_off() if $disabled{tests}; "" -}
359 mkdir -p test-runs; \
360 SRCTOP=../$(SRCDIR) \
361 BLDTOP=../$(BLDDIR) \
364 EXE_EXT={- $exeext -} \
365 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines; pwd` \
366 OPENSSL_DEBUG_MEMORY=on \
367 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
368 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
369 @echo "Tests are not supported with your chosen Configure options"
370 @ : {- output_on() if !$disabled{tests}; "" -}
373 @ : {- output_off() if $disabled{tests}; "" -}
374 @SRCTOP="$(SRCDIR)" \
375 $(PERL) $(SRCDIR)/test/run_tests.pl list
376 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
377 @echo "Tests are not supported with your chosen Configure options"
378 @ : {- output_on() if !$disabled{tests}; "" -}
380 install: install_sw install_ssldirs install_docs
382 uninstall: uninstall_docs uninstall_sw
385 @set -e; for s in $(SHLIB_INFO); do \
386 s1=`echo "$$s" | cut -f1 -d";"`; \
387 s2=`echo "$$s" | cut -f2 -d";"`; \
388 $(ECHO) $(RM) $$s1; \
390 if [ "$$s1" != "$$s2" ]; then \
391 $(ECHO) $(RM) $$s2; \
399 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
401 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
402 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
404 $(RM) tags TAGS doc-nits
405 $(RM) -r test/test-runs
406 $(RM) openssl.pc libcrypto.pc libssl.pc
407 -$(RM) `find . -type l -a \! -path "./.git/*"`
414 # We check if any depfile is newer than Makefile and decide to
415 # concatenate only if that is true.
417 @: {- output_off() if $disabled{makedepend}; "" -}
418 @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
419 ( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
420 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
422 for f in $(DEPS); do \
423 if [ -f $$f ]; then cat $$f; fi; \
424 done ) > Makefile.new; \
425 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
426 rm -f Makefile.new; \
428 mv -f Makefile.new Makefile; \
431 @: {- output_on() if $disabled{makedepend}; "" -}
433 # Install helper targets #############################################
435 install_sw: all install_dev install_engines install_runtime
437 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
439 install_docs: install_man_docs install_html_docs
441 uninstall_docs: uninstall_man_docs uninstall_html_docs
442 $(RM) -r -v $(DESTDIR)$(DOCDIR)
445 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
446 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
447 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
448 @set -e; for x in dummy $(MISC_SCRIPTS); do \
449 if [ "$$x" = "dummy" ]; then continue; fi; \
451 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
452 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
453 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
454 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
455 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
457 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
458 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
459 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
460 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
461 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
462 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
463 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
464 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
466 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
467 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
468 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
469 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
470 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
471 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
472 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
473 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
477 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
478 @$(ECHO) "*** Installing development files"
479 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
480 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
481 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
482 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
483 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
484 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
485 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
486 $(BLDDIR)/include/openssl/*.h; do \
488 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
489 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
490 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
492 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
493 @set -e; for l in $(INSTALL_LIBS); do \
495 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
496 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
497 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
498 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
499 mv -f $(DESTDIR)$(libdir)/$$fn.new \
500 $(DESTDIR)$(libdir)/$$fn; \
502 @ : {- output_off() if $disabled{shared}; "" -}
503 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
504 s1=`echo "$$s" | cut -f1 -d";"`; \
505 s2=`echo "$$s" | cut -f2 -d";"`; \
506 fn1=`basename $$s1`; \
507 fn2=`basename $$s2`; \
508 : {- output_off() if windowsdll(); "" -}; \
509 $(ECHO) "install $$s1 -> $(DESTDIR)$(libdir)/$$fn1"; \
510 cp $$s1 $(DESTDIR)$(libdir)/$$fn1.new; \
511 chmod 755 $(DESTDIR)$(libdir)/$$fn1.new; \
512 mv -f $(DESTDIR)$(libdir)/$$fn1.new \
513 $(DESTDIR)$(libdir)/$$fn1; \
514 if [ "$$fn1" != "$$fn2" ]; then \
515 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
516 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
518 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
519 $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
520 cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
521 chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
522 mv -f $(DESTDIR)$(libdir)/$$fn2.new \
523 $(DESTDIR)$(libdir)/$$fn2; \
524 : {- output_on() unless windowsdll(); "" -}; \
526 @ : {- output_on() if $disabled{shared}; "" -}
527 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
528 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
529 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
530 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
531 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
532 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
533 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
534 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
535 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
536 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
539 @$(ECHO) "*** Uninstalling development files"
540 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
541 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
542 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
543 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
544 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
545 $(BLDDIR)/include/openssl/*.h; do \
547 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
548 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
550 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
551 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
552 @set -e; for l in $(INSTALL_LIBS); do \
554 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
555 $(RM) $(DESTDIR)$(libdir)/$$fn; \
557 @ : {- output_off() if $disabled{shared}; "" -}
558 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
559 s1=`echo "$$s" | cut -f1 -d";"`; \
560 s2=`echo "$$s" | cut -f2 -d";"`; \
561 fn1=`basename $$s1`; \
562 fn2=`basename $$s2`; \
563 : {- output_off() if windowsdll(); "" -}; \
564 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
565 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
566 if [ "$$fn1" != "$$fn2" ]; then \
567 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
568 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
570 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
571 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
572 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
573 : {- output_on() unless windowsdll(); "" -}; \
575 @ : {- output_on() if $disabled{shared}; "" -}
576 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
577 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
578 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
579 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
580 -$(RMDIR) $(DESTDIR)$(libdir)
583 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
584 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
585 @$(ECHO) "*** Installing engines"
586 @set -e; for e in dummy $(INSTALL_ENGINES); do \
587 if [ "$$e" = "dummy" ]; then continue; fi; \
589 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
590 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
591 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
592 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
593 $(DESTDIR)$(ENGINESDIR)/$$fn; \
597 @$(ECHO) "*** Uninstalling engines"
598 @set -e; for e in dummy $(INSTALL_ENGINES); do \
599 if [ "$$e" = "dummy" ]; then continue; fi; \
601 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
604 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
605 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
607 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
610 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
611 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
612 @ : {- output_off() if windowsdll(); "" -}
613 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
614 @ : {- output_on() if windowsdll(); "" -}
615 @$(ECHO) "*** Installing runtime files"
616 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
617 if [ "$$s" = "dummy" ]; then continue; fi; \
619 : {- output_off() unless windowsdll(); "" -}; \
620 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
621 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
622 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
623 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
624 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
625 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
626 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
627 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
628 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
629 mv -f $(DESTDIR)$(libdir)/$$fn.new \
630 $(DESTDIR)$(libdir)/$$fn; \
631 : {- output_on() if windowsdll(); "" -}; \
633 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
634 if [ "$$x" = "dummy" ]; then continue; fi; \
636 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
637 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
638 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
639 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
640 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
642 @set -e; for x in dummy $(BIN_SCRIPTS); do \
643 if [ "$$x" = "dummy" ]; then continue; fi; \
645 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
646 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
647 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
648 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
649 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
653 @$(ECHO) "*** Uninstalling runtime files"
654 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
656 if [ "$$x" = "dummy" ]; then continue; fi; \
658 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
659 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
661 @set -e; for x in dummy $(BIN_SCRIPTS); \
663 if [ "$$x" = "dummy" ]; then continue; fi; \
665 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
666 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
668 @ : {- output_off() unless windowsdll(); "" -}
669 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
670 if [ "$$s" = "dummy" ]; then continue; fi; \
672 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
673 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
675 @ : {- output_on() unless windowsdll(); "" -}
676 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
680 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
681 @$(ECHO) "*** Installing manpages"
682 $(PERL) $(SRCDIR)/util/process_docs.pl \
683 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
686 @$(ECHO) "*** Uninstalling manpages"
687 $(PERL) $(SRCDIR)/util/process_docs.pl \
688 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
692 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
693 @$(ECHO) "*** Installing HTML manpages"
694 $(PERL) $(SRCDIR)/util/process_docs.pl \
695 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
698 @$(ECHO) "*** Uninstalling manpages"
699 $(PERL) $(SRCDIR)/util/process_docs.pl \
700 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
703 # Developer targets (note: these are only available on Unix) #########
705 update: generate errors ordinals
707 generate: generate_apps generate_crypto_bn generate_crypto_objects \
708 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
711 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
712 if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
714 # Test coverage is a good idea for the future
715 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
719 lint -DLINT $(INCLUDES) $(SRCS)
722 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
723 < apps/openssl.cnf > apps/openssl-vms.cnf )
726 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
728 generate_crypto_objects:
729 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
730 crypto/objects/objects.txt \
731 crypto/objects/obj_mac.num \
732 > crypto/objects/obj_mac.new && \
733 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
734 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
735 crypto/objects/objects.txt \
736 crypto/objects/obj_mac.num \
737 > include/openssl/obj_mac.h )
738 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
739 include/openssl/obj_mac.h \
740 > crypto/objects/obj_dat.h )
741 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
742 crypto/objects/obj_mac.num \
743 crypto/objects/obj_xref.txt \
744 > crypto/objects/obj_xref.h )
746 generate_crypto_conf:
747 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
748 > crypto/conf/conf_def.h )
750 generate_crypto_asn1:
751 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
752 > crypto/asn1/charmap.h )
755 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
756 crypto/objects/obj_dat.h \
759 # Set to -force to force a rebuild
762 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
763 ( b=`pwd`; cd $(SRCDIR); \
764 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
765 ( b=`pwd`; cd $(SRCDIR)/engines; \
767 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
768 -conf $$E `basename $$E .ec`.c ; \
772 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
773 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
777 SRCTOP=../$(SRCDIR) \
778 BLDTOP=../$(BLDDIR) \
779 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
784 -etags `find . -name '*.[ch]' -o -name '*.pm'`
786 # Release targets (note: only available on Unix) #####################
788 # If your tar command doesn't support --owner and --group, make sure to
789 # use one that does, for example GNU tar
790 TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
794 TMPDIR=/var/tmp/openssl-copy.$$$$; \
796 mkdir -p $$TMPDIR/$$DISTDIR; \
798 excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
799 excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
801 git ls-tree -r --name-only --full-tree HEAD \
802 | egrep -v "$$excl_re" \
804 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
805 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
807 (cd $$TMPDIR/$$DISTDIR; \
809 find . -type d -print | xargs chmod 755; \
810 find . -type f -print | xargs chmod a+r; \
811 find . -type f -perm -0100 -print | xargs chmod a+x); \
812 (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
813 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
815 cd $(SRCDIR); ls -l $(TARFILE).gz
818 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
820 # Helper targets #####################################################
822 link-utils: $(BLDDIR)/util/opensslwrap.sh
824 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
825 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
826 mkdir -p "$(BLDDIR)/util"; \
827 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
832 # Building targets ###################################################
834 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
836 @ ( echo 'prefix=$(INSTALLTOP)'; \
837 echo 'exec_prefix=$${prefix}'; \
838 if [ -n "$(LIBDIR)" ]; then \
839 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
841 echo 'libdir=$(libdir)'; \
843 echo 'includedir=$${prefix}/include'; \
844 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
846 echo 'Name: OpenSSL-libcrypto'; \
847 echo 'Description: OpenSSL cryptography library'; \
848 echo 'Version: '$(VERSION); \
849 echo 'Libs: -L$${libdir} -lcrypto'; \
850 echo 'Libs.private: $(LIB_EX_LIBS)'; \
851 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
854 @ ( echo 'prefix=$(INSTALLTOP)'; \
855 echo 'exec_prefix=$${prefix}'; \
856 if [ -n "$(LIBDIR)" ]; then \
857 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
859 echo 'libdir=$(libdir)'; \
861 echo 'includedir=$${prefix}/include'; \
863 echo 'Name: OpenSSL-libssl'; \
864 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
865 echo 'Version: '$(VERSION); \
866 echo 'Requires.private: libcrypto'; \
867 echo 'Libs: -L$${libdir} -lssl'; \
868 echo 'Cflags: -I$${includedir}' ) > libssl.pc
871 @ ( echo 'prefix=$(INSTALLTOP)'; \
872 echo 'exec_prefix=$${prefix}'; \
873 if [ -n "$(LIBDIR)" ]; then \
874 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
876 echo 'libdir=$(libdir)'; \
878 echo 'includedir=$${prefix}/include'; \
880 echo 'Name: OpenSSL'; \
881 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
882 echo 'Version: '$(VERSION); \
883 echo 'Requires: libssl libcrypto' ) > openssl.pc
885 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
886 @echo "Detected changed: $?"
887 $(PERL) configdata.pm -r
888 @echo "**************************************************"
890 @echo "*** Please run the same make command again ***"
892 @echo "**************************************************"
896 $(PERL) configdata.pm -r
900 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
902 # Helper function to figure out dependencies on libraries
903 # It takes a list of library names and outputs a list of dependencies
904 sub compute_lib_depends {
905 if ($disabled{shared}) {
906 return map { lib($_) } @_;
909 # Depending on shared libraries:
910 # On Windows POSIX layers, we depend on {libname}.dll.a
911 # On Unix platforms, we depend on {shlibname}.so
912 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
917 my $generator = join(" ", @{$args{generator}});
918 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
919 my $incs = join("", map { " -I".$_ } @{$args{incs}});
920 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
922 if ($args{src} !~ /\.[sS]$/) {
923 if ($args{generator}->[0] =~ m|^.*\.in$|) {
924 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
925 "util", "dofile.pl")),
926 rel2abs($config{builddir}));
928 $args{src}: $args{generator}->[0] $deps
929 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
930 "-o$target{build_file}" $generator > \$@
934 $args{src}: $args{generator}->[0] $deps
935 \$(PERL)$generator_incs $generator > \$@
939 if ($args{generator}->[0] =~ /\.pl$/) {
940 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
941 } elsif ($args{generator}->[0] =~ /\.m4$/) {
942 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
943 } elsif ($args{generator}->[0] =~ /\.S$/) {
946 die "Generator type for $args{src} unknown: $generator\n";
950 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
951 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
952 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
953 } -> {$args{intent}};
954 if (defined($generator)) {
955 # If the target is named foo.S in build.info, we want to
956 # end up generating foo.s in two steps.
957 if ($args{src} =~ /\.S$/) {
958 (my $target = $args{src}) =~ s|\.S$|.s|;
960 $target: $args{generator}->[0] $deps
961 ( trap "rm -f \$@.*" INT 0; \\
963 \$(CPP) $incs $cppflags \$@.S | \\
964 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
970 $args{src}: $args{generator}->[0] $deps
975 $args{src}: $args{generator}->[0] $deps
976 \$(CPP) $incs $cppflags $args{generator}->[0] | \\
977 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
982 # Should one wonder about the end of the Perl snippet, it's because this
983 # second regexp eats up line endings as well, if the removed path is the
984 # last in the line. We may therefore need to put back a line ending.
987 (my $obj = $args{obj}) =~ s|\.o$||;
988 my @srcs = map { if ($unified_info{generate}->{$_}) {
989 (my $x = $_) =~ s/\.S$/.s/; $x
993 } ( @{$args{srcs}} );
994 my $srcs = join(" ", @srcs);
995 my $deps = join(" ", @srcs, @{$args{deps}});
996 my $incs = join("", map { " -I".$_ } @{$args{incs}});
1000 my $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
1001 if (grep /\.rc$/, @srcs) {
1003 $cmdflags = '$(RCFLAGS)';
1005 $makedepprog = undef;
1006 } elsif (grep /\.(cc|cpp)$/, @srcs) {
1008 $cmdcompile = ' -c';
1010 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1011 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
1012 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
1013 } -> {$args{intent}};
1016 $cmdcompile = ' -c';
1018 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1019 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1020 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1021 } -> {$args{intent}};
1023 $cmdflags .= $cmdcompile;
1024 my $recipe = <<"EOF";
1027 if (defined $makedepprog && $makedepprog !~ /\/makedepend/) {
1029 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
1030 \@touch $obj$depext.tmp
1031 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
1032 rm -f $obj$depext.tmp; \\
1034 mv $obj$depext.tmp $obj$depext; \\
1039 $cmd $incs $cmdflags -o \$\@ $srcs
1041 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
1043 -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cmdflags -- $srcs \\
1044 >$obj$depext.tmp 2>/dev/null
1045 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
1046 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
1047 rm -f $obj$depext.tmp; \\
1049 mv $obj$depext.tmp $obj$depext; \\
1056 # On Unix, we build shlibs from static libs, so we're ignoring the
1057 # object file array. We *know* this routine is only called when we've
1058 # configure 'shared'.
1061 my $lib = $args{lib};
1062 my $shlib = $args{shlib};
1063 my $libd = dirname($lib);
1064 my $libn = basename($lib);
1065 (my $libname = $libn) =~ s/^lib//;
1067 foreach (@{args{deps}}) {
1068 my $d = dirname($_);
1069 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1071 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1072 my $linklibs = join("", map { my $f = basename($_);
1073 (my $l = $f) =~ s/^lib//;
1074 " -l$l" } @{$args{deps}});
1075 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
1076 grep { $_ =~ m|\.o$| }
1078 my @defs = grep { $_ =~ /\.(def|map)$/ } @{$args{objs}};
1079 my @deps = compute_lib_depends(@{$args{deps}});
1080 die "More than one exported symbol map" if scalar @defs > 1;
1081 my $objs = join(" ", @objs);
1082 my $deps = join(" ", @objs, @defs, @deps);
1083 my $target = shlib_simple($lib);
1084 my $target_full = shlib($lib);
1085 my $shared_soname = "";
1086 $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
1087 if defined $target{shared_sonameflag};
1088 my $shared_imp = "";
1089 $shared_imp .= ' '.$target{shared_impflag}.basename($target)
1090 if defined $target{shared_impflag};
1091 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1092 my $recipe = <<"EOF";
1093 # When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
1094 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
1095 # With all other Unix platforms, we often build a shared library with the
1096 # SO version built into the file name and a symlink without the SO version
1097 # It's not necessary to have both as targets. The choice falls on the
1098 # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
1099 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
1101 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1102 -o $target_full$shared_def $objs \\
1103 $linklibs \$(LIB_EX_LIBS)
1107 rm -f apps/$shlib'\$(SHLIB_EXT)'
1108 rm -f test/$shlib'\$(SHLIB_EXT)'
1109 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
1110 cp -p $shlib'\$(SHLIB_EXT)' apps/
1111 cp -p $shlib'\$(SHLIB_EXT)' test/
1112 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1116 if [ '$target' != '$target_full' ]; then \\
1118 ln -s $target_full $target; \\
1125 my $dso = $args{lib};
1126 my $dsod = dirname($dso);
1127 my $dson = basename($dso);
1129 foreach (@{args{deps}}) {
1130 my $d = dirname($_);
1131 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1133 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1134 my $linklibs = join("", map { my $f = basename($_);
1135 (my $l = $f) =~ s/^lib//;
1136 " -l$l" } @{$args{deps}});
1137 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1138 my @deps = compute_lib_depends(@{$args{deps}});
1139 my $objs = join(" ", @objs);
1140 my $deps = join(" ", @deps);
1141 my $target = dso($dso);
1143 $target: $objs $deps
1144 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1146 $linklibs \$(DSO_EX_LIBS)
1151 (my $lib = $args{lib}) =~ s/\.a$//;
1152 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1153 my $objs = join(" ", @objs);
1156 \$(AR) \$(ARFLAGS) \$\@ \$\?
1157 \$(RANLIB) \$\@ || echo Never mind.
1162 my $bin = $args{bin};
1163 my $bind = dirname($bin);
1164 my $binn = basename($bin);
1165 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$|$objext|; $x }
1167 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1169 foreach (@{args{deps}}) {
1170 next if $_ =~ /\.a$/;
1171 my $d = dirname($_);
1172 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1174 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1175 my $linklibs = join("", map { if ($_ =~ /\.a$/) {
1178 my $f = basename($_);
1179 (my $l = $f) =~ s/^lib//;
1184 my $cmdflags = '$(BIN_CFLAGS)';
1185 if (grep /_cc\.o$/, @{$args{objs}}) {
1187 $cmdflags = '$(BIN_CXXFLAGS)';
1190 $bin$exeext: $objs $deps
1192 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1193 -o $bin$exeext $objs \\
1194 $linklibs \$(BIN_EX_LIBS)
1199 my $script = $args{script};
1200 my $sources = join(" ", @{$args{sources}});
1201 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1202 "util", "dofile.pl")),
1203 rel2abs($config{builddir}));
1206 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1207 "-o$target{build_file}" $sources > "$script"
1213 my $dir = $args{dir};
1214 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1216 my %extinfo = ( dso => $dsoext,
1220 foreach my $type (("dso", "lib", "bin", "script")) {
1221 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1222 # For lib object files, we could update the library. However, it
1223 # was decided that it's enough to build the directory local object
1224 # files, so we don't need to add any actions, and the dependencies
1225 # are already taken care of.
1226 if ($type ne "lib") {
1227 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1228 if (dirname($prod) eq $dir) {
1229 push @deps, $prod.$extinfo{$type};
1231 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1237 my $deps = join(" ", @deps);
1238 my $actions = join("\n", "", @actions);
1240 $args{dir} $args{dir}/: $deps$actions
1243 "" # Important! This becomes part of the template result.