2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 our $objext = $target{obj_extension} || ".o";
7 our $defext = $target{def_extension} || ".ld";
8 our $depext = $target{dep_extension} || ".d";
9 our $exeext = $target{exe_extension} || "";
10 our $libext = $target{lib_extension} || ".a";
11 our $shlibext = $target{shared_extension} || ".so";
12 our $shlibvariant = $target{shlib_variant} || "";
13 our $shlibextsimple = $target{shared_extension_simple} || ".so";
14 our $shlibextimport = $target{shared_import_extension} || "";
15 our $dsoext = $target{dso_extension} || ".so";
16 our $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
18 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
20 # Shared AIX support is special. We put libcrypto[64].so.ver into
21 # libcrypto.a and use libcrypto_a.a as static one.
22 sub sharedaix { !$disabled{shared} && $config{target} =~ /^aix/ }
24 our $sover_dirname = $config{shlib_version_number};
25 $sover_dirname =~ s|\.|_|g
26 if $config{target} =~ /^mingw/;
28 # shlib and shlib_simple both take a static library name and figure
29 # out what the shlib name should be.
31 # When OpenSSL is configured "no-shared", these functions will just
32 # return empty lists, making them suitable to join().
34 # With Windows DLL producers, shlib($libname) will return the shared
35 # library name (which usually is different from the static library
36 # name) with the default shared extension appended to it, while
37 # shlib_simple($libname) will return the static library name with
38 # the shared extension followed by ".a" appended to it. The former
39 # result is used as the runtime shared library while the latter is
40 # used as the DLL import library.
42 # On all Unix systems, shlib($libname) will return the library name
43 # with the default shared extension, while shlib_simple($libname)
44 # will return the name from shlib($libname) with any SO version number
45 # removed. On some systems, they may therefore return the exact same
49 return () if $disabled{shared} || $lib =~ /\.a$/;
50 return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)';
54 return () if $disabled{shared} || $lib =~ /\.a$/;
57 return $lib . '$(SHLIB_EXT_IMPORT)';
59 return $lib . '$(SHLIB_EXT_SIMPLE)';
62 # Easy fixing of static library names
64 (my $lib = shift) =~ s/\.a$//;
65 return $lib . $libext;
68 # dso is a complement to shlib / shlib_simple that returns the
69 # given libname with the simple shared extension (possible SO version
70 # removed). This differs from shlib_simple() by being unconditional.
74 return $engine . $dsoext;
76 # This makes sure things get built in the order they need
81 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
85 PLATFORM={- $config{target} -}
86 OPTIONS={- $config{options} -}
87 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
88 SRCDIR={- $config{sourcedir} -}
89 BLDDIR={- $config{builddir} -}
91 VERSION={- $config{version} -}
92 MAJOR={- $config{major} -}
93 MINOR={- $config{minor} -}
94 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
95 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
96 SHLIB_MAJOR={- $config{shlib_major} -}
97 SHLIB_MINOR={- $config{shlib_minor} -}
98 SHLIB_TARGET={- $target{shared_target} -}
99 SHLIB_EXT={- $shlibext -}
100 SHLIB_EXT_SIMPLE={- $shlibextsimple -}
101 SHLIB_EXT_IMPORT={- $shlibextimport -}
103 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
104 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
105 SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
106 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
107 PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
108 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
109 {- output_off() if $disabled{makedepend}; "" -}
110 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
111 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
112 keys %{$unified_info{sources}}); -}
113 {- output_on() if $disabled{makedepend}; "" -}
114 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
115 GENERATED={- # common0.tmpl provides @generated
116 join(" ", map { my $x = $_;
117 $x =~ s|\.ld$|$defext|;
121 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
122 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
123 INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
124 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
125 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
126 {- output_off() if $disabled{apps}; "" -}
127 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
128 MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget.pl:tsget
129 {- output_on() if $disabled{apps}; "" -}
131 APPS_OPENSSL={- use File::Spec::Functions;
132 catfile("apps","openssl") -}
134 # DESTDIR is for package builders so that they can configure for, say,
135 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
136 # Normally it is left empty.
139 # Do not edit these manually. Use Configure with --prefix or --openssldir
140 # to change this! Short explanation in the top comment in Configure
141 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
143 our $prefix = $config{prefix} || "/usr/local";
146 # The logic here is that if no --openssldir was given,
147 # OPENSSLDIR will get the value from $prefix plus "/ssl".
148 # If --openssldir was given and the value is an absolute
149 # path, OPENSSLDIR will get its value without change.
150 # If the value from --openssldir is a relative path,
151 # OPENSSLDIR will get $prefix with the --openssldir
152 # value appended as a subdirectory.
154 use File::Spec::Functions;
156 $config{openssldir} ?
157 (file_name_is_absolute($config{openssldir}) ?
159 : catdir($prefix, $config{openssldir}))
160 : catdir($prefix, "ssl");
162 LIBDIR={- our $libdir = $config{libdir};
165 # if $prefix/lib$target{multilib} is not an existing
166 # directory, then assume that it's not searched by linker
167 # automatically, in which case adding $target{multilib} suffix
168 # causes more grief than we're ready to tolerate, so don't...
170 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
171 $libdir = "lib$multilib";
173 file_name_is_absolute($libdir) ? "" : $libdir -}
174 # $(libdir) is chosen to be compatible with the GNU coding standards
175 libdir={- file_name_is_absolute($libdir)
176 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
177 ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
179 # Convenience variable for those who want to set the rpath in shared
180 # libraries and applications
183 MANDIR=$(INSTALLTOP)/share/man
184 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
185 HTMLDIR=$(DOCDIR)/html
187 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
188 # appended after the manpage file section number. "ssl" is popular,
189 # resulting in files such as config.5ssl rather than config.5.
193 # For "optional" echo messages, to get "real" silence
196 ##### User defined commands and flags ################################
198 # We let the C compiler driver to take care of .s files. This is done in
199 # order to be excused from maintaining a separate set of architecture
200 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
201 # gcc, then the driver will automatically translate it to -xarch=v8plus
202 # and pass it down to assembler. In any case, we do not define AS or
203 # ASFLAGS for this reason.
205 CROSS_COMPILE={- $config{CROSS_COMPILE} -}
206 CC=$(CROSS_COMPILE){- $config{CC} -}
207 CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
208 CPPFLAGS={- our $cppflags1 = join(" ",
209 (map { "-D".$_} @{$config{CPPDEFINES}}),
210 (map { "-I".$_} @{$config{CPPINCLUDES}}),
211 @{$config{CPPFLAGS}}) -}
212 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
213 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
214 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
215 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
217 MAKEDEPEND={- $config{makedepprog} -}
219 PERL={- $config{PERL} -}
221 AR=$(CROSS_COMPILE){- $config{AR} -}
222 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
223 RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
224 RC= $(CROSS_COMPILE){- $config{RC} -}
225 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
229 TAR= {- $target{TAR} || "tar" -}
230 TARFLAGS= {- $target{TARFLAGS} -}
233 NAME= $(BASENAME)-$(VERSION)
234 TARFILE= ../$(NAME).tar
236 ##### Project flags ##################################################
238 # Variables starting with CNF_ are common variables for all product types
240 CNF_CPPFLAGS={- our $cppflags2 =
241 join(' ', $target{cppflags} || (),
242 (map { "-D".$_} @{$target{defines}},
243 @{$config{defines}}),
244 (map { "-I".$_} @{$target{includes}},
245 @{$config{includes}}),
246 @{$config{cppflags}}) -}
247 CNF_CFLAGS={- join(' ', $target{cflags} || (),
248 @{$config{cflags}}) -}
249 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
250 @{$config{cxxflags}}) -}
251 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
252 @{$config{lflags}}) -}
253 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
254 @{$config{ex_libs}}) -}
256 # Variables starting with LIB_ are used to build library object files
257 # and shared libraries.
258 # Variables starting with DSO_ are used to build DSOs and their object files.
259 # Variables starting with BIN_ are used to build programs and their object
262 LIB_CPPFLAGS={- our $lib_cppflags =
263 join(' ', $target{lib_cppflags} || (),
264 $target{shared_cppflag} || (),
266 @{$config{lib_defines}},
267 @{$config{shared_defines}}),
268 @{$config{lib_cppflags}},
269 @{$config{shared_cppflag}});
270 join(' ', $lib_cppflags,
272 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
273 'ENGINESDIR="\"$(ENGINESDIR)\""'),
274 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
275 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
276 $target{shared_cflag} || (),
277 @{$config{lib_cflags}},
278 @{$config{shared_cflag}},
279 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
280 LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
281 $target{shared_cxxflag} || (),
282 @{$config{lib_cxxflags}},
283 @{$config{shared_cxxflag}},
284 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
285 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
286 $config{shared_ldflag} || (),
287 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
288 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
289 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
290 $target{module_cppflags} || (),
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 @{$config{bin_cppflags}},
312 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
313 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
314 @{$config{bin_cflags}},
315 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
316 BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
317 @{$config{bin_cxxflags}},
318 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
319 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
320 @{$config{bin_lflags}},
321 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
322 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
324 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
325 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
326 $cppflags2 =~ s|([\\"])|\\$1|g;
327 $lib_cppflags =~ s|([\\"])|\\$1|g;
328 join(' ', $lib_cppflags || (), $cppflags2 || (),
331 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
333 # For x86 assembler: Set PROCESSOR to 386 if you want to support
335 PROCESSOR= {- $config{processor} -}
337 # We want error [and other] messages in English. Trouble is that make(1)
338 # doesn't pass macros down as environment variables unless there already
339 # was corresponding variable originally set. In other words we can only
340 # reassign environment variables, but not set new ones, not in portable
341 # manner that is. That's why we reassign several, just to be sure...
346 # The main targets ###################################################
348 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
349 {- dependmagic('build_libs'); -}: build_libs_nodep
350 {- dependmagic('build_engines'); -}: build_engines_nodep
351 {- dependmagic('build_programs'); -}: build_programs_nodep
353 build_generated: $(GENERATED_MANDATORY)
354 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
355 build_engines_nodep: $(ENGINES)
356 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
358 # Kept around for backward compatibility
359 build_apps build_tests: build_programs
361 # Convenience target to prebuild all generated files, not just the mandatory
363 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
364 @ : {- output_off() if $disabled{makedepend}; "" -}
365 @echo "Warning: consider configuring with no-makedepend, because if"
366 @echo " target system doesn't have $(PERL),"
367 @echo " then make will fail..."
368 @ : {- output_on() if $disabled{makedepend}; "" -}
371 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
372 @ : {- output_off() if $disabled{tests}; "" -}
374 mkdir -p test-runs; \
375 SRCTOP=../$(SRCDIR) \
376 BLDTOP=../$(BLDDIR) \
379 EXE_EXT={- $exeext -} \
380 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \
381 OPENSSL_DEBUG_MEMORY=on \
382 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
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}; "" -}
388 @ : {- output_off() if $disabled{tests}; "" -}
389 @SRCTOP="$(SRCDIR)" \
390 $(PERL) $(SRCDIR)/test/run_tests.pl list
391 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
392 @echo "Tests are not supported with your chosen Configure options"
393 @ : {- output_on() if !$disabled{tests}; "" -}
395 install: install_sw install_ssldirs install_docs
397 uninstall: uninstall_docs uninstall_sw
400 @set -e; for s in $(SHLIB_INFO); do \
401 if [ "$$s" = ";" ]; then continue; fi; \
402 s1=`echo "$$s" | cut -f1 -d";"`; \
403 s2=`echo "$$s" | cut -f2 -d";"`; \
404 $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
407 $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
409 if [ "$$s1" != "$$s2" ]; then \
410 $(ECHO) $(RM) $$s2; \
415 $(RM) *.{- $defext -}
418 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
419 $(RM) $(GENERATED_MANDATORY) $(GENERATED)
420 -$(RM) `find . -name .git -prune -o -name '*{- $depext -}' -print`
421 -$(RM) `find . -name .git -prune -o -name '*{- $objext -}' -print`
423 $(RM) tags TAGS doc-nits
424 $(RM) -r test/test-runs
425 $(RM) openssl.pc libcrypto.pc libssl.pc
426 -$(RM) `find . -name .git -prune -o -type l -print`
433 # We check if any depfile is newer than Makefile and decide to
434 # concatenate only if that is true.
436 @: {- output_off() if $disabled{makedepend}; "" -}
437 @$(PERL) $(SRCDIR)/util/add-depends.pl {-
438 defined $makedepprog && $makedepprog =~ /\/makedepend/
439 ? 'makedepend' : 'gcc' -}
440 @: {- output_on() if $disabled{makedepend}; "" -}
442 # Install helper targets #############################################
444 install_sw: install_dev install_engines install_runtime
446 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
448 install_docs: install_man_docs install_html_docs
450 uninstall_docs: uninstall_man_docs uninstall_html_docs
451 $(RM) -r -v $(DESTDIR)$(DOCDIR)
454 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
455 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
456 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
457 @set -e; for x in dummy $(MISC_SCRIPTS); do \
458 if [ "$$x" = "dummy" ]; then continue; fi; \
459 x1=`echo "$$x" | cut -f1 -d:`; \
460 x2=`echo "$$x" | cut -f2 -d:`; \
461 fn=`basename $$x1`; \
462 $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
463 cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
464 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
465 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
466 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
467 if [ "$$x1" != "$$x2" ]; then \
468 ln=`basename "$$x2"`; \
469 : {- output_off() unless windowsdll(); "" -}; \
470 $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
471 cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
472 : {- output_on() unless windowsdll();
473 output_off() if windowsdll(); "" -}; \
474 $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
475 ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
476 : {- output_on() if windowsdll(); "" -}; \
479 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
480 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
481 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
482 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
483 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
484 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
485 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
486 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
488 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
489 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
490 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
491 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
492 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
493 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
494 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
495 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
498 install_dev: install_runtime_libs
499 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
500 @$(ECHO) "*** Installing development files"
501 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
502 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
503 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
504 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
505 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
506 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
507 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
508 $(BLDDIR)/include/openssl/*.h; do \
510 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
511 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
512 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
514 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
515 @set -e; for l in $(INSTALL_LIBS); do \
517 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
518 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
519 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
520 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
521 mv -f $(DESTDIR)$(libdir)/$$fn.new \
522 $(DESTDIR)$(libdir)/$$fn; \
524 @ : {- output_off() if $disabled{shared}; "" -}
525 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
526 s1=`echo "$$s" | cut -f1 -d";"`; \
527 s2=`echo "$$s" | cut -f2 -d";"`; \
528 fn1=`basename $$s1`; \
529 fn2=`basename $$s2`; \
530 : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
531 if [ "$$fn1" != "$$fn2" ]; then \
532 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
533 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
535 : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
536 $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
537 cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
538 chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
539 mv -f $(DESTDIR)$(libdir)/$$fn2.new \
540 $(DESTDIR)$(libdir)/$$fn2; \
541 : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
542 a=$(DESTDIR)$(libdir)/$$fn2; \
543 $(ECHO) "install $$s1 -> $$a"; \
544 if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
545 mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
547 for so in `$(AR) t $$a`; do \
550 strip -X32_64 -e $$so; \
551 $(AR) r $$a.new $$so; \
554 $(AR) r $$a.new $$s1; \
556 : {- output_off() if sharedaix(); output_on(); "" -}; \
558 @ : {- output_on() if $disabled{shared}; "" -}
559 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
560 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
561 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
562 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
563 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
564 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
565 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
566 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
567 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
568 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
570 uninstall_dev: uninstall_runtime_libs
571 @$(ECHO) "*** Uninstalling development files"
572 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
573 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
574 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
575 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
576 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
577 $(BLDDIR)/include/openssl/*.h; do \
579 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
580 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
582 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
583 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
584 @set -e; for l in $(INSTALL_LIBS); do \
586 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
587 $(RM) $(DESTDIR)$(libdir)/$$fn; \
589 @ : {- output_off() if $disabled{shared}; "" -}
590 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
591 s1=`echo "$$s" | cut -f1 -d";"`; \
592 s2=`echo "$$s" | cut -f2 -d";"`; \
593 fn1=`basename $$s1`; \
594 fn2=`basename $$s2`; \
595 : {- output_off() if windowsdll(); "" -}; \
596 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
597 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
598 if [ "$$fn1" != "$$fn2" -a -f "$(DESTDIR)$(libdir)/$$fn1" ]; then \
599 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
600 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
602 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
603 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
604 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
605 : {- output_on() unless windowsdll(); "" -}; \
607 @ : {- output_on() if $disabled{shared}; "" -}
608 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
609 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
610 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
611 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
612 -$(RMDIR) $(DESTDIR)$(libdir)
614 install_engines: install_runtime_libs build_engines
615 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
616 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
617 @$(ECHO) "*** Installing engines"
618 @set -e; for e in dummy $(INSTALL_ENGINES); do \
619 if [ "$$e" = "dummy" ]; then continue; fi; \
621 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
622 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
623 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
624 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
625 $(DESTDIR)$(ENGINESDIR)/$$fn; \
629 @$(ECHO) "*** Uninstalling engines"
630 @set -e; for e in dummy $(INSTALL_ENGINES); do \
631 if [ "$$e" = "dummy" ]; then continue; fi; \
633 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
636 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
637 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
639 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
641 install_runtime: install_programs
643 install_runtime_libs: build_libs
644 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
645 @ : {- output_off() if windowsdll(); "" -}
646 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
647 @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
648 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
649 @ : {- output_on() unless windowsdll(); "" -}
650 @$(ECHO) "*** Installing runtime libraries"
651 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
652 if [ "$$s" = "dummy" ]; then continue; fi; \
654 : {- output_off() unless windowsdll(); "" -}; \
655 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
656 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
657 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
658 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
659 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
660 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
661 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
662 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
663 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
664 mv -f $(DESTDIR)$(libdir)/$$fn.new \
665 $(DESTDIR)$(libdir)/$$fn; \
666 : {- output_on() if windowsdll(); "" -}; \
669 install_programs: install_runtime_libs build_programs
670 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
671 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
672 @$(ECHO) "*** Installing runtime programs"
673 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
674 if [ "$$x" = "dummy" ]; then continue; fi; \
676 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
677 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
678 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
679 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
680 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
682 @set -e; for x in dummy $(BIN_SCRIPTS); do \
683 if [ "$$x" = "dummy" ]; then continue; fi; \
685 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
686 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
687 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
688 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
689 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
692 uninstall_runtime: uninstall_programs uninstall_runtime_libs
695 @$(ECHO) "*** Uninstalling runtime programs"
696 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
698 if [ "$$x" = "dummy" ]; then continue; fi; \
700 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
701 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
703 @set -e; for x in dummy $(BIN_SCRIPTS); \
705 if [ "$$x" = "dummy" ]; then continue; fi; \
707 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
708 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
710 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
712 uninstall_runtime_libs:
713 @$(ECHO) "*** Uninstalling runtime libraries"
714 @ : {- output_off() unless windowsdll(); "" -}
715 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
716 if [ "$$s" = "dummy" ]; then continue; fi; \
718 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
719 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
721 @ : {- output_on() unless windowsdll(); "" -}
725 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
726 @$(ECHO) "*** Installing manpages"
727 $(PERL) $(SRCDIR)/util/process_docs.pl \
728 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
731 @$(ECHO) "*** Uninstalling manpages"
732 $(PERL) $(SRCDIR)/util/process_docs.pl \
733 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
737 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
738 @$(ECHO) "*** Installing HTML manpages"
739 $(PERL) $(SRCDIR)/util/process_docs.pl \
740 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
743 @$(ECHO) "*** Uninstalling manpages"
744 $(PERL) $(SRCDIR)/util/process_docs.pl \
745 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
748 # Developer targets (note: these are only available on Unix) #########
750 update: generate errors ordinals
752 generate: generate_apps generate_crypto_bn generate_crypto_objects \
753 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
757 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
758 @if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \
759 else echo 'doc-nits: no errors.'; rm doc-nits ; fi
761 # Test coverage is a good idea for the future
762 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
766 lint -DLINT $(INCLUDES) $(SRCS)
769 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
770 < apps/openssl.cnf > apps/openssl-vms.cnf )
773 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
775 generate_crypto_objects:
776 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
777 crypto/objects/objects.txt \
778 crypto/objects/obj_mac.num \
779 > crypto/objects/obj_mac.new && \
780 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
781 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
782 crypto/objects/objects.txt \
783 crypto/objects/obj_mac.num \
784 > include/openssl/obj_mac.h )
785 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
786 include/openssl/obj_mac.h \
787 > crypto/objects/obj_dat.h )
788 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
789 crypto/objects/obj_mac.num \
790 crypto/objects/obj_xref.txt \
791 > crypto/objects/obj_xref.h )
793 generate_crypto_conf:
794 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
795 > crypto/conf/conf_def.h )
797 generate_crypto_asn1:
798 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
799 > crypto/asn1/charmap.h )
802 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
803 crypto/objects/obj_dat.h \
806 # Set to -force to force a rebuild
809 ( b=`pwd`; set -e; cd $(SRCDIR); \
810 $(PERL) util/ck_errf.pl -strict -internal; \
811 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
812 ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
814 $(PERL) ../util/ck_errf.pl -strict \
815 -conf $$E `basename $$E .ec`.c; \
816 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
817 -conf $$E `basename $$E .ec`.c ; \
820 {- use File::Basename;
823 qw( include/openssl/ssl.h
824 include/openssl/ssl2.h
825 include/openssl/ssl3.h
826 include/openssl/sslerr.h
827 include/openssl/tls1.h
828 include/openssl/dtls1.h
829 include/openssl/srtp.h );
831 qw( include/internal/dso.h
832 include/internal/o_dir.h
833 include/internal/o_str.h
834 include/internal/err.h
835 include/internal/sslconf.h );
836 our @cryptoskipheaders = ( @sslheaders,
837 qw( include/openssl/conf_api.h
838 include/openssl/ebcdic.h
839 include/openssl/opensslconf.h
840 include/openssl/symhacks.h ) );
841 foreach my $f ( glob(catfile($config{sourcedir},
842 'include','openssl','*.h')) ) {
843 my $fn = "include/openssl/" . basename($f);
844 push @cryptoheaders, $fn unless grep { $_ eq $fn } @cryptoskipheaders;
848 CRYPTOHEADERS={- join(" \\\n\t", sort @cryptoheaders) -}
849 SSLHEADERS={- join(" \\\n\t", sort @sslheaders) -}
852 $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
853 --ordinals util/libcrypto.num \
854 --symhacks include/openssl/symhacks.h \
857 $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
858 --ordinals util/libssl.num \
859 --symhacks include/openssl/symhacks.h \
864 SRCTOP=../$(SRCDIR) \
865 BLDTOP=../$(BLDDIR) \
866 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
871 -etags `find . -name '*.[ch]' -o -name '*.pm'`
873 # Release targets (note: only available on Unix) #####################
876 $(SRCDIR)/util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)'
878 # Helper targets #####################################################
880 link-utils: $(BLDDIR)/util/opensslwrap.sh
882 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
883 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
884 mkdir -p "$(BLDDIR)/util"; \
885 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
890 # Building targets ###################################################
892 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
894 @ ( echo 'prefix=$(INSTALLTOP)'; \
895 echo 'exec_prefix=$${prefix}'; \
896 if [ -n "$(LIBDIR)" ]; then \
897 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
899 echo 'libdir=$(libdir)'; \
901 echo 'includedir=$${prefix}/include'; \
902 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
904 echo 'Name: OpenSSL-libcrypto'; \
905 echo 'Description: OpenSSL cryptography library'; \
906 echo 'Version: '$(VERSION); \
907 echo 'Libs: -L$${libdir} -lcrypto'; \
908 echo 'Libs.private: $(LIB_EX_LIBS)'; \
909 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
912 @ ( echo 'prefix=$(INSTALLTOP)'; \
913 echo 'exec_prefix=$${prefix}'; \
914 if [ -n "$(LIBDIR)" ]; then \
915 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
917 echo 'libdir=$(libdir)'; \
919 echo 'includedir=$${prefix}/include'; \
921 echo 'Name: OpenSSL-libssl'; \
922 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
923 echo 'Version: '$(VERSION); \
924 echo 'Requires.private: libcrypto'; \
925 echo 'Libs: -L$${libdir} -lssl'; \
926 echo 'Cflags: -I$${includedir}' ) > libssl.pc
929 @ ( echo 'prefix=$(INSTALLTOP)'; \
930 echo 'exec_prefix=$${prefix}'; \
931 if [ -n "$(LIBDIR)" ]; then \
932 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
934 echo 'libdir=$(libdir)'; \
936 echo 'includedir=$${prefix}/include'; \
938 echo 'Name: OpenSSL'; \
939 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
940 echo 'Version: '$(VERSION); \
941 echo 'Requires: libssl libcrypto' ) > openssl.pc
943 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
944 @echo "Detected changed: $?"
945 $(PERL) configdata.pm -r
946 @echo "**************************************************"
948 @echo "*** Please run the same make command again ***"
950 @echo "**************************************************"
954 $(PERL) configdata.pm -r
958 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
960 # Helper function to figure out dependencies on libraries
961 # It takes a list of library names and outputs a list of dependencies
962 sub compute_lib_depends {
963 if ($disabled{shared}) {
964 return map { lib($_) } @_;
967 # Depending on shared libraries:
968 # On Windows POSIX layers, we depend on {libname}.dll.a
969 # On Unix platforms, we depend on {shlibname}.so
970 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
975 my $generator = join(" ", @{$args{generator}});
976 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
977 my $incs = join("", map { " -I".$_ } @{$args{incs}});
978 my $defs = join("", map { " -D".$_ } @{$args{defs}});
979 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
981 if ($args{src} =~ /\.ld$/) {
982 (my $target = $args{src}) =~ s/\.ld$/${defext}/;
983 (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
984 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
986 $args{generator}->[1] || basename($args{product}, $dsoext);
988 $target: $args{generator}->[0] $deps \$(SRCDIR)/util/mkdef.pl
989 \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS $mkdef_os > $target
991 } elsif ($args{src} !~ /\.[sS]$/) {
992 if ($args{generator}->[0] =~ m|^.*\.in$|) {
993 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
994 "util", "dofile.pl")),
995 rel2abs($config{builddir}));
997 $args{src}: $args{generator}->[0] $deps
998 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
999 "-o$target{build_file}" $generator > \$@
1003 $args{src}: $args{generator}->[0] $deps
1004 \$(PERL)$generator_incs $generator > \$@
1008 if ($args{generator}->[0] =~ /\.pl$/) {
1009 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
1010 } elsif ($args{generator}->[0] =~ /\.m4$/) {
1011 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
1012 } elsif ($args{generator}->[0] =~ /\.S$/) {
1015 die "Generator type for $args{src} unknown: $generator\n";
1019 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1020 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1021 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1022 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1023 } -> {$args{intent}};
1024 if (defined($generator)) {
1026 $args{src}: $args{generator}->[0] $deps
1031 $args{src}: $args{generator}->[0] $deps
1032 \$(CC) $incs $cppflags $defs -E $args{generator}->[0] | \\
1033 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
1038 # Should one wonder about the end of the Perl snippet, it's because this
1039 # second regexp eats up line endings as well, if the removed path is the
1040 # last in the line. We may therefore need to put back a line ending.
1043 (my $obj = $args{obj}) =~ s|\.o$||;
1044 my @srcs = @{$args{srcs}};
1045 my $srcs = join(" ", @srcs);
1046 my $deps = join(" ", @srcs, @{$args{deps}});
1047 my $incs = join("", map { " -I".$_ } @{$args{incs}});
1048 my $defs = join("", map { " -D".$_ } @{$args{defs}});
1052 if (grep /\.rc$/, @srcs) {
1054 $cmdflags = '$(RCFLAGS)';
1056 } elsif (grep /\.(cc|cpp)$/, @srcs) {
1058 $cmdcompile = ' -c';
1060 shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1061 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1062 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
1063 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
1064 } -> {$args{intent}};
1067 $cmdcompile = ' -c';
1069 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1070 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1071 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1072 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1073 } -> {$args{intent}};
1076 # extension-specific rules
1077 if (grep /\.s$/, @srcs) {
1080 $cmd $cmdflags -c -o \$\@ $srcs
1082 } elsif (grep /\.S$/, @srcs) {
1083 # Originally there was mutli-step rule with $(CC) -E file.S
1084 # followed by $(CC) -c file.s. It compensated for one of
1085 # legacy platform compiler's inability to handle .S files.
1086 # The platform is long discontinued by vendor so there is
1087 # hardly a point to drag it along...
1090 $cmd $incs $defs $cmdflags -c -o \$\@ $srcs
1092 } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
1093 && !grep /\.rc$/, @srcs) {
1096 $cmd $incs $defs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
1097 \@touch $obj$depext.tmp
1098 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
1099 rm -f $obj$depext.tmp; \\
1101 mv $obj$depext.tmp $obj$depext; \\
1107 $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
1109 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
1111 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
1118 # We *know* this routine is only called when we've configure 'shared'.
1121 my $lib = $args{lib};
1122 my $shlib = $args{shlib};
1123 my $libd = dirname($lib);
1124 my $libn = basename($lib);
1125 (my $libname = $libn) =~ s/^lib//;
1127 foreach (@{args{deps}}) {
1128 my $d = dirname($_);
1129 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1131 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1132 my $linklibs = join("", map { my $f = basename($_);
1133 (my $l = $f) =~ s/^lib//;
1134 " -l$l" } @{$args{deps}});
1135 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1136 grep { $_ !~ m/\.ld$/ }
1138 my @defs = map { (my $x = $_) =~ s|\.ld$||; "$x$defext" }
1139 grep { $_ =~ /\.ld$/ }
1141 my @deps = compute_lib_depends(@{$args{deps}});
1142 die "More than one exported symbol map" if scalar @defs > 1;
1143 my $objs = join(" ", @objs);
1144 my $deps = join(" ", @objs, @defs, @deps);
1145 my $simple = shlib_simple($lib);
1146 my $full = shlib($lib);
1147 my $target = "$simple $full";
1148 my $shared_soname = "";
1149 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
1150 if defined $target{shared_sonameflag};
1151 my $shared_imp = "";
1152 $shared_imp .= ' '.$target{shared_impflag}.basename($simple)
1153 if defined $target{shared_impflag};
1154 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1155 my $recipe = <<"EOF";
1157 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1158 -o $full$shared_def $objs \\
1159 $linklibs \$(LIB_EX_LIBS)
1163 rm -f apps/$shlib'\$(SHLIB_EXT)'
1164 rm -f test/$shlib'\$(SHLIB_EXT)'
1165 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
1166 cp -p $shlib'\$(SHLIB_EXT)' apps/
1167 cp -p $shlib'\$(SHLIB_EXT)' test/
1168 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1170 } elsif (sharedaix()) {
1173 \$(AR) r $simple $full
1177 if [ '$simple' != '$full' ]; then \\
1179 ln -s $full $simple; \\
1186 my $dso = $args{lib};
1187 my $dsod = dirname($dso);
1188 my $dson = basename($dso);
1190 foreach (@{args{deps}}) {
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 { my $f = basename($_);
1196 (my $l = $f) =~ s/^lib//;
1197 " -l$l" } @{$args{deps}});
1198 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1199 grep { $_ !~ m/\.ld$/ }
1201 my @defs = map { (my $x = $_) =~ s|\.ld$||; "$x$defext" }
1202 grep { $_ =~ /\.ld$/ }
1204 my @deps = compute_lib_depends(@{$args{deps}});
1205 my $objs = join(" ", @objs);
1206 my $deps = join(" ", @objs, @defs, @deps);
1207 my $target = dso($dso);
1208 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1211 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1212 -o $target$shared_def $objs \\
1213 $linklibs \$(DSO_EX_LIBS)
1218 (my $lib = $args{lib}) =~ s/\.a$//;
1219 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1220 my $objs = join(" ", @objs);
1223 \$(AR) \$(ARFLAGS) \$\@ \$\?
1224 \$(RANLIB) \$\@ || echo Never mind.
1229 my $bin = $args{bin};
1230 my $bind = dirname($bin);
1231 my $binn = basename($bin);
1232 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1234 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1236 foreach (@{args{deps}}) {
1237 next if $_ =~ /\.a$/;
1238 my $d = dirname($_);
1239 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1241 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1242 my $linklibs = join("", map { if ($_ =~ s/\.a$//) {
1245 my $f = basename($_);
1246 (my $l = $f) =~ s/^lib//;
1251 my $cmdflags = '$(BIN_CFLAGS)';
1252 if (grep /_cc\.o$/, @{$args{objs}}) {
1254 $cmdflags = '$(BIN_CXXFLAGS)';
1257 $bin$exeext: $objs $deps
1259 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1260 -o $bin$exeext $objs \\
1261 $linklibs \$(BIN_EX_LIBS)
1266 my $script = $args{script};
1267 my $sources = join(" ", @{$args{sources}});
1268 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1269 "util", "dofile.pl")),
1270 rel2abs($config{builddir}));
1273 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1274 "-o$target{build_file}" $sources > "$script"
1280 my $dir = $args{dir};
1281 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1283 my %extinfo = ( dso => $dsoext,
1287 # We already have a 'test' target, and the top directory is just plain
1289 return if $dir eq "test" || $dir eq ".";
1291 foreach my $type (("dso", "lib", "bin", "script")) {
1292 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1293 # For lib object files, we could update the library. However, it
1294 # was decided that it's enough to build the directory local object
1295 # files, so we don't need to add any actions, and the dependencies
1296 # are already taken care of.
1297 if ($type ne "lib") {
1298 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1299 if (dirname($prod) eq $dir) {
1300 push @deps, $prod.$extinfo{$type};
1302 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1308 my $deps = join(" ", @deps);
1309 my $actions = join("\n", "", @actions);
1311 $dir $dir/: $deps$actions
1314 "" # Important! This becomes part of the template result.