2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 our $objext = $target{obj_extension} || ".o";
7 our $depext = $target{dep_extension} || ".d";
8 our $exeext = $target{exe_extension} || "";
9 our $libext = $target{lib_extension} || ".a";
10 our $shlibext = $target{shared_extension} || ".so";
11 our $shlibvariant = $target{shlib_variant} || "";
12 our $shlibextsimple = $target{shared_extension_simple} || ".so";
13 our $shlibextimport = $target{shared_import_extension} || "";
14 our $dsoext = $target{dso_extension} || ".so";
15 our $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
17 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
19 # Shared AIX support is special. We put libcrypto[64].so.ver into
20 # libcrypto.a and use libcrypto_a.a as static one.
21 sub sharedaix { !$disabled{shared} && $config{target} =~ /^aix/ }
23 our $sover_dirname = $config{shlib_version_number};
24 $sover_dirname =~ s|\.|_|g
25 if $config{target} =~ /^mingw/;
27 # shlib and shlib_simple both take a static library name and figure
28 # out what the shlib name should be.
30 # When OpenSSL is configured "no-shared", these functions will just
31 # return empty lists, making them suitable to join().
33 # With Windows DLL producers, shlib($libname) will return the shared
34 # library name (which usually is different from the static library
35 # name) with the default shared extension appended to it, while
36 # shlib_simple($libname) will return the static library name with
37 # the shared extension followed by ".a" appended to it. The former
38 # result is used as the runtime shared library while the latter is
39 # used as the DLL import library.
41 # On all Unix systems, shlib($libname) will return the library name
42 # with the default shared extension, while shlib_simple($libname)
43 # will return the name from shlib($libname) with any SO version number
44 # removed. On some systems, they may therefore return the exact same
48 return () if $disabled{shared} || $lib =~ /\.a$/;
49 return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)';
53 return () if $disabled{shared} || $lib =~ /\.a$/;
56 return $lib . '$(SHLIB_EXT_IMPORT)';
58 return $lib . '$(SHLIB_EXT_SIMPLE)';
61 # Easy fixing of static library names
63 (my $lib = shift) =~ s/\.a$//;
64 return $lib . $libext;
67 # dso is a complement to shlib / shlib_simple that returns the
68 # given libname with the simple shared extension (possible SO version
69 # removed). This differs from shlib_simple() by being unconditional.
73 return $engine . $dsoext;
75 # This makes sure things get built in the order they need
80 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
84 PLATFORM={- $config{target} -}
85 OPTIONS={- $config{options} -}
86 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
87 SRCDIR={- $config{sourcedir} -}
88 BLDDIR={- $config{builddir} -}
90 VERSION={- $config{version} -}
91 MAJOR={- $config{major} -}
92 MINOR={- $config{minor} -}
93 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
94 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
95 SHLIB_MAJOR={- $config{shlib_major} -}
96 SHLIB_MINOR={- $config{shlib_minor} -}
97 SHLIB_TARGET={- $target{shared_target} -}
98 SHLIB_EXT={- $shlibext -}
99 SHLIB_EXT_SIMPLE={- $shlibextsimple -}
100 SHLIB_EXT_IMPORT={- $shlibextimport -}
102 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
103 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
104 SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
105 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
106 PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
107 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
108 {- output_off() if $disabled{makedepend}; "" -}
109 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
110 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
111 keys %{$unified_info{sources}}); -}
112 {- output_on() if $disabled{makedepend}; "" -}
113 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
114 GENERATED={- # common0.tmpl provides @generated
115 join(" ", @generated ) -}
117 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
118 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
119 INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
120 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
121 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
122 {- output_off() if $disabled{apps}; "" -}
123 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
124 MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget.pl:tsget
125 {- output_on() if $disabled{apps}; "" -}
127 APPS_OPENSSL={- use File::Spec::Functions;
128 catfile("apps","openssl") -}
130 # DESTDIR is for package builders so that they can configure for, say,
131 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
132 # Normally it is left empty.
135 # Do not edit these manually. Use Configure with --prefix or --openssldir
136 # to change this! Short explanation in the top comment in Configure
137 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
139 our $prefix = $config{prefix} || "/usr/local";
142 # The logic here is that if no --openssldir was given,
143 # OPENSSLDIR will get the value from $prefix plus "/ssl".
144 # If --openssldir was given and the value is an absolute
145 # path, OPENSSLDIR will get its value without change.
146 # If the value from --openssldir is a relative path,
147 # OPENSSLDIR will get $prefix with the --openssldir
148 # value appended as a subdirectory.
150 use File::Spec::Functions;
152 $config{openssldir} ?
153 (file_name_is_absolute($config{openssldir}) ?
155 : catdir($prefix, $config{openssldir}))
156 : catdir($prefix, "ssl");
158 LIBDIR={- our $libdir = $config{libdir};
161 # if $prefix/lib$target{multilib} is not an existing
162 # directory, then assume that it's not searched by linker
163 # automatically, in which case adding $target{multilib} suffix
164 # causes more grief than we're ready to tolerate, so don't...
166 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
167 $libdir = "lib$multilib";
169 file_name_is_absolute($libdir) ? "" : $libdir -}
170 # $(libdir) is chosen to be compatible with the GNU coding standards
171 libdir={- file_name_is_absolute($libdir)
172 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
173 ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
175 # Convenience variable for those who want to set the rpath in shared
176 # libraries and applications
179 MANDIR=$(INSTALLTOP)/share/man
180 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
181 HTMLDIR=$(DOCDIR)/html
183 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
184 # appended after the manpage file section number. "ssl" is popular,
185 # resulting in files such as config.5ssl rather than config.5.
189 # For "optional" echo messages, to get "real" silence
192 ##### User defined commands and flags ################################
194 # We let the C compiler driver to take care of .s files. This is done in
195 # order to be excused from maintaining a separate set of architecture
196 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
197 # gcc, then the driver will automatically translate it to -xarch=v8plus
198 # and pass it down to assembler. In any case, we do not define AS or
199 # ASFLAGS for this reason.
201 CROSS_COMPILE={- $config{CROSS_COMPILE} -}
202 CC=$(CROSS_COMPILE){- $config{CC} -}
203 CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
204 CPPFLAGS={- our $cppflags1 = join(" ",
205 (map { "-D".$_} @{$config{CPPDEFINES}}),
206 (map { "-I".$_} @{$config{CPPINCLUDES}}),
207 @{$config{CPPFLAGS}}) -}
208 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
209 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
210 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
211 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
213 MAKEDEPEND={- $config{makedepprog} -}
215 PERL={- $config{PERL} -}
217 AR=$(CROSS_COMPILE){- $config{AR} -}
218 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
219 RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
220 RC= $(CROSS_COMPILE){- $config{RC} -}
221 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
225 TAR= {- $target{TAR} || "tar" -}
226 TARFLAGS= {- $target{TARFLAGS} -}
229 NAME= $(BASENAME)-$(VERSION)
230 # Relative to $(SRCDIR)
231 TARFILE= ../$(NAME).tar
233 ##### Project flags ##################################################
235 # Variables starting with CNF_ are common variables for all product types
237 CNF_CPPFLAGS={- our $cppflags2 =
238 join(' ', $target{cppflags} || (),
239 (map { "-D".$_} @{$target{defines}},
240 @{$config{defines}}),
241 (map { "-I".$_} @{$target{includes}},
242 @{$config{includes}}),
243 @{$config{cppflags}}) -}
244 CNF_CFLAGS={- join(' ', $target{cflags} || (),
245 @{$config{cflags}}) -}
246 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
247 @{$config{cxxflags}}) -}
248 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
249 @{$config{lflags}}) -}
250 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
251 @{$config{ex_libs}}) -}
253 # Variables starting with LIB_ are used to build library object files
254 # and shared libraries.
255 # Variables starting with DSO_ are used to build DSOs and their object files.
256 # Variables starting with BIN_ are used to build programs and their object
259 LIB_CPPFLAGS={- our $lib_cppflags =
260 join(' ', $target{lib_cppflags} || (),
261 $target{shared_cppflag} || (),
263 @{$config{lib_defines}},
264 @{$config{shared_defines}}),
265 @{$config{lib_cppflags}},
266 @{$config{shared_cppflag}});
267 join(' ', $lib_cppflags,
269 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
270 'ENGINESDIR="\"$(ENGINESDIR)\""'),
271 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
272 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
273 $target{shared_cflag} || (),
274 @{$config{lib_cflags}},
275 @{$config{shared_cflag}},
276 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
277 LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
278 $target{shared_cxxflag} || (),
279 @{$config{lib_cxxflags}},
280 @{$config{shared_cxxflag}},
281 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
282 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
283 $config{shared_ldflag} || (),
284 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
285 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
286 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
287 $target{module_cppflags} || (),
288 @{$config{dso_cppflags}},
289 @{$config{module_cppflags}},
290 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
291 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
292 $target{module_cflags} || (),
293 @{$config{dso_cflags}},
294 @{$config{module_cflags}},
295 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
296 DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
297 $target{module_cxxflags} || (),
298 @{$config{dso_cxxflags}},
299 @{$config{module_cxxflag}},
300 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
301 DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
302 $target{module_ldflags} || (),
303 @{$config{dso_ldflags}},
304 @{$config{module_ldflags}},
305 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
306 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
307 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
308 @{$config{bin_cppflags}},
309 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
310 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
311 @{$config{bin_cflags}},
312 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
313 BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
314 @{$config{bin_cxxflags}},
315 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
316 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
317 @{$config{bin_lflags}},
318 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
319 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
321 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
322 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
323 $cppflags2 =~ s|([\\"])|\\$1|g;
324 $lib_cppflags =~ s|([\\"])|\\$1|g;
325 join(' ', $lib_cppflags || (), $cppflags2 || (),
328 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
330 # For x86 assembler: Set PROCESSOR to 386 if you want to support
332 PROCESSOR= {- $config{processor} -}
334 # We want error [and other] messages in English. Trouble is that make(1)
335 # doesn't pass macros down as environment variables unless there already
336 # was corresponding variable originally set. In other words we can only
337 # reassign environment variables, but not set new ones, not in portable
338 # manner that is. That's why we reassign several, just to be sure...
343 # The main targets ###################################################
345 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
346 {- dependmagic('build_libs'); -}: build_libs_nodep
347 {- dependmagic('build_engines'); -}: build_engines_nodep
348 {- dependmagic('build_programs'); -}: build_programs_nodep
350 build_generated: $(GENERATED_MANDATORY)
351 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
352 build_engines_nodep: $(ENGINES)
353 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
355 # Kept around for backward compatibility
356 build_apps build_tests: build_programs
358 # Convenience target to prebuild all generated files, not just the mandatory
360 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
361 @ : {- output_off() if $disabled{makedepend}; "" -}
362 @echo "Warning: consider configuring with no-makedepend, because if"
363 @echo " target system doesn't have $(PERL),"
364 @echo " then make will fail..."
365 @ : {- output_on() if $disabled{makedepend}; "" -}
368 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
369 @ : {- output_off() if $disabled{tests}; "" -}
371 mkdir -p test-runs; \
372 SRCTOP=../$(SRCDIR) \
373 BLDTOP=../$(BLDDIR) \
376 EXE_EXT={- $exeext -} \
377 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \
378 OPENSSL_DEBUG_MEMORY=on \
379 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
380 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
381 @echo "Tests are not supported with your chosen Configure options"
382 @ : {- output_on() if !$disabled{tests}; "" -}
385 @ : {- output_off() if $disabled{tests}; "" -}
386 @SRCTOP="$(SRCDIR)" \
387 $(PERL) $(SRCDIR)/test/run_tests.pl list
388 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
389 @echo "Tests are not supported with your chosen Configure options"
390 @ : {- output_on() if !$disabled{tests}; "" -}
392 install: install_sw install_ssldirs install_docs
394 uninstall: uninstall_docs uninstall_sw
397 @set -e; for s in $(SHLIB_INFO); do \
398 if [ "$$s" = ";" ]; then continue; fi; \
399 s1=`echo "$$s" | cut -f1 -d";"`; \
400 s2=`echo "$$s" | cut -f2 -d";"`; \
401 $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
404 $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
406 if [ "$$s1" != "$$s2" ]; then \
407 $(ECHO) $(RM) $$s2; \
415 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
416 $(RM) $(GENERATED_MANDATORY) $(GENERATED)
417 -$(RM) `find . -name .git -prune -o -name '*{- $depext -}' -print`
418 -$(RM) `find . -name .git -prune -o -name '*{- $objext -}' -print`
420 $(RM) tags TAGS doc-nits
421 $(RM) -r test/test-runs
422 $(RM) openssl.pc libcrypto.pc libssl.pc
423 -$(RM) `find . -name .git -prune -o -type l -print`
430 # We check if any depfile is newer than Makefile and decide to
431 # concatenate only if that is true.
433 @: {- output_off() if $disabled{makedepend}; "" -}
434 @$(PERL) $(SRCDIR)/util/add-depends.pl {-
435 defined $makedepprog && $makedepprog =~ /\/makedepend/
436 ? 'makedepend' : 'gcc' -}
437 @: {- output_on() if $disabled{makedepend}; "" -}
439 # Install helper targets #############################################
441 install_sw: install_dev install_engines install_runtime
443 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
445 install_docs: install_man_docs install_html_docs
447 uninstall_docs: uninstall_man_docs uninstall_html_docs
448 $(RM) -r -v $(DESTDIR)$(DOCDIR)
451 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
452 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
453 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
454 @set -e; for x in dummy $(MISC_SCRIPTS); do \
455 if [ "$$x" = "dummy" ]; then continue; fi; \
456 x1=`echo "$$x" | cut -f1 -d:`; \
457 x2=`echo "$$x" | cut -f2 -d:`; \
458 fn=`basename $$x1`; \
459 $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
460 cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
461 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
462 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
463 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
464 if [ "$$x1" != "$$x2" ]; then \
465 ln=`basename "$$x2"`; \
466 : {- output_off() unless windowsdll(); "" -}; \
467 $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
468 cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
469 : {- output_on() unless windowsdll();
470 output_off() if windowsdll(); "" -}; \
471 $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
472 ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
473 : {- output_on() if windowsdll(); "" -}; \
476 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
477 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
478 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
479 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
480 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
481 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
482 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
483 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
485 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
486 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
487 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
488 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
489 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
490 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
491 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
492 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
495 install_dev: install_runtime_libs
496 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
497 @$(ECHO) "*** Installing development files"
498 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
499 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
500 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
501 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
502 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
503 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
504 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
505 $(BLDDIR)/include/openssl/*.h; do \
507 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
508 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
509 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
511 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
512 @set -e; for l in $(INSTALL_LIBS); do \
514 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
515 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
516 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
517 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
518 mv -f $(DESTDIR)$(libdir)/$$fn.new \
519 $(DESTDIR)$(libdir)/$$fn; \
521 @ : {- output_off() if $disabled{shared}; "" -}
522 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
523 s1=`echo "$$s" | cut -f1 -d";"`; \
524 s2=`echo "$$s" | cut -f2 -d";"`; \
525 fn1=`basename $$s1`; \
526 fn2=`basename $$s2`; \
527 : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
528 if [ "$$fn1" != "$$fn2" ]; then \
529 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
530 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
532 : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
533 $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
534 cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
535 chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
536 mv -f $(DESTDIR)$(libdir)/$$fn2.new \
537 $(DESTDIR)$(libdir)/$$fn2; \
538 : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
539 a=$(DESTDIR)$(libdir)/$$fn2; \
540 $(ECHO) "install $$s1 -> $$a"; \
541 if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
542 mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
544 for so in `$(AR) t $$a`; do \
547 strip -X32_64 -e $$so; \
548 $(AR) r $$a.new $$so; \
551 $(AR) r $$a.new $$s1; \
553 : {- output_off() if sharedaix(); output_on(); "" -}; \
555 @ : {- output_on() if $disabled{shared}; "" -}
556 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
557 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
558 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
559 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
560 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
561 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
562 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
563 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
564 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
565 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
567 uninstall_dev: uninstall_runtime_libs
568 @$(ECHO) "*** Uninstalling development files"
569 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
570 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
571 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
572 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
573 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
574 $(BLDDIR)/include/openssl/*.h; do \
576 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
577 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
579 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
580 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
581 @set -e; for l in $(INSTALL_LIBS); do \
583 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
584 $(RM) $(DESTDIR)$(libdir)/$$fn; \
586 @ : {- output_off() if $disabled{shared}; "" -}
587 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
588 s1=`echo "$$s" | cut -f1 -d";"`; \
589 s2=`echo "$$s" | cut -f2 -d";"`; \
590 fn1=`basename $$s1`; \
591 fn2=`basename $$s2`; \
592 : {- output_off() if windowsdll(); "" -}; \
593 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
594 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
595 if [ "$$fn1" != "$$fn2" -a -f "$(DESTDIR)$(libdir)/$$fn1" ]; then \
596 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
597 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
599 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
600 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
601 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
602 : {- output_on() unless windowsdll(); "" -}; \
604 @ : {- output_on() if $disabled{shared}; "" -}
605 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
606 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
607 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
608 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
609 -$(RMDIR) $(DESTDIR)$(libdir)
611 install_engines: install_runtime_libs build_engines
612 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
613 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
614 @$(ECHO) "*** Installing engines"
615 @set -e; for e in dummy $(INSTALL_ENGINES); do \
616 if [ "$$e" = "dummy" ]; then continue; fi; \
618 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
619 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
620 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
621 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
622 $(DESTDIR)$(ENGINESDIR)/$$fn; \
626 @$(ECHO) "*** Uninstalling engines"
627 @set -e; for e in dummy $(INSTALL_ENGINES); do \
628 if [ "$$e" = "dummy" ]; then continue; fi; \
630 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
633 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
634 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
636 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
638 install_runtime: install_programs
640 install_runtime_libs: build_libs
641 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
642 @ : {- output_off() if windowsdll(); "" -}
643 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
644 @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
645 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
646 @ : {- output_on() unless windowsdll(); "" -}
647 @$(ECHO) "*** Installing runtime libraries"
648 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
649 if [ "$$s" = "dummy" ]; then continue; fi; \
651 : {- output_off() unless windowsdll(); "" -}; \
652 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
653 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
654 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
655 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
656 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
657 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
658 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
659 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
660 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
661 mv -f $(DESTDIR)$(libdir)/$$fn.new \
662 $(DESTDIR)$(libdir)/$$fn; \
663 : {- output_on() if windowsdll(); "" -}; \
666 install_programs: install_runtime_libs build_programs
667 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
668 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
669 @$(ECHO) "*** Installing runtime programs"
670 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
671 if [ "$$x" = "dummy" ]; then continue; fi; \
673 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
674 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
675 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
676 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
677 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
679 @set -e; for x in dummy $(BIN_SCRIPTS); do \
680 if [ "$$x" = "dummy" ]; then continue; fi; \
682 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
683 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
684 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
685 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
686 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
689 uninstall_runtime: uninstall_programs uninstall_runtime_libs
692 @$(ECHO) "*** Uninstalling runtime programs"
693 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
695 if [ "$$x" = "dummy" ]; then continue; fi; \
697 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
698 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
700 @set -e; for x in dummy $(BIN_SCRIPTS); \
702 if [ "$$x" = "dummy" ]; then continue; fi; \
704 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
705 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
707 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
709 uninstall_runtime_libs:
710 @$(ECHO) "*** Uninstalling runtime libraries"
711 @ : {- output_off() unless windowsdll(); "" -}
712 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
713 if [ "$$s" = "dummy" ]; then continue; fi; \
715 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
716 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
718 @ : {- output_on() unless windowsdll(); "" -}
722 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
723 @$(ECHO) "*** Installing manpages"
724 $(PERL) $(SRCDIR)/util/process_docs.pl \
725 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
728 @$(ECHO) "*** Uninstalling manpages"
729 $(PERL) $(SRCDIR)/util/process_docs.pl \
730 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
734 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
735 @$(ECHO) "*** Installing HTML manpages"
736 $(PERL) $(SRCDIR)/util/process_docs.pl \
737 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
740 @$(ECHO) "*** Uninstalling manpages"
741 $(PERL) $(SRCDIR)/util/process_docs.pl \
742 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
745 # Developer targets (note: these are only available on Unix) #########
747 update: generate errors ordinals
749 generate: generate_apps generate_crypto_bn generate_crypto_objects \
750 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
754 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
755 @if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \
756 else echo 'doc-nits: no errors.'; rm doc-nits ; fi
758 # Test coverage is a good idea for the future
759 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
763 lint -DLINT $(INCLUDES) $(SRCS)
766 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
767 < apps/openssl.cnf > apps/openssl-vms.cnf )
770 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
772 generate_crypto_objects:
773 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
774 crypto/objects/objects.txt \
775 crypto/objects/obj_mac.num \
776 > crypto/objects/obj_mac.new && \
777 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
778 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
779 crypto/objects/objects.txt \
780 crypto/objects/obj_mac.num \
781 > include/openssl/obj_mac.h )
782 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
783 include/openssl/obj_mac.h \
784 > crypto/objects/obj_dat.h )
785 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
786 crypto/objects/obj_mac.num \
787 crypto/objects/obj_xref.txt \
788 > crypto/objects/obj_xref.h )
790 generate_crypto_conf:
791 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
792 > crypto/conf/conf_def.h )
794 generate_crypto_asn1:
795 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
796 > crypto/asn1/charmap.h )
799 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
800 crypto/objects/obj_dat.h \
803 # Set to -force to force a rebuild
806 ( b=`pwd`; set -e; cd $(SRCDIR); \
807 $(PERL) util/ck_errf.pl -strict -internal; \
808 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
809 ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
811 $(PERL) ../util/ck_errf.pl -strict \
812 -conf $$E `basename $$E .ec`.c; \
813 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
814 -conf $$E `basename $$E .ec`.c ; \
818 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
819 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
823 SRCTOP=../$(SRCDIR) \
824 BLDTOP=../$(BLDDIR) \
825 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
830 -etags `find . -name '*.[ch]' -o -name '*.pm'`
832 # Release targets (note: only available on Unix) #####################
835 (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
837 # Helper targets #####################################################
839 link-utils: $(BLDDIR)/util/opensslwrap.sh
841 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
842 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
843 mkdir -p "$(BLDDIR)/util"; \
844 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
849 # Building targets ###################################################
851 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
853 @ ( echo 'prefix=$(INSTALLTOP)'; \
854 echo 'exec_prefix=$${prefix}'; \
855 if [ -n "$(LIBDIR)" ]; then \
856 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
858 echo 'libdir=$(libdir)'; \
860 echo 'includedir=$${prefix}/include'; \
861 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
863 echo 'Name: OpenSSL-libcrypto'; \
864 echo 'Description: OpenSSL cryptography library'; \
865 echo 'Version: '$(VERSION); \
866 echo 'Libs: -L$${libdir} -lcrypto'; \
867 echo 'Libs.private: $(LIB_EX_LIBS)'; \
868 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
871 @ ( echo 'prefix=$(INSTALLTOP)'; \
872 echo 'exec_prefix=$${prefix}'; \
873 if [ -n "$(LIBDIR)" ]; then \
874 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
876 echo 'libdir=$(libdir)'; \
878 echo 'includedir=$${prefix}/include'; \
880 echo 'Name: OpenSSL-libssl'; \
881 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
882 echo 'Version: '$(VERSION); \
883 echo 'Requires.private: libcrypto'; \
884 echo 'Libs: -L$${libdir} -lssl'; \
885 echo 'Cflags: -I$${includedir}' ) > libssl.pc
888 @ ( echo 'prefix=$(INSTALLTOP)'; \
889 echo 'exec_prefix=$${prefix}'; \
890 if [ -n "$(LIBDIR)" ]; then \
891 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
893 echo 'libdir=$(libdir)'; \
895 echo 'includedir=$${prefix}/include'; \
897 echo 'Name: OpenSSL'; \
898 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
899 echo 'Version: '$(VERSION); \
900 echo 'Requires: libssl libcrypto' ) > openssl.pc
902 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
903 @echo "Detected changed: $?"
904 $(PERL) configdata.pm -r
905 @echo "**************************************************"
907 @echo "*** Please run the same make command again ***"
909 @echo "**************************************************"
913 $(PERL) configdata.pm -r
917 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
919 # Helper function to figure out dependencies on libraries
920 # It takes a list of library names and outputs a list of dependencies
921 sub compute_lib_depends {
922 if ($disabled{shared}) {
923 return map { lib($_) } @_;
926 # Depending on shared libraries:
927 # On Windows POSIX layers, we depend on {libname}.dll.a
928 # On Unix platforms, we depend on {shlibname}.so
929 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
934 my $generator = join(" ", @{$args{generator}});
935 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
936 my $incs = join("", map { " -I".$_ } @{$args{incs}});
937 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
939 if ($args{src} !~ /\.[sS]$/) {
940 if ($args{generator}->[0] =~ m|^.*\.in$|) {
941 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
942 "util", "dofile.pl")),
943 rel2abs($config{builddir}));
945 $args{src}: $args{generator}->[0] $deps
946 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
947 "-o$target{build_file}" $generator > \$@
951 $args{src}: $args{generator}->[0] $deps
952 \$(PERL)$generator_incs $generator > \$@
956 if ($args{generator}->[0] =~ /\.pl$/) {
957 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
958 } elsif ($args{generator}->[0] =~ /\.m4$/) {
959 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
960 } elsif ($args{generator}->[0] =~ /\.S$/) {
963 die "Generator type for $args{src} unknown: $generator\n";
967 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
968 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
969 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
970 } -> {$args{intent}};
971 if (defined($generator)) {
973 $args{src}: $args{generator}->[0] $deps
978 $args{src}: $args{generator}->[0] $deps
979 \$(CC) $incs $cppflags -E $args{generator}->[0] | \\
980 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
985 # Should one wonder about the end of the Perl snippet, it's because this
986 # second regexp eats up line endings as well, if the removed path is the
987 # last in the line. We may therefore need to put back a line ending.
990 (my $obj = $args{obj}) =~ s|\.o$||;
991 my @srcs = @{$args{srcs}};
992 my $srcs = join(" ", @srcs);
993 my $deps = join(" ", @srcs, @{$args{deps}});
994 my $incs = join("", map { " -I".$_ } @{$args{incs}});
998 if (grep /\.rc$/, @srcs) {
1000 $cmdflags = '$(RCFLAGS)';
1002 } elsif (grep /\.(cc|cpp)$/, @srcs) {
1004 $cmdcompile = ' -c';
1006 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1007 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
1008 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
1009 } -> {$args{intent}};
1012 $cmdcompile = ' -c';
1014 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1015 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1016 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1017 } -> {$args{intent}};
1020 # extension-specific rules
1021 if (grep /\.s$/, @srcs) {
1024 $cmd $cmdflags -c -o \$\@ $srcs
1026 } elsif (grep /\.S$/, @srcs) {
1027 # Originally there was mutli-step rule with $(CC) -E file.S
1028 # followed by $(CC) -c file.s. It compensated for one of
1029 # legacy platform compiler's inability to handle .S files.
1030 # The platform is long discontinued by vendor so there is
1031 # hardly a point to drag it along...
1034 $cmd $incs $cmdflags -c -o \$\@ $srcs
1036 } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
1037 && !grep /\.rc$/, @srcs) {
1040 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
1041 \@touch $obj$depext.tmp
1042 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
1043 rm -f $obj$depext.tmp; \\
1045 mv $obj$depext.tmp $obj$depext; \\
1051 $cmd $incs $cmdflags $cmdcompile -o \$\@ $srcs
1053 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
1055 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
1062 # We *know* this routine is only called when we've configure 'shared'.
1065 my $lib = $args{lib};
1066 my $shlib = $args{shlib};
1067 my $libd = dirname($lib);
1068 my $libn = basename($lib);
1069 (my $libname = $libn) =~ s/^lib//;
1071 foreach (@{args{deps}}) {
1072 my $d = dirname($_);
1073 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1075 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1076 my $linklibs = join("", map { my $f = basename($_);
1077 (my $l = $f) =~ s/^lib//;
1078 " -l$l" } @{$args{deps}});
1079 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1080 grep { $_ !~ m/\.(?:def|map)$/ }
1082 my @defs = grep { $_ =~ /\.(?:def|map)$/ } @{$args{objs}};
1083 my @deps = compute_lib_depends(@{$args{deps}});
1084 die "More than one exported symbol map" if scalar @defs > 1;
1085 my $objs = join(" ", @objs);
1086 my $deps = join(" ", @objs, @defs, @deps);
1087 my $simple = shlib_simple($lib);
1088 my $full = shlib($lib);
1089 my $target = "$simple $full";
1090 my $shared_soname = "";
1091 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
1092 if defined $target{shared_sonameflag};
1093 my $shared_imp = "";
1094 $shared_imp .= ' '.$target{shared_impflag}.basename($simple)
1095 if defined $target{shared_impflag};
1096 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1097 my $recipe = <<"EOF";
1099 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1100 -o $full$shared_def $objs \\
1101 $linklibs \$(LIB_EX_LIBS)
1105 rm -f apps/$shlib'\$(SHLIB_EXT)'
1106 rm -f test/$shlib'\$(SHLIB_EXT)'
1107 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
1108 cp -p $shlib'\$(SHLIB_EXT)' apps/
1109 cp -p $shlib'\$(SHLIB_EXT)' test/
1110 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1112 } elsif (sharedaix()) {
1115 \$(AR) r $simple $full
1119 if [ '$simple' != '$full' ]; then \\
1121 ln -s $full $simple; \\
1128 my $dso = $args{lib};
1129 my $dsod = dirname($dso);
1130 my $dson = basename($dso);
1132 foreach (@{args{deps}}) {
1133 my $d = dirname($_);
1134 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1136 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1137 my $linklibs = join("", map { my $f = basename($_);
1138 (my $l = $f) =~ s/^lib//;
1139 " -l$l" } @{$args{deps}});
1140 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1141 grep { $_ !~ m/\.(?:def|map)$/ }
1143 my @deps = compute_lib_depends(@{$args{deps}});
1144 my $objs = join(" ", @objs);
1145 my $deps = join(" ", @deps);
1146 my $target = dso($dso);
1148 $target: $objs $deps
1149 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1151 $linklibs \$(DSO_EX_LIBS)
1156 (my $lib = $args{lib}) =~ s/\.a$//;
1157 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1158 my $objs = join(" ", @objs);
1161 \$(AR) \$(ARFLAGS) \$\@ \$\?
1162 \$(RANLIB) \$\@ || echo Never mind.
1167 my $bin = $args{bin};
1168 my $bind = dirname($bin);
1169 my $binn = basename($bin);
1170 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1172 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1174 foreach (@{args{deps}}) {
1175 next if $_ =~ /\.a$/;
1176 my $d = dirname($_);
1177 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1179 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1180 my $linklibs = join("", map { if ($_ =~ s/\.a$//) {
1183 my $f = basename($_);
1184 (my $l = $f) =~ s/^lib//;
1189 my $cmdflags = '$(BIN_CFLAGS)';
1190 if (grep /_cc\.o$/, @{$args{objs}}) {
1192 $cmdflags = '$(BIN_CXXFLAGS)';
1195 $bin$exeext: $objs $deps
1197 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1198 -o $bin$exeext $objs \\
1199 $linklibs \$(BIN_EX_LIBS)
1204 my $script = $args{script};
1205 my $sources = join(" ", @{$args{sources}});
1206 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1207 "util", "dofile.pl")),
1208 rel2abs($config{builddir}));
1211 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1212 "-o$target{build_file}" $sources > "$script"
1218 my $dir = $args{dir};
1219 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1221 my %extinfo = ( dso => $dsoext,
1225 # We already have a 'test' target, and the top directory is just plain
1227 return if $dir eq "test" || $dir eq ".";
1229 foreach my $type (("dso", "lib", "bin", "script")) {
1230 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1231 # For lib object files, we could update the library. However, it
1232 # was decided that it's enough to build the directory local object
1233 # files, so we don't need to add any actions, and the dependencies
1234 # are already taken care of.
1235 if ($type ne "lib") {
1236 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1237 if (dirname($prod) eq $dir) {
1238 push @deps, $prod.$extinfo{$type};
1240 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1246 my $deps = join(" ", @deps);
1247 my $actions = join("\n", "", @actions);
1249 $dir $dir/: $deps$actions
1252 "" # Important! This becomes part of the template result.