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";
15 our $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
17 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
19 # Shared AIX support is special. We put libcrypto[64].so.ver into
20 # libcrypto.a and use libcrypto_a.a as static one.
21 sub sharedaix { !$disabled{shared} && $config{target} =~ /^aix/ }
23 our $sover_dirname = $config{shlib_version_number};
24 $sover_dirname =~ s|\.|_|g
25 if $config{target} =~ /^mingw/;
27 # shlib and shlib_simple both take a static library name and figure
28 # out what the shlib name should be.
30 # When OpenSSL is configured "no-shared", these functions will just
31 # return empty lists, making them suitable to join().
33 # With Windows DLL producers, shlib($libname) will return the shared
34 # library name (which usually is different from the static library
35 # name) with the default shared extension appended to it, while
36 # shlib_simple($libname) will return the static library name with
37 # the shared extension followed by ".a" appended to it. The former
38 # result is used as the runtime shared library while the latter is
39 # used as the DLL import library.
41 # On all Unix systems, shlib($libname) will return the library name
42 # with the default shared extension, while shlib_simple($libname)
43 # will return the name from shlib($libname) with any SO version number
44 # removed. On some systems, they may therefore return the exact same
48 return () if $disabled{shared} || $lib =~ /\.a$/;
49 return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)';
53 return () if $disabled{shared} || $lib =~ /\.a$/;
56 return $lib . '$(SHLIB_EXT_IMPORT)';
58 return $lib . '$(SHLIB_EXT_SIMPLE)';
61 # Easy fixing of static library names
63 (my $lib = shift) =~ s/\.a$//;
64 return $lib . $libext;
67 # dso is a complement to shlib / shlib_simple that returns the
68 # given libname with the simple shared extension (possible SO version
69 # removed). This differs from shlib_simple() by being unconditional.
73 return $engine . $dsoext;
75 # This makes sure things get built in the order they need
80 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
84 PLATFORM={- $config{target} -}
85 OPTIONS={- $config{options} -}
86 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
87 SRCDIR={- $config{sourcedir} -}
88 BLDDIR={- $config{builddir} -}
90 VERSION={- $config{version} -}
91 MAJOR={- $config{major} -}
92 MINOR={- $config{minor} -}
93 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
94 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
95 SHLIB_MAJOR={- $config{shlib_major} -}
96 SHLIB_MINOR={- $config{shlib_minor} -}
97 SHLIB_TARGET={- $target{shared_target} -}
98 SHLIB_EXT={- $shlibext -}
99 SHLIB_EXT_SIMPLE={- $shlibextsimple -}
100 SHLIB_EXT_IMPORT={- $shlibextimport -}
102 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
103 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
104 SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
105 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
106 PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
107 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
108 {- output_off() if $disabled{makedepend}; "" -}
109 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
110 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
111 keys %{$unified_info{sources}}); -}
112 {- output_on() if $disabled{makedepend}; "" -}
113 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
114 GENERATED={- # common0.tmpl provides @generated
115 join(" ", @generated ) -}
117 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
118 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
119 INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
120 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
121 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
122 {- output_off() if $disabled{apps}; "" -}
123 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
124 MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget.pl:tsget
125 {- output_on() if $disabled{apps}; "" -}
127 APPS_OPENSSL={- use File::Spec::Functions;
128 catfile("apps","openssl") -}
130 # DESTDIR is for package builders so that they can configure for, say,
131 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
132 # Normally it is left empty.
135 # Do not edit these manually. Use Configure with --prefix or --openssldir
136 # to change this! Short explanation in the top comment in Configure
137 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
139 our $prefix = $config{prefix} || "/usr/local";
142 # The logic here is that if no --openssldir was given,
143 # OPENSSLDIR will get the value from $prefix plus "/ssl".
144 # If --openssldir was given and the value is an absolute
145 # path, OPENSSLDIR will get its value without change.
146 # If the value from --openssldir is a relative path,
147 # OPENSSLDIR will get $prefix with the --openssldir
148 # value appended as a subdirectory.
150 use File::Spec::Functions;
152 $config{openssldir} ?
153 (file_name_is_absolute($config{openssldir}) ?
155 : catdir($prefix, $config{openssldir}))
156 : catdir($prefix, "ssl");
158 LIBDIR={- our $libdir = $config{libdir};
161 # if $prefix/lib$target{multilib} is not an existing
162 # directory, then assume that it's not searched by linker
163 # automatically, in which case adding $target{multilib} suffix
164 # causes more grief than we're ready to tolerate, so don't...
166 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
167 $libdir = "lib$multilib";
169 file_name_is_absolute($libdir) ? "" : $libdir -}
170 # $(libdir) is chosen to be compatible with the GNU coding standards
171 libdir={- file_name_is_absolute($libdir)
172 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
173 ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
175 # Convenience variable for those who want to set the rpath in shared
176 # libraries and applications
179 MANDIR=$(INSTALLTOP)/share/man
180 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
181 HTMLDIR=$(DOCDIR)/html
183 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
184 # appended after the manpage file section number. "ssl" is popular,
185 # resulting in files such as config.5ssl rather than config.5.
189 # For "optional" echo messages, to get "real" silence
192 ##### User defined commands and flags ################################
194 # We let the C compiler driver to take care of .s files. This is done in
195 # order to be excused from maintaining a separate set of architecture
196 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
197 # gcc, then the driver will automatically translate it to -xarch=v8plus
198 # and pass it down to assembler. In any case, we do not define AS or
199 # ASFLAGS for this reason.
201 CROSS_COMPILE={- $config{CROSS_COMPILE} -}
202 CC=$(CROSS_COMPILE){- $config{CC} -}
203 CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
204 CPPFLAGS={- our $cppflags1 = join(" ",
205 (map { "-D".$_} @{$config{CPPDEFINES}}),
206 (map { "-I".$_} @{$config{CPPINCLUDES}}),
207 @{$config{CPPFLAGS}}) -}
208 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
209 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
210 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
211 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
213 MAKEDEPEND={- $config{makedepprog} -}
215 PERL={- $config{PERL} -}
217 AR=$(CROSS_COMPILE){- $config{AR} -}
218 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
219 RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
220 RC= $(CROSS_COMPILE){- $config{RC} -}
221 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
225 TAR= {- $target{TAR} || "tar" -}
226 TARFLAGS= {- $target{TARFLAGS} -}
229 NAME= $(BASENAME)-$(VERSION)
230 # Relative to $(SRCDIR)
231 TARFILE= ../$(NAME).tar
233 ##### Project flags ##################################################
235 # Variables starting with CNF_ are common variables for all product types
237 CNF_CPPFLAGS={- our $cppflags2 =
238 join(' ', $target{cppflags} || (),
239 (map { "-D".$_} @{$target{defines}},
240 @{$config{defines}}),
241 (map { "-I".$_} @{$target{includes}},
242 @{$config{includes}}),
243 @{$config{cppflags}}) -}
244 CNF_CFLAGS={- join(' ', $target{cflags} || (),
245 @{$config{cflags}}) -}
246 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
247 @{$config{cxxflags}}) -}
248 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
249 @{$config{lflags}}) -}
250 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
251 @{$config{ex_libs}}) -}
253 # Variables starting with LIB_ are used to build library object files
254 # and shared libraries.
255 # Variables starting with DSO_ are used to build DSOs and their object files.
256 # Variables starting with BIN_ are used to build programs and their object
259 LIB_CPPFLAGS={- our $lib_cppflags =
260 join(' ', $target{lib_cppflags} || (),
261 $target{shared_cppflag} || (),
263 @{$config{lib_defines} || ()},
264 @{$config{shared_defines} || ()}),
265 @{$config{lib_cppflags}},
266 @{$config{shared_cppflag}});
267 join(' ', $lib_cppflags,
269 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
270 'ENGINESDIR="\"$(ENGINESDIR)\""'),
271 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
272 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
273 $target{shared_cflag} || (),
274 @{$config{lib_cflags}},
275 @{$config{shared_cflag}},
276 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
277 LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
278 $target{shared_cxxflag} || (),
279 @{$config{lib_cxxflags}},
280 @{$config{shared_cxxflag}},
281 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
282 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
283 $config{shared_ldflag} || (),
284 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
285 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
286 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
287 $target{module_cppflags} || (),
289 @{$config{dso_defines} || ()},
290 @{$config{module_defines} || ()}),
291 @{$config{dso_cppflags}},
292 @{$config{module_cppflags}},
293 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
294 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
295 $target{module_cflags} || (),
296 @{$config{dso_cflags}},
297 @{$config{module_cflags}},
298 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
299 DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
300 $target{module_cxxflags} || (),
301 @{$config{dso_cxxflags}},
302 @{$config{module_cxxflag}},
303 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
304 DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
305 $target{module_ldflags} || (),
306 @{$config{dso_ldflags}},
307 @{$config{module_ldflags}},
308 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
309 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
310 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
311 (map { '-D'.$_ } @{$config{bin_defines} || ()}),
312 @{$config{bin_cppflags}},
313 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
314 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
315 @{$config{bin_cflags}},
316 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
317 BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
318 @{$config{bin_cxxflags}},
319 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
320 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
321 @{$config{bin_lflags}},
322 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
323 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
325 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
326 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
327 $cppflags2 =~ s|([\\"])|\\$1|g;
328 $lib_cppflags =~ s|([\\"])|\\$1|g;
329 join(' ', $lib_cppflags || (), $cppflags2 || (),
332 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
334 # For x86 assembler: Set PROCESSOR to 386 if you want to support
336 PROCESSOR= {- $config{processor} -}
338 # We want error [and other] messages in English. Trouble is that make(1)
339 # doesn't pass macros down as environment variables unless there already
340 # was corresponding variable originally set. In other words we can only
341 # reassign environment variables, but not set new ones, not in portable
342 # manner that is. That's why we reassign several, just to be sure...
347 # The main targets ###################################################
349 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
350 {- dependmagic('build_libs'); -}: build_libs_nodep
351 {- dependmagic('build_engines'); -}: build_engines_nodep
352 {- dependmagic('build_programs'); -}: build_programs_nodep
354 build_generated: $(GENERATED_MANDATORY)
355 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
356 build_engines_nodep: $(ENGINES)
357 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
359 # Kept around for backward compatibility
360 build_apps build_tests: build_programs
362 # Convenience target to prebuild all generated files, not just the mandatory
364 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
365 @ : {- output_off() if $disabled{makedepend}; "" -}
366 @echo "Warning: consider configuring with no-makedepend, because if"
367 @echo " target system doesn't have $(PERL),"
368 @echo " then make will fail..."
369 @ : {- output_on() if $disabled{makedepend}; "" -}
372 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
373 @ : {- output_off() if $disabled{tests}; "" -}
375 mkdir -p test-runs; \
376 SRCTOP=../$(SRCDIR) \
377 BLDTOP=../$(BLDDIR) \
380 EXE_EXT={- $exeext -} \
381 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \
382 OPENSSL_DEBUG_MEMORY=on \
383 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
384 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
385 @echo "Tests are not supported with your chosen Configure options"
386 @ : {- output_on() if !$disabled{tests}; "" -}
389 @ : {- output_off() if $disabled{tests}; "" -}
390 @SRCTOP="$(SRCDIR)" \
391 $(PERL) $(SRCDIR)/test/run_tests.pl list
392 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
393 @echo "Tests are not supported with your chosen Configure options"
394 @ : {- output_on() if !$disabled{tests}; "" -}
396 install: install_sw install_ssldirs install_docs
398 uninstall: uninstall_docs uninstall_sw
401 @set -e; for s in $(SHLIB_INFO); do \
402 if [ "$$s" = ";" ]; then continue; fi; \
403 s1=`echo "$$s" | cut -f1 -d";"`; \
404 s2=`echo "$$s" | cut -f2 -d";"`; \
405 $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
408 $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
410 if [ "$$s1" != "$$s2" ]; then \
411 $(ECHO) $(RM) $$s2; \
419 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
420 $(RM) $(GENERATED_MANDATORY) $(GENERATED)
421 -$(RM) `find . -name .git -prune -o -name '*{- $depext -}' -print`
422 -$(RM) `find . -name .git -prune -o -name '*{- $objext -}' -print`
424 $(RM) tags TAGS doc-nits
425 $(RM) -r test/test-runs
426 $(RM) openssl.pc libcrypto.pc libssl.pc
427 -$(RM) `find . -name .git -prune -o -type l -print`
434 # We check if any depfile is newer than Makefile and decide to
435 # concatenate only if that is true.
437 @: {- output_off() if $disabled{makedepend}; "" -}
438 @$(PERL) $(SRCDIR)/util/add-depends.pl {-
439 defined $makedepprog && $makedepprog =~ /\/makedepend/
440 ? 'makedepend' : 'gcc' -}
441 @: {- output_on() if $disabled{makedepend}; "" -}
443 # Install helper targets #############################################
445 install_sw: install_dev install_engines install_runtime
447 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
449 install_docs: install_man_docs install_html_docs
451 uninstall_docs: uninstall_man_docs uninstall_html_docs
452 $(RM) -r $(DESTDIR)$(DOCDIR)
455 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
456 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
457 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
458 @set -e; for x in dummy $(MISC_SCRIPTS); do \
459 if [ "$$x" = "dummy" ]; then continue; fi; \
460 x1=`echo "$$x" | cut -f1 -d:`; \
461 x2=`echo "$$x" | cut -f2 -d:`; \
462 fn=`basename $$x1`; \
463 $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
464 cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
465 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
466 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
467 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
468 if [ "$$x1" != "$$x2" ]; then \
469 ln=`basename "$$x2"`; \
470 : {- output_off() unless windowsdll(); "" -}; \
471 $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
472 cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
473 : {- output_on() unless windowsdll();
474 output_off() if windowsdll(); "" -}; \
475 $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
476 ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
477 : {- output_on() if windowsdll(); "" -}; \
480 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
481 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
482 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
483 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
484 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
485 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
486 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
487 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
489 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
490 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
491 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
492 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
493 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
494 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
495 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
496 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
499 install_dev: install_runtime_libs
500 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
501 @$(ECHO) "*** Installing development files"
502 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
503 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
504 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
505 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
506 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
507 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
508 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
509 $(BLDDIR)/include/openssl/*.h; do \
511 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
512 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
513 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
515 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
516 @set -e; for l in $(INSTALL_LIBS); do \
518 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
519 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
520 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
521 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
522 mv -f $(DESTDIR)$(libdir)/$$fn.new \
523 $(DESTDIR)$(libdir)/$$fn; \
525 @ : {- output_off() if $disabled{shared}; "" -}
526 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
527 s1=`echo "$$s" | cut -f1 -d";"`; \
528 s2=`echo "$$s" | cut -f2 -d";"`; \
529 fn1=`basename $$s1`; \
530 fn2=`basename $$s2`; \
531 : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
532 if [ "$$fn1" != "$$fn2" ]; then \
533 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
534 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
536 : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
537 $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
538 cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
539 chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
540 mv -f $(DESTDIR)$(libdir)/$$fn2.new \
541 $(DESTDIR)$(libdir)/$$fn2; \
542 : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
543 a=$(DESTDIR)$(libdir)/$$fn2; \
544 $(ECHO) "install $$s1 -> $$a"; \
545 if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
546 mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
548 for so in `$(AR) t $$a`; do \
551 strip -X32_64 -e $$so; \
552 $(AR) r $$a.new $$so; \
555 $(AR) r $$a.new $$s1; \
557 : {- output_off() if sharedaix(); output_on(); "" -}; \
559 @ : {- output_on() if $disabled{shared}; "" -}
560 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
561 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
562 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
563 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
564 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
565 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
566 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
567 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
568 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
569 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
571 uninstall_dev: uninstall_runtime_libs
572 @$(ECHO) "*** Uninstalling development files"
573 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
574 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
575 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
576 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
577 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
578 $(BLDDIR)/include/openssl/*.h; do \
580 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
581 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
583 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
584 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
585 @set -e; for l in $(INSTALL_LIBS); do \
587 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
588 $(RM) $(DESTDIR)$(libdir)/$$fn; \
590 @ : {- output_off() if $disabled{shared}; "" -}
591 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
592 s1=`echo "$$s" | cut -f1 -d";"`; \
593 s2=`echo "$$s" | cut -f2 -d";"`; \
594 fn1=`basename $$s1`; \
595 fn2=`basename $$s2`; \
596 : {- output_off() if windowsdll(); "" -}; \
597 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
598 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
599 if [ "$$fn1" != "$$fn2" -a -f "$(DESTDIR)$(libdir)/$$fn1" ]; then \
600 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
601 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
603 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
604 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
605 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
606 : {- output_on() unless windowsdll(); "" -}; \
608 @ : {- output_on() if $disabled{shared}; "" -}
609 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
610 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
611 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
612 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
613 -$(RMDIR) $(DESTDIR)$(libdir)
615 install_engines: install_runtime_libs build_engines
616 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
617 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
618 @$(ECHO) "*** Installing engines"
619 @set -e; for e in dummy $(INSTALL_ENGINES); do \
620 if [ "$$e" = "dummy" ]; then continue; fi; \
622 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
623 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
624 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
625 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
626 $(DESTDIR)$(ENGINESDIR)/$$fn; \
630 @$(ECHO) "*** Uninstalling engines"
631 @set -e; for e in dummy $(INSTALL_ENGINES); do \
632 if [ "$$e" = "dummy" ]; then continue; fi; \
634 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
637 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
638 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
640 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
642 install_runtime: install_programs
644 install_runtime_libs: build_libs
645 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
646 @ : {- output_off() if windowsdll(); "" -}
647 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
648 @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
649 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
650 @ : {- output_on() unless windowsdll(); "" -}
651 @$(ECHO) "*** Installing runtime libraries"
652 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
653 if [ "$$s" = "dummy" ]; then continue; fi; \
655 : {- output_off() unless windowsdll(); "" -}; \
656 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
657 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
658 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
659 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
660 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
661 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
662 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
663 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
664 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
665 mv -f $(DESTDIR)$(libdir)/$$fn.new \
666 $(DESTDIR)$(libdir)/$$fn; \
667 : {- output_on() if windowsdll(); "" -}; \
670 install_programs: install_runtime_libs build_programs
671 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
672 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
673 @$(ECHO) "*** Installing runtime programs"
674 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
675 if [ "$$x" = "dummy" ]; then continue; fi; \
677 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
678 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
679 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
680 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
681 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
683 @set -e; for x in dummy $(BIN_SCRIPTS); do \
684 if [ "$$x" = "dummy" ]; then continue; fi; \
686 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
687 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
688 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
689 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
690 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
693 uninstall_runtime: uninstall_programs uninstall_runtime_libs
696 @$(ECHO) "*** Uninstalling runtime programs"
697 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
699 if [ "$$x" = "dummy" ]; then continue; fi; \
701 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
702 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
704 @set -e; for x in dummy $(BIN_SCRIPTS); \
706 if [ "$$x" = "dummy" ]; then continue; fi; \
708 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
709 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
711 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
713 uninstall_runtime_libs:
714 @$(ECHO) "*** Uninstalling runtime libraries"
715 @ : {- output_off() unless windowsdll(); "" -}
716 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
717 if [ "$$s" = "dummy" ]; then continue; fi; \
719 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
720 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
722 @ : {- output_on() unless windowsdll(); "" -}
726 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
727 @$(ECHO) "*** Installing manpages"
728 $(PERL) $(SRCDIR)/util/process_docs.pl \
729 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
732 @$(ECHO) "*** Uninstalling manpages"
733 $(PERL) $(SRCDIR)/util/process_docs.pl \
734 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
738 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
739 @$(ECHO) "*** Installing HTML manpages"
740 $(PERL) $(SRCDIR)/util/process_docs.pl \
741 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
744 @$(ECHO) "*** Uninstalling manpages"
745 $(PERL) $(SRCDIR)/util/process_docs.pl \
746 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
749 # Developer targets (note: these are only available on Unix) #########
751 update: generate errors ordinals
753 generate: generate_apps generate_crypto_bn generate_crypto_objects \
754 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
758 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
759 @if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \
760 else echo 'doc-nits: no errors.'; rm doc-nits ; fi
762 # Test coverage is a good idea for the future
763 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
767 lint -DLINT $(INCLUDES) $(SRCS)
770 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
771 < apps/openssl.cnf > apps/openssl-vms.cnf )
774 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
776 generate_crypto_objects:
777 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
778 crypto/objects/objects.txt \
779 crypto/objects/obj_mac.num \
780 > crypto/objects/obj_mac.new && \
781 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
782 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
783 crypto/objects/objects.txt \
784 crypto/objects/obj_mac.num \
785 > include/openssl/obj_mac.h )
786 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
787 include/openssl/obj_mac.h \
788 > crypto/objects/obj_dat.h )
789 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
790 crypto/objects/obj_mac.num \
791 crypto/objects/obj_xref.txt \
792 > crypto/objects/obj_xref.h )
794 generate_crypto_conf:
795 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
796 > crypto/conf/conf_def.h )
798 generate_crypto_asn1:
799 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
800 > crypto/asn1/charmap.h )
803 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
804 crypto/objects/obj_dat.h \
807 # Set to -force to force a rebuild
810 ( b=`pwd`; set -e; cd $(SRCDIR); \
811 $(PERL) util/ck_errf.pl -strict -internal; \
812 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
813 ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
815 $(PERL) ../util/ck_errf.pl -strict \
816 -conf $$E `basename $$E .ec`.c; \
817 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
818 -conf $$E `basename $$E .ec`.c ; \
822 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
823 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
827 SRCTOP=../$(SRCDIR) \
828 BLDTOP=../$(BLDDIR) \
829 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
834 -etags `find . -name '*.[ch]' -o -name '*.pm'`
836 # Release targets (note: only available on Unix) #####################
839 (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
841 # Helper targets #####################################################
843 link-utils: $(BLDDIR)/util/opensslwrap.sh
845 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
846 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
847 mkdir -p "$(BLDDIR)/util"; \
848 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
853 # Building targets ###################################################
855 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
857 @ ( echo 'prefix=$(INSTALLTOP)'; \
858 echo 'exec_prefix=$${prefix}'; \
859 if [ -n "$(LIBDIR)" ]; then \
860 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
862 echo 'libdir=$(libdir)'; \
864 echo 'includedir=$${prefix}/include'; \
865 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
867 echo 'Name: OpenSSL-libcrypto'; \
868 echo 'Description: OpenSSL cryptography library'; \
869 echo 'Version: '$(VERSION); \
870 echo 'Libs: -L$${libdir} -lcrypto'; \
871 echo 'Libs.private: $(LIB_EX_LIBS)'; \
872 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
875 @ ( echo 'prefix=$(INSTALLTOP)'; \
876 echo 'exec_prefix=$${prefix}'; \
877 if [ -n "$(LIBDIR)" ]; then \
878 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
880 echo 'libdir=$(libdir)'; \
882 echo 'includedir=$${prefix}/include'; \
884 echo 'Name: OpenSSL-libssl'; \
885 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
886 echo 'Version: '$(VERSION); \
887 echo 'Requires.private: libcrypto'; \
888 echo 'Libs: -L$${libdir} -lssl'; \
889 echo 'Cflags: -I$${includedir}' ) > libssl.pc
892 @ ( echo 'prefix=$(INSTALLTOP)'; \
893 echo 'exec_prefix=$${prefix}'; \
894 if [ -n "$(LIBDIR)" ]; then \
895 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
897 echo 'libdir=$(libdir)'; \
899 echo 'includedir=$${prefix}/include'; \
901 echo 'Name: OpenSSL'; \
902 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
903 echo 'Version: '$(VERSION); \
904 echo 'Requires: libssl libcrypto' ) > openssl.pc
906 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
907 @echo "Detected changed: $?"
908 $(PERL) configdata.pm -r
909 @echo "**************************************************"
911 @echo "*** Please run the same make command again ***"
913 @echo "**************************************************"
917 $(PERL) configdata.pm -r
921 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
923 # Helper function to figure out dependencies on libraries
924 # It takes a list of library names and outputs a list of dependencies
925 sub compute_lib_depends {
926 if ($disabled{shared}) {
927 return map { lib($_) } @_;
930 # Depending on shared libraries:
931 # On Windows POSIX layers, we depend on {libname}.dll.a
932 # On Unix platforms, we depend on {shlibname}.so
933 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
938 my $generator = join(" ", @{$args{generator}});
939 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
940 my $incs = join("", map { " -I".$_ } @{$args{incs}});
941 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
943 if ($args{src} !~ /\.[sS]$/) {
944 if ($args{generator}->[0] =~ m|^.*\.in$|) {
945 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
946 "util", "dofile.pl")),
947 rel2abs($config{builddir}));
949 $args{src}: $args{generator}->[0] $deps
950 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
951 "-o$target{build_file}" $generator > \$@
955 $args{src}: $args{generator}->[0] $deps
956 \$(PERL)$generator_incs $generator > \$@
960 if ($args{generator}->[0] =~ /\.pl$/) {
961 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
962 } elsif ($args{generator}->[0] =~ /\.m4$/) {
963 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
964 } elsif ($args{generator}->[0] =~ /\.S$/) {
967 die "Generator type for $args{src} unknown: $generator\n";
971 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
972 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
973 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
974 } -> {$args{intent}};
975 if (defined($generator)) {
977 $args{src}: $args{generator}->[0] $deps
982 $args{src}: $args{generator}->[0] $deps
983 \$(CC) $incs $cppflags -E $args{generator}->[0] | \\
984 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
989 # Should one wonder about the end of the Perl snippet, it's because this
990 # second regexp eats up line endings as well, if the removed path is the
991 # last in the line. We may therefore need to put back a line ending.
994 (my $obj = $args{obj}) =~ s|\.o$||;
995 my @srcs = @{$args{srcs}};
996 my $srcs = join(" ", @srcs);
997 my $deps = join(" ", @srcs, @{$args{deps}});
998 my $incs = join("", map { " -I".$_ } @{$args{incs}});
1002 if (grep /\.rc$/, @srcs) {
1004 $cmdflags = '$(RCFLAGS)';
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}};
1024 # extension-specific rules
1025 if (grep /\.s$/, @srcs) {
1028 $cmd $cmdflags -c -o \$\@ $srcs
1030 } elsif (grep /\.S$/, @srcs) {
1031 # Originally there was mutli-step rule with $(CC) -E file.S
1032 # followed by $(CC) -c file.s. It compensated for one of
1033 # legacy platform compiler's inability to handle .S files.
1034 # The platform is long discontinued by vendor so there is
1035 # hardly a point to drag it along...
1038 $cmd $incs $cmdflags -c -o \$\@ $srcs
1040 } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
1041 && !grep /\.rc$/, @srcs) {
1044 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
1045 \@touch $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; \\
1055 $cmd $incs $cmdflags $cmdcompile -o \$\@ $srcs
1057 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
1059 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
1066 # We *know* this routine is only called when we've configure 'shared'.
1069 my $lib = $args{lib};
1070 my $shlib = $args{shlib};
1071 my $libd = dirname($lib);
1072 my $libn = basename($lib);
1073 (my $libname = $libn) =~ s/^lib//;
1075 foreach (@{args{deps}}) {
1076 my $d = dirname($_);
1077 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1079 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1080 my $linklibs = join("", map { my $f = basename($_);
1081 (my $l = $f) =~ s/^lib//;
1082 " -l$l" } @{$args{deps}});
1083 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1084 grep { $_ !~ m/\.(?:def|map)$/ }
1086 my @defs = grep { $_ =~ /\.(?:def|map)$/ } @{$args{objs}};
1087 my @deps = compute_lib_depends(@{$args{deps}});
1088 die "More than one exported symbol map" if scalar @defs > 1;
1089 my $objs = join(" ", @objs);
1090 my $deps = join(" ", @objs, @defs, @deps);
1091 my $simple = shlib_simple($lib);
1092 my $full = shlib($lib);
1093 my $target = "$simple $full";
1094 my $shared_soname = "";
1095 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
1096 if defined $target{shared_sonameflag};
1097 my $shared_imp = "";
1098 $shared_imp .= ' '.$target{shared_impflag}.basename($simple)
1099 if defined $target{shared_impflag};
1100 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1101 my $recipe = <<"EOF";
1103 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1104 -o $full$shared_def $objs \\
1105 $linklibs \$(LIB_EX_LIBS)
1109 rm -f apps/$shlib'\$(SHLIB_EXT)'
1110 rm -f test/$shlib'\$(SHLIB_EXT)'
1111 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
1112 cp -p $shlib'\$(SHLIB_EXT)' apps/
1113 cp -p $shlib'\$(SHLIB_EXT)' test/
1114 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1116 } elsif (sharedaix()) {
1119 \$(AR) r $simple $full
1123 if [ '$simple' != '$full' ]; then \\
1125 ln -s $full $simple; \\
1132 my $dso = $args{lib};
1133 my $dsod = dirname($dso);
1134 my $dson = basename($dso);
1136 foreach (@{args{deps}}) {
1137 my $d = dirname($_);
1138 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1140 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1141 my $linklibs = join("", map { my $f = basename($_);
1142 (my $l = $f) =~ s/^lib//;
1143 " -l$l" } @{$args{deps}});
1144 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1145 grep { $_ !~ m/\.(?:def|map)$/ }
1147 my @deps = compute_lib_depends(@{$args{deps}});
1148 my $objs = join(" ", @objs);
1149 my $deps = join(" ", @deps);
1150 my $target = dso($dso);
1152 $target: $objs $deps
1153 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1155 $linklibs \$(DSO_EX_LIBS)
1160 (my $lib = $args{lib}) =~ s/\.a$//;
1161 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1162 my $objs = join(" ", @objs);
1165 \$(AR) \$(ARFLAGS) \$\@ \$\?
1166 \$(RANLIB) \$\@ || echo Never mind.
1171 my $bin = $args{bin};
1172 my $bind = dirname($bin);
1173 my $binn = basename($bin);
1174 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1176 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1178 foreach (@{args{deps}}) {
1179 next if $_ =~ /\.a$/;
1180 my $d = dirname($_);
1181 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1183 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1184 my $linklibs = join("", map { if ($_ =~ s/\.a$//) {
1187 my $f = basename($_);
1188 (my $l = $f) =~ s/^lib//;
1193 my $cmdflags = '$(BIN_CFLAGS)';
1194 if (grep /_cc\.o$/, @{$args{objs}}) {
1196 $cmdflags = '$(BIN_CXXFLAGS)';
1199 $bin$exeext: $objs $deps
1201 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1202 -o $bin$exeext $objs \\
1203 $linklibs \$(BIN_EX_LIBS)
1208 my $script = $args{script};
1209 my $sources = join(" ", @{$args{sources}});
1210 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1211 "util", "dofile.pl")),
1212 rel2abs($config{builddir}));
1215 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1216 "-o$target{build_file}" $sources > "$script"
1222 my $dir = $args{dir};
1223 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1225 my %extinfo = ( dso => $dsoext,
1229 # We already have a 'test' target, and the top directory is just plain
1231 return if $dir eq "test" || $dir eq ".";
1233 foreach my $type (("dso", "lib", "bin", "script")) {
1234 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1235 # For lib object files, we could update the library. However, it
1236 # was decided that it's enough to build the directory local object
1237 # files, so we don't need to add any actions, and the dependencies
1238 # are already taken care of.
1239 if ($type ne "lib") {
1240 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1241 if (dirname($prod) eq $dir) {
1242 push @deps, $prod.$extinfo{$type};
1244 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1250 my $deps = join(" ", @deps);
1251 my $actions = join("\n", "", @actions);
1253 $dir $dir/: $deps$actions
1256 "" # Important! This becomes part of the template result.