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
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 TARFILE= ../$(NAME).tar
232 ##### Project flags ##################################################
234 # Variables starting with CNF_ are common variables for all product types
236 CNF_CPPFLAGS={- our $cppflags2 =
237 join(' ', $target{cppflags} || (),
238 (map { "-D".$_} @{$target{defines}},
239 @{$config{defines}}),
240 (map { "-I".$_} @{$target{includes}},
241 @{$config{includes}}),
242 @{$config{cppflags}}) -}
243 CNF_CFLAGS={- join(' ', $target{cflags} || (),
244 @{$config{cflags}}) -}
245 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
246 @{$config{cxxflags}}) -}
247 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
248 @{$config{lflags}}) -}
249 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
250 @{$config{ex_libs}}) -}
252 # Variables starting with LIB_ are used to build library object files
253 # and shared libraries.
254 # Variables starting with DSO_ are used to build DSOs and their object files.
255 # Variables starting with BIN_ are used to build programs and their object
258 LIB_CPPFLAGS={- our $lib_cppflags =
259 join(' ', $target{lib_cppflags} || (),
260 $target{shared_cppflag} || (),
262 @{$config{lib_defines}},
263 @{$config{shared_defines}}),
264 @{$config{lib_cppflags}},
265 @{$config{shared_cppflag}});
266 join(' ', $lib_cppflags,
268 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
269 'ENGINESDIR="\"$(ENGINESDIR)\""'),
270 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
271 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
272 $target{shared_cflag} || (),
273 @{$config{lib_cflags}},
274 @{$config{shared_cflag}},
275 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
276 LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
277 $target{shared_cxxflag} || (),
278 @{$config{lib_cxxflags}},
279 @{$config{shared_cxxflag}},
280 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
281 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
282 $config{shared_ldflag} || (),
283 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
284 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
285 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
286 $target{module_cppflags} || (),
287 @{$config{dso_cppflags}},
288 @{$config{module_cppflags}},
289 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
290 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
291 $target{module_cflags} || (),
292 @{$config{dso_cflags}},
293 @{$config{module_cflags}},
294 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
295 DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
296 $target{module_cxxflags} || (),
297 @{$config{dso_cxxflags}},
298 @{$config{module_cxxflag}},
299 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
300 DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
301 $target{module_ldflags} || (),
302 @{$config{dso_ldflags}},
303 @{$config{module_ldflags}},
304 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
305 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
306 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
307 @{$config{bin_cppflags}},
308 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
309 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
310 @{$config{bin_cflags}},
311 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
312 BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
313 @{$config{bin_cxxflags}},
314 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
315 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
316 @{$config{bin_lflags}},
317 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
318 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
320 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
321 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
322 $cppflags2 =~ s|([\\"])|\\$1|g;
323 $lib_cppflags =~ s|([\\"])|\\$1|g;
324 join(' ', $lib_cppflags || (), $cppflags2 || (),
327 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
329 # For x86 assembler: Set PROCESSOR to 386 if you want to support
331 PROCESSOR= {- $config{processor} -}
333 # We want error [and other] messages in English. Trouble is that make(1)
334 # doesn't pass macros down as environment variables unless there already
335 # was corresponding variable originally set. In other words we can only
336 # reassign environment variables, but not set new ones, not in portable
337 # manner that is. That's why we reassign several, just to be sure...
342 # The main targets ###################################################
344 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
345 {- dependmagic('build_libs'); -}: build_libs_nodep
346 {- dependmagic('build_engines'); -}: build_engines_nodep
347 {- dependmagic('build_programs'); -}: build_programs_nodep
349 build_generated: $(GENERATED_MANDATORY)
350 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
351 build_engines_nodep: $(ENGINES)
352 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
354 # Kept around for backward compatibility
355 build_apps build_tests: build_programs
357 # Convenience target to prebuild all generated files, not just the mandatory
359 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
360 @ : {- output_off() if $disabled{makedepend}; "" -}
361 @echo "Warning: consider configuring with no-makedepend, because if"
362 @echo " target system doesn't have $(PERL),"
363 @echo " then make will fail..."
364 @ : {- output_on() if $disabled{makedepend}; "" -}
367 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
368 @ : {- output_off() if $disabled{tests}; "" -}
370 mkdir -p test-runs; \
371 SRCTOP=../$(SRCDIR) \
372 BLDTOP=../$(BLDDIR) \
375 EXE_EXT={- $exeext -} \
376 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \
377 OPENSSL_DEBUG_MEMORY=on \
378 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
379 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
380 @echo "Tests are not supported with your chosen Configure options"
381 @ : {- output_on() if !$disabled{tests}; "" -}
384 @ : {- output_off() if $disabled{tests}; "" -}
385 @SRCTOP="$(SRCDIR)" \
386 $(PERL) $(SRCDIR)/test/run_tests.pl list
387 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
388 @echo "Tests are not supported with your chosen Configure options"
389 @ : {- output_on() if !$disabled{tests}; "" -}
391 install: install_sw install_ssldirs install_docs
393 uninstall: uninstall_docs uninstall_sw
396 @set -e; for s in $(SHLIB_INFO); do \
397 if [ "$$s" = ";" ]; then continue; fi; \
398 s1=`echo "$$s" | cut -f1 -d";"`; \
399 s2=`echo "$$s" | cut -f2 -d";"`; \
400 $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
403 $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
405 if [ "$$s1" != "$$s2" ]; then \
406 $(ECHO) $(RM) $$s2; \
414 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
415 $(RM) $(GENERATED_MANDATORY) $(GENERATED)
416 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
417 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
419 $(RM) tags TAGS doc-nits
420 $(RM) -r test/test-runs
421 $(RM) openssl.pc libcrypto.pc libssl.pc
422 -$(RM) `find . -type l -a \! -path "./.git/*"`
429 # We check if any depfile is newer than Makefile and decide to
430 # concatenate only if that is true.
432 @: {- output_off() if $disabled{makedepend}; "" -}
433 @$(PERL) $(SRCDIR)/util/add-depends.pl {-
434 defined $makedepprog && $makedepprog =~ /\/makedepend/
435 ? 'makedepend' : 'gcc' -}
436 @: {- output_on() if $disabled{makedepend}; "" -}
438 # Install helper targets #############################################
440 install_sw: all install_dev install_engines install_runtime
442 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
444 install_docs: install_man_docs install_html_docs
446 uninstall_docs: uninstall_man_docs uninstall_html_docs
447 $(RM) -r -v $(DESTDIR)$(DOCDIR)
450 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
451 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
452 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
453 @set -e; for x in dummy $(MISC_SCRIPTS); do \
454 if [ "$$x" = "dummy" ]; then continue; fi; \
456 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
457 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
458 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
459 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
460 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
462 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
463 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
464 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
465 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
466 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
467 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
468 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
469 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
471 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
472 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
473 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
474 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
475 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
476 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
477 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
478 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
482 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
483 @$(ECHO) "*** Installing development files"
484 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
485 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
486 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
487 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
488 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
489 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
490 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
491 $(BLDDIR)/include/openssl/*.h; do \
493 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
494 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
495 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
497 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
498 @set -e; for l in $(INSTALL_LIBS); do \
500 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
501 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
502 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
503 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
504 mv -f $(DESTDIR)$(libdir)/$$fn.new \
505 $(DESTDIR)$(libdir)/$$fn; \
507 @ : {- output_off() if $disabled{shared}; "" -}
508 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
509 s1=`echo "$$s" | cut -f1 -d";"`; \
510 s2=`echo "$$s" | cut -f2 -d";"`; \
511 fn1=`basename $$s1`; \
512 fn2=`basename $$s2`; \
513 : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
514 $(ECHO) "install $$s1 -> $(DESTDIR)$(libdir)/$$fn1"; \
515 cp $$s1 $(DESTDIR)$(libdir)/$$fn1.new; \
516 chmod 755 $(DESTDIR)$(libdir)/$$fn1.new; \
517 mv -f $(DESTDIR)$(libdir)/$$fn1.new \
518 $(DESTDIR)$(libdir)/$$fn1; \
519 if [ "$$fn1" != "$$fn2" ]; then \
520 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
521 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
523 : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
524 $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
525 cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
526 chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
527 mv -f $(DESTDIR)$(libdir)/$$fn2.new \
528 $(DESTDIR)$(libdir)/$$fn2; \
529 : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
530 a=$(DESTDIR)$(libdir)/$$fn2; \
531 $(ECHO) "install $$s1 -> $$a"; \
532 if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
533 mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
535 for so in `$(AR) t $$a`; do \
538 strip -X32_64 -e $$so; \
539 $(AR) r $$a.new $$so; \
542 $(AR) r $$a.new $$s1; \
544 : {- output_off() if sharedaix(); output_on(); "" -}; \
546 @ : {- output_on() if $disabled{shared}; "" -}
547 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
548 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
549 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
550 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
551 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
552 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
553 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
554 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
555 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
556 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
559 @$(ECHO) "*** Uninstalling development files"
560 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
561 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
562 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
563 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
564 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
565 $(BLDDIR)/include/openssl/*.h; do \
567 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
568 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
570 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
571 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
572 @set -e; for l in $(INSTALL_LIBS); do \
574 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
575 $(RM) $(DESTDIR)$(libdir)/$$fn; \
577 @ : {- output_off() if $disabled{shared}; "" -}
578 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
579 s1=`echo "$$s" | cut -f1 -d";"`; \
580 s2=`echo "$$s" | cut -f2 -d";"`; \
581 fn1=`basename $$s1`; \
582 fn2=`basename $$s2`; \
583 : {- output_off() if windowsdll(); "" -}; \
584 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
585 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
586 if [ "$$fn1" != "$$fn2" -a -f "$(DESTDIR)$(libdir)/$$fn1" ]; then \
587 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
588 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
590 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
591 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
592 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
593 : {- output_on() unless windowsdll(); "" -}; \
595 @ : {- output_on() if $disabled{shared}; "" -}
596 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
597 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
598 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
599 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
600 -$(RMDIR) $(DESTDIR)$(libdir)
603 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
604 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
605 @$(ECHO) "*** Installing engines"
606 @set -e; for e in dummy $(INSTALL_ENGINES); do \
607 if [ "$$e" = "dummy" ]; then continue; fi; \
609 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
610 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
611 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
612 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
613 $(DESTDIR)$(ENGINESDIR)/$$fn; \
617 @$(ECHO) "*** Uninstalling engines"
618 @set -e; for e in dummy $(INSTALL_ENGINES); do \
619 if [ "$$e" = "dummy" ]; then continue; fi; \
621 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
624 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
625 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
627 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
630 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
631 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
632 @ : {- output_off() if windowsdll(); "" -}
633 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
634 @ : {- output_on() if windowsdll(); "" -}
635 @$(ECHO) "*** Installing runtime files"
636 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
637 if [ "$$s" = "dummy" ]; then continue; fi; \
639 : {- output_off() unless windowsdll(); "" -}; \
640 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
641 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
642 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
643 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
645 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
646 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
647 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
648 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
649 mv -f $(DESTDIR)$(libdir)/$$fn.new \
650 $(DESTDIR)$(libdir)/$$fn; \
651 : {- output_on() if windowsdll(); "" -}; \
653 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
654 if [ "$$x" = "dummy" ]; then continue; fi; \
656 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
657 cp $$x $(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; \
662 @set -e; for x in dummy $(BIN_SCRIPTS); do \
663 if [ "$$x" = "dummy" ]; then continue; fi; \
665 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
666 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
667 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
668 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
669 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
673 @$(ECHO) "*** Uninstalling runtime files"
674 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
676 if [ "$$x" = "dummy" ]; then continue; fi; \
678 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
679 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
681 @set -e; for x in dummy $(BIN_SCRIPTS); \
683 if [ "$$x" = "dummy" ]; then continue; fi; \
685 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
686 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
688 @ : {- output_off() unless windowsdll(); "" -}
689 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
690 if [ "$$s" = "dummy" ]; then continue; fi; \
692 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
693 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
695 @ : {- output_on() unless windowsdll(); "" -}
696 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
700 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
701 @$(ECHO) "*** Installing manpages"
702 $(PERL) $(SRCDIR)/util/process_docs.pl \
703 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
706 @$(ECHO) "*** Uninstalling manpages"
707 $(PERL) $(SRCDIR)/util/process_docs.pl \
708 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
712 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
713 @$(ECHO) "*** Installing HTML manpages"
714 $(PERL) $(SRCDIR)/util/process_docs.pl \
715 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
718 @$(ECHO) "*** Uninstalling manpages"
719 $(PERL) $(SRCDIR)/util/process_docs.pl \
720 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
723 # Developer targets (note: these are only available on Unix) #########
725 update: generate errors ordinals
727 generate: generate_apps generate_crypto_bn generate_crypto_objects \
728 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
732 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
733 @if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \
734 else echo 'doc-nits: no errors.'; rm doc-nits ; fi
736 # Test coverage is a good idea for the future
737 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
741 lint -DLINT $(INCLUDES) $(SRCS)
744 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
745 < apps/openssl.cnf > apps/openssl-vms.cnf )
748 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
750 generate_crypto_objects:
751 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
752 crypto/objects/objects.txt \
753 crypto/objects/obj_mac.num \
754 > crypto/objects/obj_mac.new && \
755 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
756 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
757 crypto/objects/objects.txt \
758 crypto/objects/obj_mac.num \
759 > include/openssl/obj_mac.h )
760 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
761 include/openssl/obj_mac.h \
762 > crypto/objects/obj_dat.h )
763 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
764 crypto/objects/obj_mac.num \
765 crypto/objects/obj_xref.txt \
766 > crypto/objects/obj_xref.h )
768 generate_crypto_conf:
769 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
770 > crypto/conf/conf_def.h )
772 generate_crypto_asn1:
773 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
774 > crypto/asn1/charmap.h )
777 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
778 crypto/objects/obj_dat.h \
781 # Set to -force to force a rebuild
784 ( b=`pwd`; set -e; cd $(SRCDIR); \
785 $(PERL) util/ck_errf.pl -strict -internal; \
786 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
787 ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
789 $(PERL) ../util/ck_errf.pl -strict \
790 -conf $$E `basename $$E .ec`.c; \
791 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
792 -conf $$E `basename $$E .ec`.c ; \
796 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
797 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
801 SRCTOP=../$(SRCDIR) \
802 BLDTOP=../$(BLDDIR) \
803 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
808 -etags `find . -name '*.[ch]' -o -name '*.pm'`
810 # Release targets (note: only available on Unix) #####################
812 # If your tar command doesn't support --owner and --group, make sure to
813 # use one that does, for example GNU tar
814 TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cf -
818 TMPDIR=/var/tmp/openssl-copy.$$$$; \
820 mkdir -p $$TMPDIR/$$DISTDIR; \
822 excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
823 excl_re="^(fuzz/corpora|Configurations/.*\.norelease\.conf|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
825 git ls-tree -r --name-only --full-tree HEAD \
826 | egrep -v "$$excl_re" \
828 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
829 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
831 (cd $$TMPDIR/$$DISTDIR; \
833 find . -type d -print | xargs chmod 755; \
834 find . -type f -print | xargs chmod a+r; \
835 find . -type f -perm -0100 -print | xargs chmod a+x); \
836 (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
837 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
839 cd $(SRCDIR); ls -l $(TARFILE).gz
842 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
844 # Helper targets #####################################################
846 link-utils: $(BLDDIR)/util/opensslwrap.sh
848 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
849 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
850 mkdir -p "$(BLDDIR)/util"; \
851 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
856 # Building targets ###################################################
858 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
860 @ ( echo 'prefix=$(INSTALLTOP)'; \
861 echo 'exec_prefix=$${prefix}'; \
862 if [ -n "$(LIBDIR)" ]; then \
863 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
865 echo 'libdir=$(libdir)'; \
867 echo 'includedir=$${prefix}/include'; \
868 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
870 echo 'Name: OpenSSL-libcrypto'; \
871 echo 'Description: OpenSSL cryptography library'; \
872 echo 'Version: '$(VERSION); \
873 echo 'Libs: -L$${libdir} -lcrypto'; \
874 echo 'Libs.private: $(LIB_EX_LIBS)'; \
875 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
878 @ ( echo 'prefix=$(INSTALLTOP)'; \
879 echo 'exec_prefix=$${prefix}'; \
880 if [ -n "$(LIBDIR)" ]; then \
881 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
883 echo 'libdir=$(libdir)'; \
885 echo 'includedir=$${prefix}/include'; \
887 echo 'Name: OpenSSL-libssl'; \
888 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
889 echo 'Version: '$(VERSION); \
890 echo 'Requires.private: libcrypto'; \
891 echo 'Libs: -L$${libdir} -lssl'; \
892 echo 'Cflags: -I$${includedir}' ) > libssl.pc
895 @ ( echo 'prefix=$(INSTALLTOP)'; \
896 echo 'exec_prefix=$${prefix}'; \
897 if [ -n "$(LIBDIR)" ]; then \
898 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
900 echo 'libdir=$(libdir)'; \
902 echo 'includedir=$${prefix}/include'; \
904 echo 'Name: OpenSSL'; \
905 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
906 echo 'Version: '$(VERSION); \
907 echo 'Requires: libssl libcrypto' ) > openssl.pc
909 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
910 @echo "Detected changed: $?"
911 $(PERL) configdata.pm -r
912 @echo "**************************************************"
914 @echo "*** Please run the same make command again ***"
916 @echo "**************************************************"
920 $(PERL) configdata.pm -r
924 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
926 # Helper function to figure out dependencies on libraries
927 # It takes a list of library names and outputs a list of dependencies
928 sub compute_lib_depends {
929 if ($disabled{shared}) {
930 return map { lib($_) } @_;
933 # Depending on shared libraries:
934 # On Windows POSIX layers, we depend on {libname}.dll.a
935 # On Unix platforms, we depend on {shlibname}.so
936 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
941 my $generator = join(" ", @{$args{generator}});
942 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
943 my $incs = join("", map { " -I".$_ } @{$args{incs}});
944 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
946 if ($args{src} !~ /\.[sS]$/) {
947 if ($args{generator}->[0] =~ m|^.*\.in$|) {
948 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
949 "util", "dofile.pl")),
950 rel2abs($config{builddir}));
952 $args{src}: $args{generator}->[0] $deps
953 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
954 "-o$target{build_file}" $generator > \$@
958 $args{src}: $args{generator}->[0] $deps
959 \$(PERL)$generator_incs $generator > \$@
963 if ($args{generator}->[0] =~ /\.pl$/) {
964 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
965 } elsif ($args{generator}->[0] =~ /\.m4$/) {
966 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
967 } elsif ($args{generator}->[0] =~ /\.S$/) {
970 die "Generator type for $args{src} unknown: $generator\n";
974 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
975 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
976 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
977 } -> {$args{intent}};
978 if (defined($generator)) {
980 $args{src}: $args{generator}->[0] $deps
985 $args{src}: $args{generator}->[0] $deps
986 \$(CC) $incs $cppflags -E $args{generator}->[0] | \\
987 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
992 # Should one wonder about the end of the Perl snippet, it's because this
993 # second regexp eats up line endings as well, if the removed path is the
994 # last in the line. We may therefore need to put back a line ending.
997 (my $obj = $args{obj}) =~ s|\.o$||;
998 my @srcs = @{$args{srcs}};
999 my $srcs = join(" ", @srcs);
1000 my $deps = join(" ", @srcs, @{$args{deps}});
1001 my $incs = join("", map { " -I".$_ } @{$args{incs}});
1005 if (grep /\.rc$/, @srcs) {
1007 $cmdflags = '$(RCFLAGS)';
1009 } elsif (grep /\.(cc|cpp)$/, @srcs) {
1011 $cmdcompile = ' -c';
1013 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1014 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
1015 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
1016 } -> {$args{intent}};
1019 $cmdcompile = ' -c';
1021 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1022 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1023 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1024 } -> {$args{intent}};
1027 # extension-specific rules
1028 if (grep /\.s$/, @srcs) {
1031 $cmd $cmdflags -c -o \$\@ $srcs
1033 } elsif (grep /\.S$/, @srcs) {
1034 # Originally there was mutli-step rule with $(CC) -E file.S
1035 # followed by $(CC) -c file.s. It compensated for one of
1036 # legacy platform compiler's inability to handle .S files.
1037 # The platform is long discontinued by vendor so there is
1038 # hardly a point to drag it along...
1041 $cmd $incs $cmdflags -c -o \$\@ $srcs
1043 } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
1044 && !grep /\.rc$/, @srcs) {
1047 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
1048 \@touch $obj$depext.tmp
1049 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
1050 rm -f $obj$depext.tmp; \\
1052 mv $obj$depext.tmp $obj$depext; \\
1058 $cmd $incs $cmdflags $cmdcompile -o \$\@ $srcs
1060 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
1062 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
1069 # On Unix, we build shlibs from static libs, so we're ignoring the
1070 # object file array. We *know* this routine is only called when we've
1071 # configure 'shared'.
1074 my $lib = $args{lib};
1075 my $shlib = $args{shlib};
1076 my $libd = dirname($lib);
1077 my $libn = basename($lib);
1078 (my $libname = $libn) =~ s/^lib//;
1080 foreach (@{args{deps}}) {
1081 my $d = dirname($_);
1082 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1084 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1085 my $linklibs = join("", map { my $f = basename($_);
1086 (my $l = $f) =~ s/^lib//;
1087 " -l$l" } @{$args{deps}});
1088 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1089 grep { $_ !~ m/\.(?:def|map)$/ }
1091 my @defs = grep { $_ =~ /\.(?:def|map)$/ } @{$args{objs}};
1092 my @deps = compute_lib_depends(@{$args{deps}});
1093 die "More than one exported symbol map" if scalar @defs > 1;
1094 my $objs = join(" ", @objs);
1095 my $deps = join(" ", @objs, @defs, @deps);
1096 my $target = shlib_simple($lib);
1097 my $target_full = shlib($lib);
1098 my $shared_soname = "";
1099 $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
1100 if defined $target{shared_sonameflag};
1101 my $shared_imp = "";
1102 $shared_imp .= ' '.$target{shared_impflag}.basename($target)
1103 if defined $target{shared_impflag};
1104 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1105 my $recipe = <<"EOF";
1106 # When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
1107 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
1108 # With all other Unix platforms, we often build a shared library with the
1109 # SO version built into the file name and a symlink without the SO version
1110 # It's not necessary to have both as targets. The choice falls on the
1111 # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
1112 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
1114 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1115 -o $target_full$shared_def $objs \\
1116 $linklibs \$(LIB_EX_LIBS)
1120 rm -f apps/$shlib'\$(SHLIB_EXT)'
1121 rm -f test/$shlib'\$(SHLIB_EXT)'
1122 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
1123 cp -p $shlib'\$(SHLIB_EXT)' apps/
1124 cp -p $shlib'\$(SHLIB_EXT)' test/
1125 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1127 } elsif (sharedaix()) {
1130 \$(AR) r $target $target_full
1134 if [ '$target' != '$target_full' ]; then \\
1136 ln -s $target_full $target; \\
1143 my $dso = $args{lib};
1144 my $dsod = dirname($dso);
1145 my $dson = basename($dso);
1147 foreach (@{args{deps}}) {
1148 my $d = dirname($_);
1149 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1151 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1152 my $linklibs = join("", map { my $f = basename($_);
1153 (my $l = $f) =~ s/^lib//;
1154 " -l$l" } @{$args{deps}});
1155 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1156 grep { $_ !~ m/\.(?:def|map)$/ }
1158 my @deps = compute_lib_depends(@{$args{deps}});
1159 my $objs = join(" ", @objs);
1160 my $deps = join(" ", @deps);
1161 my $target = dso($dso);
1163 $target: $objs $deps
1164 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1166 $linklibs \$(DSO_EX_LIBS)
1171 (my $lib = $args{lib}) =~ s/\.a$//;
1172 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1173 my $objs = join(" ", @objs);
1176 \$(AR) \$(ARFLAGS) \$\@ \$\?
1177 \$(RANLIB) \$\@ || echo Never mind.
1182 my $bin = $args{bin};
1183 my $bind = dirname($bin);
1184 my $binn = basename($bin);
1185 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1187 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1189 foreach (@{args{deps}}) {
1190 next if $_ =~ /\.a$/;
1191 my $d = dirname($_);
1192 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1194 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1195 my $linklibs = join("", map { if ($_ =~ s/\.a$//) {
1198 my $f = basename($_);
1199 (my $l = $f) =~ s/^lib//;
1204 my $cmdflags = '$(BIN_CFLAGS)';
1205 if (grep /_cc\.o$/, @{$args{objs}}) {
1207 $cmdflags = '$(BIN_CXXFLAGS)';
1210 $bin$exeext: $objs $deps
1212 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1213 -o $bin$exeext $objs \\
1214 $linklibs \$(BIN_EX_LIBS)
1219 my $script = $args{script};
1220 my $sources = join(" ", @{$args{sources}});
1221 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1222 "util", "dofile.pl")),
1223 rel2abs($config{builddir}));
1226 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1227 "-o$target{build_file}" $sources > "$script"
1233 my $dir = $args{dir};
1234 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1236 my %extinfo = ( dso => $dsoext,
1240 foreach my $type (("dso", "lib", "bin", "script")) {
1241 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1242 # For lib object files, we could update the library. However, it
1243 # was decided that it's enough to build the directory local object
1244 # files, so we don't need to add any actions, and the dependencies
1245 # are already taken care of.
1246 if ($type ne "lib") {
1247 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1248 if (dirname($prod) eq $dir) {
1249 push @deps, $prod.$extinfo{$type};
1251 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1257 my $deps = join(" ", @deps);
1258 my $actions = join("\n", "", @actions);
1260 $args{dir} $args{dir}/: $deps$actions
1263 "" # Important! This becomes part of the template result.