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{full_version}" -}
92 MAJOR={- $config{major} -}
93 MINOR={- $config{minor} -}
94 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
95 SHLIB_TARGET={- $target{shared_target} -}
96 SHLIB_EXT={- $shlibext -}
97 SHLIB_EXT_SIMPLE={- $shlibextsimple -}
98 SHLIB_EXT_IMPORT={- $shlibextimport -}
100 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
101 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
102 SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
103 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
104 PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
105 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
106 {- output_off() if $disabled{makedepend}; "" -}
107 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
108 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
109 keys %{$unified_info{sources}}); -}
110 {- output_on() if $disabled{makedepend}; "" -}
111 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
112 GENERATED={- # common0.tmpl provides @generated
113 join(" ", map { my $x = $_;
114 $x =~ s|\.ld$|$defext|;
118 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
119 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
120 INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
121 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
122 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
123 {- output_off() if $disabled{apps}; "" -}
124 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
125 MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget.pl:tsget
126 {- output_on() if $disabled{apps}; "" -}
128 APPS_OPENSSL={- use File::Spec::Functions;
129 catfile("apps","openssl") -}
131 # DESTDIR is for package builders so that they can configure for, say,
132 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
133 # Normally it is left empty.
136 # Do not edit these manually. Use Configure with --prefix or --openssldir
137 # to change this! Short explanation in the top comment in Configure
138 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
140 our $prefix = $config{prefix} || "/usr/local";
143 # The logic here is that if no --openssldir was given,
144 # OPENSSLDIR will get the value from $prefix plus "/ssl".
145 # If --openssldir was given and the value is an absolute
146 # path, OPENSSLDIR will get its value without change.
147 # If the value from --openssldir is a relative path,
148 # OPENSSLDIR will get $prefix with the --openssldir
149 # value appended as a subdirectory.
151 use File::Spec::Functions;
153 $config{openssldir} ?
154 (file_name_is_absolute($config{openssldir}) ?
156 : catdir($prefix, $config{openssldir}))
157 : catdir($prefix, "ssl");
159 LIBDIR={- our $libdir = $config{libdir};
162 # if $prefix/lib$target{multilib} is not an existing
163 # directory, then assume that it's not searched by linker
164 # automatically, in which case adding $target{multilib} suffix
165 # causes more grief than we're ready to tolerate, so don't...
167 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
168 $libdir = "lib$multilib";
170 file_name_is_absolute($libdir) ? "" : $libdir -}
171 # $(libdir) is chosen to be compatible with the GNU coding standards
172 libdir={- file_name_is_absolute($libdir)
173 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
174 ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
176 # Convenience variable for those who want to set the rpath in shared
177 # libraries and applications
180 MANDIR=$(INSTALLTOP)/share/man
181 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
182 HTMLDIR=$(DOCDIR)/html
184 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
185 # appended after the manpage file section number. "ssl" is popular,
186 # resulting in files such as config.5ssl rather than config.5.
190 # For "optional" echo messages, to get "real" silence
193 ##### User defined commands and flags ################################
195 # We let the C compiler driver to take care of .s files. This is done in
196 # order to be excused from maintaining a separate set of architecture
197 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
198 # gcc, then the driver will automatically translate it to -xarch=v8plus
199 # and pass it down to assembler. In any case, we do not define AS or
200 # ASFLAGS for this reason.
202 CROSS_COMPILE={- $config{CROSS_COMPILE} -}
203 CC=$(CROSS_COMPILE){- $config{CC} -}
204 CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
205 CPPFLAGS={- our $cppflags1 = join(" ",
206 (map { "-D".$_} @{$config{CPPDEFINES}}),
207 (map { "-I".$_} @{$config{CPPINCLUDES}}),
208 @{$config{CPPFLAGS}}) -}
209 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
210 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
211 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
212 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
214 MAKEDEPEND={- $config{makedepprog} -}
216 PERL={- $config{PERL} -}
218 AR=$(CROSS_COMPILE){- $config{AR} -}
219 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
220 RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
221 RC= $(CROSS_COMPILE){- $config{RC} -}
222 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
226 TAR= {- $target{TAR} || "tar" -}
227 TARFLAGS= {- $target{TARFLAGS} -}
230 NAME= $(BASENAME)-$(VERSION)
231 # Relative to $(SRCDIR)
232 TARFILE= ../$(NAME).tar
234 ##### Project flags ##################################################
236 # Variables starting with CNF_ are common variables for all product types
238 CNF_CPPFLAGS={- our $cppflags2 =
239 join(' ', $target{cppflags} || (),
240 (map { "-D".$_} @{$target{defines}},
241 @{$config{defines}}),
242 (map { "-I".$_} @{$target{includes}},
243 @{$config{includes}}),
244 @{$config{cppflags}}) -}
245 CNF_CFLAGS={- join(' ', $target{cflags} || (),
246 @{$config{cflags}}) -}
247 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
248 @{$config{cxxflags}}) -}
249 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
250 @{$config{lflags}}) -}
251 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
252 @{$config{ex_libs}}) -}
254 # Variables starting with LIB_ are used to build library object files
255 # and shared libraries.
256 # Variables starting with DSO_ are used to build DSOs and their object files.
257 # Variables starting with BIN_ are used to build programs and their object
260 LIB_CPPFLAGS={- our $lib_cppflags =
261 join(' ', $target{lib_cppflags} || (),
262 $target{shared_cppflag} || (),
264 @{$config{lib_defines}},
265 @{$config{shared_defines}}),
266 @{$config{lib_cppflags}},
267 @{$config{shared_cppflag}});
268 join(' ', $lib_cppflags,
270 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
271 'ENGINESDIR="\"$(ENGINESDIR)\""'),
272 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
273 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
274 $target{shared_cflag} || (),
275 @{$config{lib_cflags}},
276 @{$config{shared_cflag}},
277 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
278 LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
279 $target{shared_cxxflag} || (),
280 @{$config{lib_cxxflags}},
281 @{$config{shared_cxxflag}},
282 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
283 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
284 $config{shared_ldflag} || (),
285 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
286 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
287 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
288 $target{module_cppflags} || (),
289 @{$config{dso_cppflags}},
290 @{$config{module_cppflags}},
291 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
292 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
293 $target{module_cflags} || (),
294 @{$config{dso_cflags}},
295 @{$config{module_cflags}},
296 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
297 DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
298 $target{module_cxxflags} || (),
299 @{$config{dso_cxxflags}},
300 @{$config{module_cxxflag}},
301 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
302 DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
303 $target{module_ldflags} || (),
304 @{$config{dso_ldflags}},
305 @{$config{module_ldflags}},
306 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
307 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
308 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
309 @{$config{bin_cppflags}},
310 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
311 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
312 @{$config{bin_cflags}},
313 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
314 BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
315 @{$config{bin_cxxflags}},
316 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
317 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
318 @{$config{bin_lflags}},
319 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
320 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
322 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
323 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
324 $cppflags2 =~ s|([\\"])|\\$1|g;
325 $lib_cppflags =~ s|([\\"])|\\$1|g;
326 join(' ', $lib_cppflags || (), $cppflags2 || (),
329 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
331 # For x86 assembler: Set PROCESSOR to 386 if you want to support
333 PROCESSOR= {- $config{processor} -}
335 # We want error [and other] messages in English. Trouble is that make(1)
336 # doesn't pass macros down as environment variables unless there already
337 # was corresponding variable originally set. In other words we can only
338 # reassign environment variables, but not set new ones, not in portable
339 # manner that is. That's why we reassign several, just to be sure...
344 # The main targets ###################################################
346 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
347 {- dependmagic('build_libs'); -}: build_libs_nodep
348 {- dependmagic('build_engines'); -}: build_engines_nodep
349 {- dependmagic('build_programs'); -}: build_programs_nodep
351 build_generated: $(GENERATED_MANDATORY)
352 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
353 build_engines_nodep: $(ENGINES)
354 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
356 # Kept around for backward compatibility
357 build_apps build_tests: build_programs
359 # Convenience target to prebuild all generated files, not just the mandatory
361 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
362 @ : {- output_off() if $disabled{makedepend}; "" -}
363 @echo "Warning: consider configuring with no-makedepend, because if"
364 @echo " target system doesn't have $(PERL),"
365 @echo " then make will fail..."
366 @ : {- output_on() if $disabled{makedepend}; "" -}
369 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
370 @ : {- output_off() if $disabled{tests}; "" -}
372 mkdir -p test-runs; \
373 SRCTOP=../$(SRCDIR) \
374 BLDTOP=../$(BLDDIR) \
377 EXE_EXT={- $exeext -} \
378 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \
379 OPENSSL_DEBUG_MEMORY=on \
380 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
381 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
382 @echo "Tests are not supported with your chosen Configure options"
383 @ : {- output_on() if !$disabled{tests}; "" -}
386 @ : {- output_off() if $disabled{tests}; "" -}
387 @SRCTOP="$(SRCDIR)" \
388 $(PERL) $(SRCDIR)/test/run_tests.pl list
389 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
390 @echo "Tests are not supported with your chosen Configure options"
391 @ : {- output_on() if !$disabled{tests}; "" -}
393 install: install_sw install_ssldirs install_docs
395 uninstall: uninstall_docs uninstall_sw
398 @set -e; for s in $(SHLIB_INFO); do \
399 if [ "$$s" = ";" ]; then continue; fi; \
400 s1=`echo "$$s" | cut -f1 -d";"`; \
401 s2=`echo "$$s" | cut -f2 -d";"`; \
402 $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
405 $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
407 if [ "$$s1" != "$$s2" ]; then \
408 $(ECHO) $(RM) $$s2; \
413 $(RM) *.{- $defext -}
416 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
417 $(RM) $(GENERATED_MANDATORY) $(GENERATED)
418 -$(RM) `find . -name .git -prune -o -name '*{- $depext -}' -print`
419 -$(RM) `find . -name .git -prune -o -name '*{- $objext -}' -print`
421 $(RM) tags TAGS doc-nits
422 $(RM) -r test/test-runs
423 $(RM) openssl.pc libcrypto.pc libssl.pc
424 -$(RM) `find . -name .git -prune -o -type l -print`
431 # We check if any depfile is newer than Makefile and decide to
432 # concatenate only if that is true.
434 @: {- output_off() if $disabled{makedepend}; "" -}
435 @$(PERL) $(SRCDIR)/util/add-depends.pl {-
436 defined $makedepprog && $makedepprog =~ /\/makedepend/
437 ? 'makedepend' : 'gcc' -}
438 @: {- output_on() if $disabled{makedepend}; "" -}
440 # Install helper targets #############################################
442 install_sw: install_dev install_engines install_runtime
444 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
446 install_docs: install_man_docs install_html_docs
448 uninstall_docs: uninstall_man_docs uninstall_html_docs
449 $(RM) -r -v $(DESTDIR)$(DOCDIR)
452 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
453 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
454 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
455 @set -e; for x in dummy $(MISC_SCRIPTS); do \
456 if [ "$$x" = "dummy" ]; then continue; fi; \
457 x1=`echo "$$x" | cut -f1 -d:`; \
458 x2=`echo "$$x" | cut -f2 -d:`; \
459 fn=`basename $$x1`; \
460 $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
461 cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
462 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
463 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
464 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
465 if [ "$$x1" != "$$x2" ]; then \
466 ln=`basename "$$x2"`; \
467 : {- output_off() unless windowsdll(); "" -}; \
468 $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
469 cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
470 : {- output_on() unless windowsdll();
471 output_off() if windowsdll(); "" -}; \
472 $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
473 ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
474 : {- output_on() if windowsdll(); "" -}; \
477 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
478 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
479 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
480 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
481 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
482 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
483 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
484 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
486 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
487 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
488 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
489 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
490 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
491 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
492 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
493 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
496 install_dev: install_runtime_libs
497 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
498 @$(ECHO) "*** Installing development files"
499 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
500 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
501 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
502 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
503 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
504 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
505 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
506 $(BLDDIR)/include/openssl/*.h; do \
508 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
509 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
510 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
512 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
513 @set -e; for l in $(INSTALL_LIBS); do \
515 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
516 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
517 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
518 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
519 mv -f $(DESTDIR)$(libdir)/$$fn.new \
520 $(DESTDIR)$(libdir)/$$fn; \
522 @ : {- output_off() if $disabled{shared}; "" -}
523 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
524 s1=`echo "$$s" | cut -f1 -d";"`; \
525 s2=`echo "$$s" | cut -f2 -d";"`; \
526 fn1=`basename $$s1`; \
527 fn2=`basename $$s2`; \
528 : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
529 if [ "$$fn1" != "$$fn2" ]; then \
530 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
531 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
533 : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
534 $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
535 cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
536 chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
537 mv -f $(DESTDIR)$(libdir)/$$fn2.new \
538 $(DESTDIR)$(libdir)/$$fn2; \
539 : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
540 a=$(DESTDIR)$(libdir)/$$fn2; \
541 $(ECHO) "install $$s1 -> $$a"; \
542 if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
543 mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
545 for so in `$(AR) t $$a`; do \
548 strip -X32_64 -e $$so; \
549 $(AR) r $$a.new $$so; \
552 $(AR) r $$a.new $$s1; \
554 : {- output_off() if sharedaix(); output_on(); "" -}; \
556 @ : {- output_on() if $disabled{shared}; "" -}
557 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
558 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
559 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
560 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
561 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
562 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
563 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
564 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
565 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
566 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
568 uninstall_dev: uninstall_runtime_libs
569 @$(ECHO) "*** Uninstalling development files"
570 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
571 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
572 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
573 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
574 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
575 $(BLDDIR)/include/openssl/*.h; do \
577 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
578 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
580 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
581 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
582 @set -e; for l in $(INSTALL_LIBS); do \
584 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
585 $(RM) $(DESTDIR)$(libdir)/$$fn; \
587 @ : {- output_off() if $disabled{shared}; "" -}
588 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
589 s1=`echo "$$s" | cut -f1 -d";"`; \
590 s2=`echo "$$s" | cut -f2 -d";"`; \
591 fn1=`basename $$s1`; \
592 fn2=`basename $$s2`; \
593 : {- output_off() if windowsdll(); "" -}; \
594 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
595 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
596 if [ "$$fn1" != "$$fn2" -a -f "$(DESTDIR)$(libdir)/$$fn1" ]; then \
597 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
598 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
600 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
601 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
602 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
603 : {- output_on() unless windowsdll(); "" -}; \
605 @ : {- output_on() if $disabled{shared}; "" -}
606 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
607 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
608 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
609 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
610 -$(RMDIR) $(DESTDIR)$(libdir)
612 install_engines: install_runtime_libs build_engines
613 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
614 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
615 @$(ECHO) "*** Installing engines"
616 @set -e; for e in dummy $(INSTALL_ENGINES); do \
617 if [ "$$e" = "dummy" ]; then continue; fi; \
619 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
620 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
621 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
622 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
623 $(DESTDIR)$(ENGINESDIR)/$$fn; \
627 @$(ECHO) "*** Uninstalling engines"
628 @set -e; for e in dummy $(INSTALL_ENGINES); do \
629 if [ "$$e" = "dummy" ]; then continue; fi; \
631 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
634 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
635 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
637 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
639 install_runtime: install_programs
641 install_runtime_libs: build_libs
642 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
643 @ : {- output_off() if windowsdll(); "" -}
644 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
645 @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
646 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
647 @ : {- output_on() unless windowsdll(); "" -}
648 @$(ECHO) "*** Installing runtime libraries"
649 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
650 if [ "$$s" = "dummy" ]; then continue; fi; \
652 : {- output_off() unless windowsdll(); "" -}; \
653 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
654 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
655 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
656 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
657 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
658 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
659 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
660 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
661 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
662 mv -f $(DESTDIR)$(libdir)/$$fn.new \
663 $(DESTDIR)$(libdir)/$$fn; \
664 : {- output_on() if windowsdll(); "" -}; \
667 install_programs: install_runtime_libs build_programs
668 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
669 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
670 @$(ECHO) "*** Installing runtime programs"
671 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
672 if [ "$$x" = "dummy" ]; then continue; fi; \
674 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
675 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
676 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
677 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
678 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
680 @set -e; for x in dummy $(BIN_SCRIPTS); do \
681 if [ "$$x" = "dummy" ]; then continue; fi; \
683 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
684 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
685 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
686 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
687 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
690 uninstall_runtime: uninstall_programs uninstall_runtime_libs
693 @$(ECHO) "*** Uninstalling runtime programs"
694 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
696 if [ "$$x" = "dummy" ]; then continue; fi; \
698 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
699 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
701 @set -e; for x in dummy $(BIN_SCRIPTS); \
703 if [ "$$x" = "dummy" ]; then continue; fi; \
705 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
706 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
708 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
710 uninstall_runtime_libs:
711 @$(ECHO) "*** Uninstalling runtime libraries"
712 @ : {- output_off() unless windowsdll(); "" -}
713 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
714 if [ "$$s" = "dummy" ]; then continue; fi; \
716 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
717 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
719 @ : {- output_on() unless windowsdll(); "" -}
723 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
724 @$(ECHO) "*** Installing manpages"
725 $(PERL) $(SRCDIR)/util/process_docs.pl \
726 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
729 @$(ECHO) "*** Uninstalling manpages"
730 $(PERL) $(SRCDIR)/util/process_docs.pl \
731 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
735 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
736 @$(ECHO) "*** Installing HTML manpages"
737 $(PERL) $(SRCDIR)/util/process_docs.pl \
738 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
741 @$(ECHO) "*** Uninstalling manpages"
742 $(PERL) $(SRCDIR)/util/process_docs.pl \
743 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
746 # Developer targets (note: these are only available on Unix) #########
748 update: generate errors ordinals
750 generate: generate_apps generate_crypto_bn generate_crypto_objects \
751 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
755 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
756 @if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \
757 else echo 'doc-nits: no errors.'; rm doc-nits ; fi
759 # Test coverage is a good idea for the future
760 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
764 lint -DLINT $(INCLUDES) $(SRCS)
767 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
768 < apps/openssl.cnf > apps/openssl-vms.cnf )
771 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
773 generate_crypto_objects:
774 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
775 crypto/objects/objects.txt \
776 crypto/objects/obj_mac.num \
777 > crypto/objects/obj_mac.new && \
778 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
779 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
780 crypto/objects/objects.txt \
781 crypto/objects/obj_mac.num \
782 > include/openssl/obj_mac.h )
783 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
784 include/openssl/obj_mac.h \
785 > crypto/objects/obj_dat.h )
786 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
787 crypto/objects/obj_mac.num \
788 crypto/objects/obj_xref.txt \
789 > crypto/objects/obj_xref.h )
791 generate_crypto_conf:
792 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
793 > crypto/conf/conf_def.h )
795 generate_crypto_asn1:
796 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
797 > crypto/asn1/charmap.h )
800 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
801 crypto/objects/obj_dat.h \
804 # Set to -force to force a rebuild
807 ( b=`pwd`; set -e; cd $(SRCDIR); \
808 $(PERL) util/ck_errf.pl -strict -internal; \
809 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
810 ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
812 $(PERL) ../util/ck_errf.pl -strict \
813 -conf $$E `basename $$E .ec`.c; \
814 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
815 -conf $$E `basename $$E .ec`.c ; \
818 {- use File::Basename;
821 qw( include/openssl/ssl.h
822 include/openssl/ssl2.h
823 include/openssl/ssl3.h
824 include/openssl/sslerr.h
825 include/openssl/tls1.h
826 include/openssl/dtls1.h
827 include/openssl/srtp.h );
829 qw( include/internal/dso.h
830 include/internal/o_dir.h
831 include/internal/o_str.h
832 include/internal/err.h
833 include/internal/sslconf.h );
834 our @cryptoskipheaders = ( @sslheaders,
835 qw( include/openssl/conf_api.h
836 include/openssl/ebcdic.h
837 include/openssl/opensslconf.h
838 include/openssl/symhacks.h ) );
839 foreach my $f ( glob(catfile($config{sourcedir},
840 'include','openssl','*.h')) ) {
841 my $fn = "include/openssl/" . basename($f);
842 push @cryptoheaders, $fn unless grep { $_ eq $fn } @cryptoskipheaders;
846 CRYPTOHEADERS={- join(" \\\n\t", sort @cryptoheaders) -}
847 SSLHEADERS={- join(" \\\n\t", sort @sslheaders) -}
850 $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
851 --ordinals util/libcrypto.num \
852 --symhacks include/openssl/symhacks.h \
855 $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
856 --ordinals util/libssl.num \
857 --symhacks include/openssl/symhacks.h \
862 SRCTOP=../$(SRCDIR) \
863 BLDTOP=../$(BLDDIR) \
864 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
869 -etags `find . -name '*.[ch]' -o -name '*.pm'`
871 # Release targets (note: only available on Unix) #####################
874 (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
876 # Helper targets #####################################################
878 link-utils: $(BLDDIR)/util/opensslwrap.sh
880 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
881 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
882 mkdir -p "$(BLDDIR)/util"; \
883 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
888 # Building targets ###################################################
890 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
892 @ ( echo 'prefix=$(INSTALLTOP)'; \
893 echo 'exec_prefix=$${prefix}'; \
894 if [ -n "$(LIBDIR)" ]; then \
895 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
897 echo 'libdir=$(libdir)'; \
899 echo 'includedir=$${prefix}/include'; \
900 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
902 echo 'Name: OpenSSL-libcrypto'; \
903 echo 'Description: OpenSSL cryptography library'; \
904 echo 'Version: '$(VERSION); \
905 echo 'Libs: -L$${libdir} -lcrypto'; \
906 echo 'Libs.private: $(LIB_EX_LIBS)'; \
907 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
910 @ ( echo 'prefix=$(INSTALLTOP)'; \
911 echo 'exec_prefix=$${prefix}'; \
912 if [ -n "$(LIBDIR)" ]; then \
913 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
915 echo 'libdir=$(libdir)'; \
917 echo 'includedir=$${prefix}/include'; \
919 echo 'Name: OpenSSL-libssl'; \
920 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
921 echo 'Version: '$(VERSION); \
922 echo 'Requires.private: libcrypto'; \
923 echo 'Libs: -L$${libdir} -lssl'; \
924 echo 'Cflags: -I$${includedir}' ) > libssl.pc
927 @ ( echo 'prefix=$(INSTALLTOP)'; \
928 echo 'exec_prefix=$${prefix}'; \
929 if [ -n "$(LIBDIR)" ]; then \
930 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
932 echo 'libdir=$(libdir)'; \
934 echo 'includedir=$${prefix}/include'; \
936 echo 'Name: OpenSSL'; \
937 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
938 echo 'Version: '$(VERSION); \
939 echo 'Requires: libssl libcrypto' ) > openssl.pc
941 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
942 @echo "Detected changed: $?"
943 $(PERL) configdata.pm -r
944 @echo "**************************************************"
946 @echo "*** Please run the same make command again ***"
948 @echo "**************************************************"
952 $(PERL) configdata.pm -r
956 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
958 # Helper function to figure out dependencies on libraries
959 # It takes a list of library names and outputs a list of dependencies
960 sub compute_lib_depends {
961 if ($disabled{shared}) {
962 return map { lib($_) } @_;
965 # Depending on shared libraries:
966 # On Windows POSIX layers, we depend on {libname}.dll.a
967 # On Unix platforms, we depend on {shlibname}.so
968 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
973 my $generator = join(" ", @{$args{generator}});
974 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
975 my $incs = join("", map { " -I".$_ } @{$args{incs}});
976 my $defs = join("", map { " -D".$_ } @{$args{defs}});
977 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
979 if ($args{src} =~ /\.ld$/) {
980 (my $target = $args{src}) =~ s/\.ld$/${defext}/;
981 (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
982 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
984 $args{generator}->[1] || basename($args{product}, $dsoext);
986 $target: $args{generator}->[0] $deps \$(SRCDIR)/util/mkdef.pl
987 \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS $mkdef_os > $target
989 } elsif ($args{src} !~ /\.[sS]$/) {
990 if ($args{generator}->[0] =~ m|^.*\.in$|) {
991 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
992 "util", "dofile.pl")),
993 rel2abs($config{builddir}));
995 $args{src}: $args{generator}->[0] $deps
996 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
997 "-o$target{build_file}" $generator > \$@
1001 $args{src}: $args{generator}->[0] $deps
1002 \$(PERL)$generator_incs $generator > \$@
1006 if ($args{generator}->[0] =~ /\.pl$/) {
1007 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
1008 } elsif ($args{generator}->[0] =~ /\.m4$/) {
1009 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
1010 } elsif ($args{generator}->[0] =~ /\.S$/) {
1013 die "Generator type for $args{src} unknown: $generator\n";
1017 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1018 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1019 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1020 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1021 } -> {$args{intent}};
1022 if (defined($generator)) {
1024 $args{src}: $args{generator}->[0] $deps
1029 $args{src}: $args{generator}->[0] $deps
1030 \$(CC) $incs $cppflags $defs -E $args{generator}->[0] | \\
1031 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
1036 # Should one wonder about the end of the Perl snippet, it's because this
1037 # second regexp eats up line endings as well, if the removed path is the
1038 # last in the line. We may therefore need to put back a line ending.
1041 (my $obj = $args{obj}) =~ s|\.o$||;
1042 my @srcs = @{$args{srcs}};
1043 my $srcs = join(" ", @srcs);
1044 my $deps = join(" ", @srcs, @{$args{deps}});
1045 my $incs = join("", map { " -I".$_ } @{$args{incs}});
1046 my $defs = join("", map { " -D".$_ } @{$args{defs}});
1050 if (grep /\.rc$/, @srcs) {
1052 $cmdflags = '$(RCFLAGS)';
1054 } elsif (grep /\.(cc|cpp)$/, @srcs) {
1056 $cmdcompile = ' -c';
1058 shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1059 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1060 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
1061 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
1062 } -> {$args{intent}};
1065 $cmdcompile = ' -c';
1067 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1068 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1069 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1070 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1071 } -> {$args{intent}};
1074 # extension-specific rules
1075 if (grep /\.s$/, @srcs) {
1078 $cmd $cmdflags -c -o \$\@ $srcs
1080 } elsif (grep /\.S$/, @srcs) {
1081 # Originally there was mutli-step rule with $(CC) -E file.S
1082 # followed by $(CC) -c file.s. It compensated for one of
1083 # legacy platform compiler's inability to handle .S files.
1084 # The platform is long discontinued by vendor so there is
1085 # hardly a point to drag it along...
1088 $cmd $incs $defs $cmdflags -c -o \$\@ $srcs
1090 } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
1091 && !grep /\.rc$/, @srcs) {
1094 $cmd $incs $defs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
1095 \@touch $obj$depext.tmp
1096 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
1097 rm -f $obj$depext.tmp; \\
1099 mv $obj$depext.tmp $obj$depext; \\
1105 $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
1107 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
1109 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
1116 # We *know* this routine is only called when we've configure 'shared'.
1119 my $lib = $args{lib};
1120 my $shlib = $args{shlib};
1121 my $libd = dirname($lib);
1122 my $libn = basename($lib);
1123 (my $libname = $libn) =~ s/^lib//;
1125 foreach (@{args{deps}}) {
1126 my $d = dirname($_);
1127 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1129 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1130 my $linklibs = join("", map { my $f = basename($_);
1131 (my $l = $f) =~ s/^lib//;
1132 " -l$l" } @{$args{deps}});
1133 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1134 grep { $_ !~ m/\.ld$/ }
1136 my @defs = map { (my $x = $_) =~ s|\.ld$||; "$x$defext" }
1137 grep { $_ =~ /\.ld$/ }
1139 my @deps = compute_lib_depends(@{$args{deps}});
1140 die "More than one exported symbol map" if scalar @defs > 1;
1141 my $objs = join(" ", @objs);
1142 my $deps = join(" ", @objs, @defs, @deps);
1143 my $simple = shlib_simple($lib);
1144 my $full = shlib($lib);
1145 my $target = "$simple $full";
1146 my $shared_soname = "";
1147 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
1148 if defined $target{shared_sonameflag};
1149 my $shared_imp = "";
1150 $shared_imp .= ' '.$target{shared_impflag}.basename($simple)
1151 if defined $target{shared_impflag};
1152 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1153 my $recipe = <<"EOF";
1155 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1156 -o $full$shared_def $objs \\
1157 $linklibs \$(LIB_EX_LIBS)
1161 rm -f apps/$shlib'\$(SHLIB_EXT)'
1162 rm -f test/$shlib'\$(SHLIB_EXT)'
1163 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
1164 cp -p $shlib'\$(SHLIB_EXT)' apps/
1165 cp -p $shlib'\$(SHLIB_EXT)' test/
1166 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1168 } elsif (sharedaix()) {
1171 \$(AR) r $simple $full
1175 if [ '$simple' != '$full' ]; then \\
1177 ln -s $full $simple; \\
1184 my $dso = $args{lib};
1185 my $dsod = dirname($dso);
1186 my $dson = basename($dso);
1188 foreach (@{args{deps}}) {
1189 my $d = dirname($_);
1190 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1192 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1193 my $linklibs = join("", map { my $f = basename($_);
1194 (my $l = $f) =~ s/^lib//;
1195 " -l$l" } @{$args{deps}});
1196 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1197 grep { $_ !~ m/\.ld$/ }
1199 my @defs = map { (my $x = $_) =~ s|\.ld$||; "$x$defext" }
1200 grep { $_ =~ /\.ld$/ }
1202 my @deps = compute_lib_depends(@{$args{deps}});
1203 my $objs = join(" ", @objs);
1204 my $deps = join(" ", @objs, @defs, @deps);
1205 my $target = dso($dso);
1206 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1209 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1210 -o $target$shared_def $objs \\
1211 $linklibs \$(DSO_EX_LIBS)
1216 (my $lib = $args{lib}) =~ s/\.a$//;
1217 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1218 my $objs = join(" ", @objs);
1221 \$(AR) \$(ARFLAGS) \$\@ \$\?
1222 \$(RANLIB) \$\@ || echo Never mind.
1227 my $bin = $args{bin};
1228 my $bind = dirname($bin);
1229 my $binn = basename($bin);
1230 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1232 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1234 foreach (@{args{deps}}) {
1235 next if $_ =~ /\.a$/;
1236 my $d = dirname($_);
1237 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1239 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1240 my $linklibs = join("", map { if ($_ =~ s/\.a$//) {
1243 my $f = basename($_);
1244 (my $l = $f) =~ s/^lib//;
1249 my $cmdflags = '$(BIN_CFLAGS)';
1250 if (grep /_cc\.o$/, @{$args{objs}}) {
1252 $cmdflags = '$(BIN_CXXFLAGS)';
1255 $bin$exeext: $objs $deps
1257 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1258 -o $bin$exeext $objs \\
1259 $linklibs \$(BIN_EX_LIBS)
1264 my $script = $args{script};
1265 my $sources = join(" ", @{$args{sources}});
1266 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1267 "util", "dofile.pl")),
1268 rel2abs($config{builddir}));
1271 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1272 "-o$target{build_file}" $sources > "$script"
1278 my $dir = $args{dir};
1279 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1281 my %extinfo = ( dso => $dsoext,
1285 # We already have a 'test' target, and the top directory is just plain
1287 return if $dir eq "test" || $dir eq ".";
1289 foreach my $type (("dso", "lib", "bin", "script")) {
1290 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1291 # For lib object files, we could update the library. However, it
1292 # was decided that it's enough to build the directory local object
1293 # files, so we don't need to add any actions, and the dependencies
1294 # are already taken care of.
1295 if ($type ne "lib") {
1296 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1297 if (dirname($prod) eq $dir) {
1298 push @deps, $prod.$extinfo{$type};
1300 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1306 my $deps = join(" ", @deps);
1307 my $actions = join("\n", "", @actions);
1309 $dir $dir/: $deps$actions
1312 "" # Important! This becomes part of the template result.