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 our $sover_dirname = $config{shlib_version_number};
20 $sover_dirname =~ s|\.|_|g
21 if $config{target} =~ /^mingw/;
23 # shlib and shlib_simple both take a static library name and figure
24 # out what the shlib name should be.
26 # When OpenSSL is configured "no-shared", these functions will just
27 # return empty lists, making them suitable to join().
29 # With Windows DLL producers, shlib($libname) will return the shared
30 # library name (which usually is different from the static library
31 # name) with the default shared extension appended to it, while
32 # shlib_simple($libname) will return the static library name with
33 # the shared extension followed by ".a" appended to it. The former
34 # result is used as the runtime shared library while the latter is
35 # used as the DLL import library.
37 # On all Unix systems, shlib($libname) will return the library name
38 # with the default shared extension, while shlib_simple($libname)
39 # will return the name from shlib($libname) with any SO version number
40 # removed. On some systems, they may therefore return the exact same
44 return () if $disabled{shared} || $lib =~ /\.a$/;
45 return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)';
49 return () if $disabled{shared} || $lib =~ /\.a$/;
52 return $lib . '$(SHLIB_EXT_IMPORT)';
54 return $lib . '$(SHLIB_EXT_SIMPLE)';
57 # Easy fixing of static library names
59 (my $lib = shift) =~ s/\.a$//;
60 return $lib . $libext;
63 # dso is a complement to shlib / shlib_simple that returns the
64 # given libname with the simple shared extension (possible SO version
65 # removed). This differs from shlib_simple() by being unconditional.
69 return $engine . $dsoext;
71 # This makes sure things get built in the order they need
76 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
80 PLATFORM={- $config{target} -}
81 OPTIONS={- $config{options} -}
82 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
83 SRCDIR={- $config{sourcedir} -}
84 BLDDIR={- $config{builddir} -}
86 VERSION={- $config{version} -}
87 MAJOR={- $config{major} -}
88 MINOR={- $config{minor} -}
89 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
90 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
91 SHLIB_MAJOR={- $config{shlib_major} -}
92 SHLIB_MINOR={- $config{shlib_minor} -}
93 SHLIB_TARGET={- $target{shared_target} -}
94 SHLIB_EXT={- $shlibext -}
95 SHLIB_EXT_SIMPLE={- $shlibextsimple -}
96 SHLIB_EXT_IMPORT={- $shlibextimport -}
98 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
99 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
100 SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
101 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
102 PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
103 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
104 {- output_off() if $disabled{makedepend}; "" -}
105 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
106 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
107 keys %{$unified_info{sources}}); -}
108 {- output_on() if $disabled{makedepend}; "" -}
109 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
110 GENERATED={- # common0.tmpl provides @generated
111 join(" ", @generated ) -}
113 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
114 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
115 INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
116 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
117 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
118 {- output_off() if $disabled{apps}; "" -}
119 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
120 MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
121 {- output_on() if $disabled{apps}; "" -}
123 APPS_OPENSSL={- use File::Spec::Functions;
124 catfile("apps","openssl") -}
126 # DESTDIR is for package builders so that they can configure for, say,
127 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
128 # Normally it is left empty.
131 # Do not edit these manually. Use Configure with --prefix or --openssldir
132 # to change this! Short explanation in the top comment in Configure
133 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
135 our $prefix = $config{prefix} || "/usr/local";
138 # The logic here is that if no --openssldir was given,
139 # OPENSSLDIR will get the value from $prefix plus "/ssl".
140 # If --openssldir was given and the value is an absolute
141 # path, OPENSSLDIR will get its value without change.
142 # If the value from --openssldir is a relative path,
143 # OPENSSLDIR will get $prefix with the --openssldir
144 # value appended as a subdirectory.
146 use File::Spec::Functions;
148 $config{openssldir} ?
149 (file_name_is_absolute($config{openssldir}) ?
151 : catdir($prefix, $config{openssldir}))
152 : catdir($prefix, "ssl");
154 LIBDIR={- our $libdir = $config{libdir};
157 # if $prefix/lib$target{multilib} is not an existing
158 # directory, then assume that it's not searched by linker
159 # automatically, in which case adding $target{multilib} suffix
160 # causes more grief than we're ready to tolerate, so don't...
162 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
163 $libdir = "lib$multilib";
165 file_name_is_absolute($libdir) ? "" : $libdir -}
166 # $(libdir) is chosen to be compatible with the GNU coding standards
167 libdir={- file_name_is_absolute($libdir)
168 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
169 ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
171 # Convenience variable for those who want to set the rpath in shared
172 # libraries and applications
175 MANDIR=$(INSTALLTOP)/share/man
176 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
177 HTMLDIR=$(DOCDIR)/html
179 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
180 # appended after the manpage file section number. "ssl" is popular,
181 # resulting in files such as config.5ssl rather than config.5.
185 # For "optional" echo messages, to get "real" silence
188 ##### User defined commands and flags ################################
190 # We let the C compiler driver to take care of .s files. This is done in
191 # order to be excused from maintaining a separate set of architecture
192 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
193 # gcc, then the driver will automatically translate it to -xarch=v8plus
194 # and pass it down to assembler. In any case, we do not define AS or
195 # ASFLAGS for this reason.
197 CROSS_COMPILE={- $config{CROSS_COMPILE} -}
198 CC=$(CROSS_COMPILE){- $config{CC} -}
199 CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
200 CPPFLAGS={- our $cppflags1 = join(" ",
201 (map { "-D".$_} @{$config{CPPDEFINES}}),
202 (map { "-I".$_} @{$config{CPPINCLUDES}}),
203 @{$config{CPPFLAGS}}) -}
204 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
205 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
206 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
207 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
209 MAKEDEPEND={- $config{makedepprog} -}
211 PERL={- $config{perl} -}
213 AR=$(CROSS_COMPILE){- $config{AR} -}
214 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
215 RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
216 RC= $(CROSS_COMPILE){- $config{RC} -}
217 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
221 TAR= {- $target{TAR} || "tar" -}
222 TARFLAGS= {- $target{TARFLAGS} -}
225 NAME= $(BASENAME)-$(VERSION)
226 TARFILE= ../$(NAME).tar
228 ##### Project flags ##################################################
230 # Variables starting with CNF_ are common variables for all product types
232 CNF_CPPFLAGS={- our $cppflags2 =
233 join(' ', $target{cppflags} || (),
234 (map { "-D".$_} @{$target{defines}},
235 @{$config{defines}}),
236 (map { "-I".$_} @{$target{includes}},
237 @{$config{includes}}),
238 @{$config{cppflags}}) -}
239 CNF_CFLAGS={- join(' ', $target{cflags} || (),
240 @{$config{cflags}}) -}
241 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
242 @{$config{cxxflags}}) -}
243 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
244 @{$config{lflags}}) -}
245 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
246 @{$config{ex_libs}}) -}
248 # Variables starting with LIB_ are used to build library object files
249 # and shared libraries.
250 # Variables starting with DSO_ are used to build DSOs and their object files.
251 # Variables starting with BIN_ are used to build programs and their object
254 LIB_CPPFLAGS={- our $lib_cppflags =
255 join(' ', $target{lib_cppflags} || (),
256 $target{shared_cppflag} || (),
258 @{$config{lib_defines}},
259 @{$config{shared_defines}}),
260 @{$config{lib_cppflags}},
261 @{$config{shared_cppflag}});
262 join(' ', $lib_cppflags,
264 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
265 'ENGINESDIR="\"$(ENGINESDIR)\""'),
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 $lib_cppflags =~ s|([\\"])|\\$1|g;
320 join(' ', $lib_cppflags || (), $cppflags2 || (),
323 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
325 # For x86 assembler: Set PROCESSOR to 386 if you want to support
327 PROCESSOR= {- $config{processor} -}
329 # We want error [and other] messages in English. Trouble is that make(1)
330 # doesn't pass macros down as environment variables unless there already
331 # was corresponding variable originally set. In other words we can only
332 # reassign environment variables, but not set new ones, not in portable
333 # manner that is. That's why we reassign several, just to be sure...
338 # The main targets ###################################################
340 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
341 {- dependmagic('build_libs'); -}: build_libs_nodep
342 {- dependmagic('build_engines'); -}: build_engines_nodep
343 {- dependmagic('build_programs'); -}: build_programs_nodep
345 build_generated: $(GENERATED_MANDATORY)
346 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
347 build_engines_nodep: $(ENGINES)
348 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
350 # Kept around for backward compatibility
351 build_apps build_tests: build_programs
353 # Convenience target to prebuild all generated files, not just the mandatory
355 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
356 @ : {- output_off() if $disabled{makedepend}; "" -}
357 @echo "Warning: consider configuring with no-makedepend, because if"
358 @echo " target system doesn't have $(PERL),"
359 @echo " then make will fail..."
360 @ : {- output_on() if $disabled{makedepend}; "" -}
363 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
364 @ : {- output_off() if $disabled{tests}; "" -}
366 mkdir -p test-runs; \
367 SRCTOP=../$(SRCDIR) \
368 BLDTOP=../$(BLDDIR) \
371 EXE_EXT={- $exeext -} \
372 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines; pwd` \
373 OPENSSL_DEBUG_MEMORY=on \
374 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
375 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
376 @echo "Tests are not supported with your chosen Configure options"
377 @ : {- output_on() if !$disabled{tests}; "" -}
380 @ : {- output_off() if $disabled{tests}; "" -}
381 @SRCTOP="$(SRCDIR)" \
382 $(PERL) $(SRCDIR)/test/run_tests.pl list
383 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
384 @echo "Tests are not supported with your chosen Configure options"
385 @ : {- output_on() if !$disabled{tests}; "" -}
387 install: install_sw install_ssldirs install_docs
389 uninstall: uninstall_docs uninstall_sw
392 @set -e; for s in $(SHLIB_INFO); do \
393 s1=`echo "$$s" | cut -f1 -d";"`; \
394 s2=`echo "$$s" | cut -f2 -d";"`; \
395 $(ECHO) $(RM) $$s1; \
397 if [ "$$s1" != "$$s2" ]; then \
398 $(ECHO) $(RM) $$s2; \
406 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
408 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
409 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
411 $(RM) tags TAGS doc-nits
412 $(RM) -r test/test-runs
413 $(RM) openssl.pc libcrypto.pc libssl.pc
414 -$(RM) `find . -type l -a \! -path "./.git/*"`
421 # We check if any depfile is newer than Makefile and decide to
422 # concatenate only if that is true.
424 @: {- output_off() if $disabled{makedepend}; "" -}
425 @$(PERL) $(SRCDIR)/util/add-depends.pl {-
426 defined $makedepprog && $makedepprog =~ /\/makedepend/
427 ? 'makedepend' : 'gcc' -}
428 @: {- output_on() if $disabled{makedepend}; "" -}
430 # Install helper targets #############################################
432 install_sw: all install_dev install_engines install_runtime
434 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
436 install_docs: install_man_docs install_html_docs
438 uninstall_docs: uninstall_man_docs uninstall_html_docs
439 $(RM) -r -v $(DESTDIR)$(DOCDIR)
442 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
443 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
444 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
445 @set -e; for x in dummy $(MISC_SCRIPTS); do \
446 if [ "$$x" = "dummy" ]; then continue; fi; \
448 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
449 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
450 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
451 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
452 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
454 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
455 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
456 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
457 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
458 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
459 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
460 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
461 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
463 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
464 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
465 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
466 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
467 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
468 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
469 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
470 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
474 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
475 @$(ECHO) "*** Installing development files"
476 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
477 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
478 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
479 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
480 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
481 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
482 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
483 $(BLDDIR)/include/openssl/*.h; do \
485 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
486 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
487 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
489 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
490 @set -e; for l in $(INSTALL_LIBS); do \
492 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
493 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
494 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
495 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
496 mv -f $(DESTDIR)$(libdir)/$$fn.new \
497 $(DESTDIR)$(libdir)/$$fn; \
499 @ : {- output_off() if $disabled{shared}; "" -}
500 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
501 s1=`echo "$$s" | cut -f1 -d";"`; \
502 s2=`echo "$$s" | cut -f2 -d";"`; \
503 fn1=`basename $$s1`; \
504 fn2=`basename $$s2`; \
505 : {- output_off() if windowsdll(); "" -}; \
506 $(ECHO) "install $$s1 -> $(DESTDIR)$(libdir)/$$fn1"; \
507 cp $$s1 $(DESTDIR)$(libdir)/$$fn1.new; \
508 chmod 755 $(DESTDIR)$(libdir)/$$fn1.new; \
509 mv -f $(DESTDIR)$(libdir)/$$fn1.new \
510 $(DESTDIR)$(libdir)/$$fn1; \
511 if [ "$$fn1" != "$$fn2" ]; then \
512 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
513 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
515 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
516 $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
517 cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
518 chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
519 mv -f $(DESTDIR)$(libdir)/$$fn2.new \
520 $(DESTDIR)$(libdir)/$$fn2; \
521 : {- output_on() unless windowsdll(); "" -}; \
523 @ : {- output_on() if $disabled{shared}; "" -}
524 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
525 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
526 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
527 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
528 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
529 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
530 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
531 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
532 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
533 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
536 @$(ECHO) "*** Uninstalling development files"
537 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
538 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
539 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
540 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
541 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
542 $(BLDDIR)/include/openssl/*.h; do \
544 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
545 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
547 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
548 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
549 @set -e; for l in $(INSTALL_LIBS); do \
551 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
552 $(RM) $(DESTDIR)$(libdir)/$$fn; \
554 @ : {- output_off() if $disabled{shared}; "" -}
555 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
556 s1=`echo "$$s" | cut -f1 -d";"`; \
557 s2=`echo "$$s" | cut -f2 -d";"`; \
558 fn1=`basename $$s1`; \
559 fn2=`basename $$s2`; \
560 : {- output_off() if windowsdll(); "" -}; \
561 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
562 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
563 if [ "$$fn1" != "$$fn2" ]; then \
564 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
565 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
567 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
568 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
569 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
570 : {- output_on() unless windowsdll(); "" -}; \
572 @ : {- output_on() if $disabled{shared}; "" -}
573 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
574 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
575 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
576 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
577 -$(RMDIR) $(DESTDIR)$(libdir)
580 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
581 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
582 @$(ECHO) "*** Installing engines"
583 @set -e; for e in dummy $(INSTALL_ENGINES); do \
584 if [ "$$e" = "dummy" ]; then continue; fi; \
586 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
587 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
588 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
589 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
590 $(DESTDIR)$(ENGINESDIR)/$$fn; \
594 @$(ECHO) "*** Uninstalling engines"
595 @set -e; for e in dummy $(INSTALL_ENGINES); do \
596 if [ "$$e" = "dummy" ]; then continue; fi; \
598 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
601 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
602 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
604 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
607 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
608 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
609 @ : {- output_off() if windowsdll(); "" -}
610 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
611 @ : {- output_on() if windowsdll(); "" -}
612 @$(ECHO) "*** Installing runtime files"
613 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
614 if [ "$$s" = "dummy" ]; then continue; fi; \
616 : {- output_off() unless windowsdll(); "" -}; \
617 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
618 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
619 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
620 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
621 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
622 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
623 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
624 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
625 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
626 mv -f $(DESTDIR)$(libdir)/$$fn.new \
627 $(DESTDIR)$(libdir)/$$fn; \
628 : {- output_on() if windowsdll(); "" -}; \
630 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
631 if [ "$$x" = "dummy" ]; then continue; fi; \
633 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
634 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
635 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
636 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
637 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
639 @set -e; for x in dummy $(BIN_SCRIPTS); do \
640 if [ "$$x" = "dummy" ]; then continue; fi; \
642 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
643 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
644 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
645 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
646 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
650 @$(ECHO) "*** Uninstalling runtime files"
651 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
653 if [ "$$x" = "dummy" ]; then continue; fi; \
655 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
656 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
658 @set -e; for x in dummy $(BIN_SCRIPTS); \
660 if [ "$$x" = "dummy" ]; then continue; fi; \
662 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
663 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
665 @ : {- output_off() unless windowsdll(); "" -}
666 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
667 if [ "$$s" = "dummy" ]; then continue; fi; \
669 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
670 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
672 @ : {- output_on() unless windowsdll(); "" -}
673 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
677 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
678 @$(ECHO) "*** Installing manpages"
679 $(PERL) $(SRCDIR)/util/process_docs.pl \
680 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
683 @$(ECHO) "*** Uninstalling manpages"
684 $(PERL) $(SRCDIR)/util/process_docs.pl \
685 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
689 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
690 @$(ECHO) "*** Installing HTML manpages"
691 $(PERL) $(SRCDIR)/util/process_docs.pl \
692 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
695 @$(ECHO) "*** Uninstalling manpages"
696 $(PERL) $(SRCDIR)/util/process_docs.pl \
697 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
700 # Developer targets (note: these are only available on Unix) #########
702 update: generate errors ordinals
704 generate: generate_apps generate_crypto_bn generate_crypto_objects \
705 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
708 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
709 if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
711 # Test coverage is a good idea for the future
712 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
716 lint -DLINT $(INCLUDES) $(SRCS)
719 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
720 < apps/openssl.cnf > apps/openssl-vms.cnf )
723 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
725 generate_crypto_objects:
726 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
727 crypto/objects/objects.txt \
728 crypto/objects/obj_mac.num \
729 > crypto/objects/obj_mac.new && \
730 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
731 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
732 crypto/objects/objects.txt \
733 crypto/objects/obj_mac.num \
734 > include/openssl/obj_mac.h )
735 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
736 include/openssl/obj_mac.h \
737 > crypto/objects/obj_dat.h )
738 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
739 crypto/objects/obj_mac.num \
740 crypto/objects/obj_xref.txt \
741 > crypto/objects/obj_xref.h )
743 generate_crypto_conf:
744 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
745 > crypto/conf/conf_def.h )
747 generate_crypto_asn1:
748 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
749 > crypto/asn1/charmap.h )
752 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
753 crypto/objects/obj_dat.h \
756 # Set to -force to force a rebuild
759 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
760 ( b=`pwd`; cd $(SRCDIR); \
761 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
762 ( b=`pwd`; cd $(SRCDIR)/engines; \
764 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
765 -conf $$E `basename $$E .ec`.c ; \
769 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
770 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
774 SRCTOP=../$(SRCDIR) \
775 BLDTOP=../$(BLDDIR) \
776 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
781 -etags `find . -name '*.[ch]' -o -name '*.pm'`
783 # Release targets (note: only available on Unix) #####################
785 # If your tar command doesn't support --owner and --group, make sure to
786 # use one that does, for example GNU tar
787 TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cf -
791 TMPDIR=/var/tmp/openssl-copy.$$$$; \
793 mkdir -p $$TMPDIR/$$DISTDIR; \
795 excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
796 excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
798 git ls-tree -r --name-only --full-tree HEAD \
799 | egrep -v "$$excl_re" \
801 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
802 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
804 (cd $$TMPDIR/$$DISTDIR; \
806 find . -type d -print | xargs chmod 755; \
807 find . -type f -print | xargs chmod a+r; \
808 find . -type f -perm -0100 -print | xargs chmod a+x); \
809 (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
810 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
812 cd $(SRCDIR); ls -l $(TARFILE).gz
815 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
817 # Helper targets #####################################################
819 link-utils: $(BLDDIR)/util/opensslwrap.sh
821 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
822 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
823 mkdir -p "$(BLDDIR)/util"; \
824 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
829 # Building targets ###################################################
831 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
833 @ ( echo 'prefix=$(INSTALLTOP)'; \
834 echo 'exec_prefix=$${prefix}'; \
835 if [ -n "$(LIBDIR)" ]; then \
836 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
838 echo 'libdir=$(libdir)'; \
840 echo 'includedir=$${prefix}/include'; \
841 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
843 echo 'Name: OpenSSL-libcrypto'; \
844 echo 'Description: OpenSSL cryptography library'; \
845 echo 'Version: '$(VERSION); \
846 echo 'Libs: -L$${libdir} -lcrypto'; \
847 echo 'Libs.private: $(LIB_EX_LIBS)'; \
848 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
851 @ ( echo 'prefix=$(INSTALLTOP)'; \
852 echo 'exec_prefix=$${prefix}'; \
853 if [ -n "$(LIBDIR)" ]; then \
854 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
856 echo 'libdir=$(libdir)'; \
858 echo 'includedir=$${prefix}/include'; \
860 echo 'Name: OpenSSL-libssl'; \
861 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
862 echo 'Version: '$(VERSION); \
863 echo 'Requires.private: libcrypto'; \
864 echo 'Libs: -L$${libdir} -lssl'; \
865 echo 'Cflags: -I$${includedir}' ) > libssl.pc
868 @ ( echo 'prefix=$(INSTALLTOP)'; \
869 echo 'exec_prefix=$${prefix}'; \
870 if [ -n "$(LIBDIR)" ]; then \
871 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
873 echo 'libdir=$(libdir)'; \
875 echo 'includedir=$${prefix}/include'; \
877 echo 'Name: OpenSSL'; \
878 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
879 echo 'Version: '$(VERSION); \
880 echo 'Requires: libssl libcrypto' ) > openssl.pc
882 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
883 @echo "Detected changed: $?"
884 $(PERL) configdata.pm -r
885 @echo "**************************************************"
887 @echo "*** Please run the same make command again ***"
889 @echo "**************************************************"
893 $(PERL) configdata.pm -r
897 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
899 # Helper function to figure out dependencies on libraries
900 # It takes a list of library names and outputs a list of dependencies
901 sub compute_lib_depends {
902 if ($disabled{shared}) {
903 return map { lib($_) } @_;
906 # Depending on shared libraries:
907 # On Windows POSIX layers, we depend on {libname}.dll.a
908 # On Unix platforms, we depend on {shlibname}.so
909 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
914 my $generator = join(" ", @{$args{generator}});
915 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
916 my $incs = join("", map { " -I".$_ } @{$args{incs}});
917 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
919 if ($args{src} !~ /\.[sS]$/) {
920 if ($args{generator}->[0] =~ m|^.*\.in$|) {
921 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
922 "util", "dofile.pl")),
923 rel2abs($config{builddir}));
925 $args{src}: $args{generator}->[0] $deps
926 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
927 "-o$target{build_file}" $generator > \$@
931 $args{src}: $args{generator}->[0] $deps
932 \$(PERL)$generator_incs $generator > \$@
936 if ($args{generator}->[0] =~ /\.pl$/) {
937 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
938 } elsif ($args{generator}->[0] =~ /\.m4$/) {
939 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
940 } elsif ($args{generator}->[0] =~ /\.S$/) {
943 die "Generator type for $args{src} unknown: $generator\n";
947 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
948 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
949 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
950 } -> {$args{intent}};
951 if (defined($generator)) {
953 $args{src}: $args{generator}->[0] $deps
958 $args{src}: $args{generator}->[0] $deps
959 \$(CC) $incs $cppflags -E $args{generator}->[0] | \\
960 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
965 # Should one wonder about the end of the Perl snippet, it's because this
966 # second regexp eats up line endings as well, if the removed path is the
967 # last in the line. We may therefore need to put back a line ending.
970 (my $obj = $args{obj}) =~ s|\.o$||;
971 my @srcs = @{$args{srcs}};
972 my $srcs = join(" ", @srcs);
973 my $deps = join(" ", @srcs, @{$args{deps}});
974 my $incs = join("", map { " -I".$_ } @{$args{incs}});
978 if (grep /\.rc$/, @srcs) {
980 $cmdflags = '$(RCFLAGS)';
982 $makedepprog = undef;
983 } elsif (grep /\.(cc|cpp)$/, @srcs) {
987 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
988 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
989 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
990 } -> {$args{intent}};
995 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
996 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
997 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
998 } -> {$args{intent}};
1001 # extension-specific rules
1002 if (grep /\.s$/, @srcs) {
1005 $cmd $cmdflags -c -o \$\@ $srcs
1007 } elsif (grep /\.S$/, @srcs) {
1008 # Originally there was mutli-step rule with $(CC) -E file.S
1009 # followed by $(CC) -c file.s. It compensated for one of
1010 # legacy platform compiler's inability to handle .S files.
1011 # The platform is long discontinued by vendor so there is
1012 # hardly a point to drag it along...
1015 $cmd $incs $cmdflags -c -o \$\@ $srcs
1017 } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/) {
1020 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
1021 \@touch $obj$depext.tmp
1022 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
1023 rm -f $obj$depext.tmp; \\
1025 mv $obj$depext.tmp $obj$depext; \\
1031 $cmd $incs $cmdflags $cmdcompile -o \$\@ $srcs
1033 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
1035 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
1042 # On Unix, we build shlibs from static libs, so we're ignoring the
1043 # object file array. We *know* this routine is only called when we've
1044 # configure 'shared'.
1047 my $lib = $args{lib};
1048 my $shlib = $args{shlib};
1049 my $libd = dirname($lib);
1050 my $libn = basename($lib);
1051 (my $libname = $libn) =~ s/^lib//;
1053 foreach (@{args{deps}}) {
1054 my $d = dirname($_);
1055 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1057 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1058 my $linklibs = join("", map { my $f = basename($_);
1059 (my $l = $f) =~ s/^lib//;
1060 " -l$l" } @{$args{deps}});
1061 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1062 grep { $_ !~ m/\.(?:def|map)$/ }
1064 my @defs = grep { $_ =~ /\.(?:def|map)$/ } @{$args{objs}};
1065 my @deps = compute_lib_depends(@{$args{deps}});
1066 die "More than one exported symbol map" if scalar @defs > 1;
1067 my $objs = join(" ", @objs);
1068 my $deps = join(" ", @objs, @defs, @deps);
1069 my $target = shlib_simple($lib);
1070 my $target_full = shlib($lib);
1071 my $shared_soname = "";
1072 $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
1073 if defined $target{shared_sonameflag};
1074 my $shared_imp = "";
1075 $shared_imp .= ' '.$target{shared_impflag}.basename($target)
1076 if defined $target{shared_impflag};
1077 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1078 my $recipe = <<"EOF";
1079 # When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
1080 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
1081 # With all other Unix platforms, we often build a shared library with the
1082 # SO version built into the file name and a symlink without the SO version
1083 # It's not necessary to have both as targets. The choice falls on the
1084 # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
1085 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
1087 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1088 -o $target_full$shared_def $objs \\
1089 $linklibs \$(LIB_EX_LIBS)
1093 rm -f apps/$shlib'\$(SHLIB_EXT)'
1094 rm -f test/$shlib'\$(SHLIB_EXT)'
1095 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
1096 cp -p $shlib'\$(SHLIB_EXT)' apps/
1097 cp -p $shlib'\$(SHLIB_EXT)' test/
1098 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1102 if [ '$target' != '$target_full' ]; then \\
1104 ln -s $target_full $target; \\
1111 my $dso = $args{lib};
1112 my $dsod = dirname($dso);
1113 my $dson = basename($dso);
1115 foreach (@{args{deps}}) {
1116 my $d = dirname($_);
1117 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1119 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1120 my $linklibs = join("", map { my $f = basename($_);
1121 (my $l = $f) =~ s/^lib//;
1122 " -l$l" } @{$args{deps}});
1123 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1124 grep { $_ !~ m/\.(?:def|map)$/ }
1126 my @deps = compute_lib_depends(@{$args{deps}});
1127 my $objs = join(" ", @objs);
1128 my $deps = join(" ", @deps);
1129 my $target = dso($dso);
1131 $target: $objs $deps
1132 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1134 $linklibs \$(DSO_EX_LIBS)
1139 (my $lib = $args{lib}) =~ s/\.a$//;
1140 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1141 my $objs = join(" ", @objs);
1144 \$(AR) \$(ARFLAGS) \$\@ \$\?
1145 \$(RANLIB) \$\@ || echo Never mind.
1150 my $bin = $args{bin};
1151 my $bind = dirname($bin);
1152 my $binn = basename($bin);
1153 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1155 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1157 foreach (@{args{deps}}) {
1158 next if $_ =~ /\.a$/;
1159 my $d = dirname($_);
1160 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1162 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1163 my $linklibs = join("", map { if ($_ =~ /\.a$/) {
1166 my $f = basename($_);
1167 (my $l = $f) =~ s/^lib//;
1172 my $cmdflags = '$(BIN_CFLAGS)';
1173 if (grep /_cc\.o$/, @{$args{objs}}) {
1175 $cmdflags = '$(BIN_CXXFLAGS)';
1178 $bin$exeext: $objs $deps
1180 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1181 -o $bin$exeext $objs \\
1182 $linklibs \$(BIN_EX_LIBS)
1187 my $script = $args{script};
1188 my $sources = join(" ", @{$args{sources}});
1189 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1190 "util", "dofile.pl")),
1191 rel2abs($config{builddir}));
1194 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1195 "-o$target{build_file}" $sources > "$script"
1201 my $dir = $args{dir};
1202 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1204 my %extinfo = ( dso => $dsoext,
1208 foreach my $type (("dso", "lib", "bin", "script")) {
1209 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1210 # For lib object files, we could update the library. However, it
1211 # was decided that it's enough to build the directory local object
1212 # files, so we don't need to add any actions, and the dependencies
1213 # are already taken care of.
1214 if ($type ne "lib") {
1215 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1216 if (dirname($prod) eq $dir) {
1217 push @deps, $prod.$extinfo{$type};
1219 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1225 my $deps = join(" ", @deps);
1226 my $actions = join("\n", "", @actions);
1228 $args{dir} $args{dir}/: $deps$actions
1231 "" # Important! This becomes part of the template result.