2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 our $makedepprog = platform->makedepprog();
8 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
10 # Shared AIX support is special. We put libcrypto[64].so.ver into
11 # libcrypto.a and use libcrypto_a.a as static one.
12 sub sharedaix { !$disabled{shared} && $config{target} =~ /^aix/ }
14 our $sover_dirname = platform->shlib_version_as_filename();
16 # This makes sure things get built in the order they need
21 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
25 PLATFORM={- $config{target} -}
26 OPTIONS={- $config{options} -}
27 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
28 SRCDIR={- $config{sourcedir} -}
29 BLDDIR={- $config{builddir} -}
31 VERSION={- "$config{full_version}" -}
32 MAJOR={- $config{major} -}
33 MINOR={- $config{minor} -}
34 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
35 SHLIB_TARGET={- $target{shared_target} -}
37 LIBS={- join(" ", map { platform->staticlib($_) // () } @{$unified_info{libraries}}) -}
38 SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
39 SHLIB_INFO={- join(" ", map { my $x = platform->sharedlib($_);
40 my $y = platform->sharedlib_simple($_);
41 $x ? "\"$x;$y\"" : () }
42 @{$unified_info{libraries}}) -}
43 ENGINES={- join(" ", map { platform->dso($_) } @{$unified_info{engines}}) -}
44 PROGRAMS={- join(" ", map { platform->bin($_) } @{$unified_info{programs}}) -}
45 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
46 {- output_off() if $disabled{makedepend}; "" -}
47 DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
48 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
49 keys %{$unified_info{sources}}); -}
50 {- output_on() if $disabled{makedepend}; "" -}
51 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
52 GENERATED={- # common0.tmpl provides @generated
53 join(" ", map { platform->convertext($_) } @generated ) -}
56 join(" ", map { platform->staticlib($_) // () }
57 grep { !$unified_info{attributes}->{$_}->{noinst} }
58 @{$unified_info{libraries}})
61 join(" ", map { platform->sharedlib($_) // () }
62 grep { !$unified_info{attributes}->{$_}->{noinst} }
63 @{$unified_info{libraries}})
66 join(" ", map { my $x = platform->sharedlib($_);
67 my $y = platform->sharedlib_simple($_);
68 $x ? "\"$x;$y\"" : () }
69 grep { !$unified_info{attributes}->{$_}->{noinst} }
70 @{$unified_info{libraries}})
73 join(" ", map { platform->dso($_) }
74 grep { !$unified_info{attributes}->{$_}->{noinst} }
75 @{$unified_info{engines}})
78 join(" ", map { platform->bin($_) }
79 grep { !$unified_info{attributes}->{$_}->{noinst} }
80 @{$unified_info{programs}})
83 join(" ", map { my $x = $unified_info{attributes}->{$_}->{linkname};
85 grep { !$unified_info{attributes}->{$_}->{noinst}
86 && !$unified_info{attributes}->{$_}->{misc} }
87 @{$unified_info{scripts}})
90 join(" ", map { my $x = $unified_info{attributes}->{$_}->{linkname};
92 grep { !$unified_info{attributes}->{$_}->{noinst}
93 && $unified_info{attributes}->{$_}->{misc} }
94 @{$unified_info{scripts}})
97 APPS_OPENSSL={- use File::Spec::Functions;
98 catfile("apps","openssl") -}
100 # DESTDIR is for package builders so that they can configure for, say,
101 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
102 # Normally it is left empty.
105 # Do not edit these manually. Use Configure with --prefix or --openssldir
106 # to change this! Short explanation in the top comment in Configure
107 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
109 our $prefix = $config{prefix} || "/usr/local";
112 # The logic here is that if no --openssldir was given,
113 # OPENSSLDIR will get the value from $prefix plus "/ssl".
114 # If --openssldir was given and the value is an absolute
115 # path, OPENSSLDIR will get its value without change.
116 # If the value from --openssldir is a relative path,
117 # OPENSSLDIR will get $prefix with the --openssldir
118 # value appended as a subdirectory.
120 use File::Spec::Functions;
122 $config{openssldir} ?
123 (file_name_is_absolute($config{openssldir}) ?
125 : catdir($prefix, $config{openssldir}))
126 : catdir($prefix, "ssl");
128 LIBDIR={- our $libdir = $config{libdir};
131 # if $prefix/lib$target{multilib} is not an existing
132 # directory, then assume that it's not searched by linker
133 # automatically, in which case adding $target{multilib} suffix
134 # causes more grief than we're ready to tolerate, so don't...
136 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
137 $libdir = "lib$multilib";
139 file_name_is_absolute($libdir) ? "" : $libdir -}
140 # $(libdir) is chosen to be compatible with the GNU coding standards
141 libdir={- file_name_is_absolute($libdir)
142 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
143 ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
145 # Convenience variable for those who want to set the rpath in shared
146 # libraries and applications
149 MANDIR=$(INSTALLTOP)/share/man
150 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
151 HTMLDIR=$(DOCDIR)/html
153 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
154 # appended after the manpage file section number. "ssl" is popular,
155 # resulting in files such as config.5ssl rather than config.5.
159 # For "optional" echo messages, to get "real" silence
162 ##### User defined commands and flags ################################
164 # We let the C compiler driver to take care of .s files. This is done in
165 # order to be excused from maintaining a separate set of architecture
166 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
167 # gcc, then the driver will automatically translate it to -xarch=v8plus
168 # and pass it down to assembler. In any case, we do not define AS or
169 # ASFLAGS for this reason.
171 CROSS_COMPILE={- $config{CROSS_COMPILE} -}
172 CC=$(CROSS_COMPILE){- $config{CC} -}
173 CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
174 CPPFLAGS={- our $cppflags1 = join(" ",
175 (map { "-D".$_} @{$config{CPPDEFINES}}),
176 (map { "-I".$_} @{$config{CPPINCLUDES}}),
177 @{$config{CPPFLAGS}}) -}
178 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
179 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
180 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
181 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
183 MAKEDEPEND={- $config{makedepprog} -}
185 PERL={- $config{PERL} -}
187 AR=$(CROSS_COMPILE){- $config{AR} -}
188 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
189 RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
190 RC= $(CROSS_COMPILE){- $config{RC} -}
191 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
195 TAR= {- $target{TAR} || "tar" -}
196 TARFLAGS= {- $target{TARFLAGS} -}
199 NAME= $(BASENAME)-$(VERSION)
200 # Relative to $(SRCDIR)
201 TARFILE= ../$(NAME).tar
203 ##### Project flags ##################################################
205 # Variables starting with CNF_ are common variables for all product types
207 CNF_CPPFLAGS={- our $cppflags2 =
208 join(' ', $target{cppflags} || (),
209 (map { "-D".$_} @{$target{defines}},
210 @{$config{defines}}),
211 (map { "-I".$_} @{$target{includes}},
212 @{$config{includes}}),
213 @{$config{cppflags}}) -}
214 CNF_CFLAGS={- join(' ', $target{cflags} || (),
215 @{$config{cflags}}) -}
216 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
217 @{$config{cxxflags}}) -}
218 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
219 @{$config{lflags}}) -}
220 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
221 @{$config{ex_libs}}) -}
223 # Variables starting with LIB_ are used to build library object files
224 # and shared libraries.
225 # Variables starting with DSO_ are used to build DSOs and their object files.
226 # Variables starting with BIN_ are used to build programs and their object
229 LIB_CPPFLAGS={- our $lib_cppflags =
230 join(' ', $target{lib_cppflags} || (),
231 $target{shared_cppflag} || (),
233 @{$config{lib_defines}},
234 @{$config{shared_defines}}),
235 @{$config{lib_cppflags}},
236 @{$config{shared_cppflag}});
237 join(' ', $lib_cppflags,
239 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
240 'ENGINESDIR="\"$(ENGINESDIR)\""'),
241 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
242 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
243 $target{shared_cflag} || (),
244 @{$config{lib_cflags}},
245 @{$config{shared_cflag}},
246 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
247 LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
248 $target{shared_cxxflag} || (),
249 @{$config{lib_cxxflags}},
250 @{$config{shared_cxxflag}},
251 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
252 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
253 $config{shared_ldflag} || (),
254 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
255 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
256 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
257 $target{module_cppflags} || (),
258 @{$config{dso_cppflags}},
259 @{$config{module_cppflags}},
260 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
261 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
262 $target{module_cflags} || (),
263 @{$config{dso_cflags}},
264 @{$config{module_cflags}},
265 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
266 DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
267 $target{module_cxxflags} || (),
268 @{$config{dso_cxxflags}},
269 @{$config{module_cxxflag}},
270 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
271 DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
272 $target{module_ldflags} || (),
273 @{$config{dso_ldflags}},
274 @{$config{module_ldflags}},
275 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
276 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
277 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
278 @{$config{bin_cppflags}},
279 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
280 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
281 @{$config{bin_cflags}},
282 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
283 BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
284 @{$config{bin_cxxflags}},
285 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
286 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
287 @{$config{bin_lflags}},
288 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
289 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
291 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
292 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
293 $cppflags2 =~ s|([\\"])|\\$1|g;
294 $lib_cppflags =~ s|([\\"])|\\$1|g;
295 join(' ', $lib_cppflags || (), $cppflags2 || (),
298 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
300 # For x86 assembler: Set PROCESSOR to 386 if you want to support
302 PROCESSOR= {- $config{processor} -}
304 # We want error [and other] messages in English. Trouble is that make(1)
305 # doesn't pass macros down as environment variables unless there already
306 # was corresponding variable originally set. In other words we can only
307 # reassign environment variables, but not set new ones, not in portable
308 # manner that is. That's why we reassign several, just to be sure...
313 # The main targets ###################################################
315 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
316 {- dependmagic('build_libs'); -}: build_libs_nodep
317 {- dependmagic('build_engines'); -}: build_engines_nodep
318 {- dependmagic('build_programs'); -}: build_programs_nodep
320 build_generated: $(GENERATED_MANDATORY)
321 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
322 build_engines_nodep: $(ENGINES)
323 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
325 # Kept around for backward compatibility
326 build_apps build_tests: build_programs
328 # Convenience target to prebuild all generated files, not just the mandatory
330 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
331 @ : {- output_off() if $disabled{makedepend}; "" -}
332 @echo "Warning: consider configuring with no-makedepend, because if"
333 @echo " target system doesn't have $(PERL),"
334 @echo " then make will fail..."
335 @ : {- output_on() if $disabled{makedepend}; "" -}
338 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
339 @ : {- output_off() if $disabled{tests}; "" -}
341 mkdir -p test-runs; \
342 SRCTOP=../$(SRCDIR) \
343 BLDTOP=../$(BLDDIR) \
346 EXE_EXT={- platform->binext() -} \
347 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \
348 OPENSSL_DEBUG_MEMORY=on \
349 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
350 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
351 @echo "Tests are not supported with your chosen Configure options"
352 @ : {- output_on() if !$disabled{tests}; "" -}
355 @ : {- output_off() if $disabled{tests}; "" -}
356 @SRCTOP="$(SRCDIR)" \
357 $(PERL) $(SRCDIR)/test/run_tests.pl list
358 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
359 @echo "Tests are not supported with your chosen Configure options"
360 @ : {- output_on() if !$disabled{tests}; "" -}
362 install: install_sw install_ssldirs install_docs
364 uninstall: uninstall_docs uninstall_sw
367 @set -e; for s in $(SHLIB_INFO); do \
368 if [ "$$s" = ";" ]; then continue; fi; \
369 s1=`echo "$$s" | cut -f1 -d";"`; \
370 s2=`echo "$$s" | cut -f2 -d";"`; \
371 $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
374 $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
376 if [ "$$s1" != "$$s2" ]; then \
377 $(ECHO) $(RM) $$s2; \
382 $(RM) *{- platform->defext() -}
385 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
386 $(RM) $(GENERATED_MANDATORY) $(GENERATED)
387 -$(RM) `find . -name .git -prune -o -name '*{- platform->depext() -}' -print`
388 -$(RM) `find . -name .git -prune -o -name '*{- platform->objext() -}' -print`
390 $(RM) tags TAGS doc-nits
391 $(RM) -r test/test-runs
392 $(RM) openssl.pc libcrypto.pc libssl.pc
393 -$(RM) `find . -name .git -prune -o -type l -print`
400 # We check if any depfile is newer than Makefile and decide to
401 # concatenate only if that is true.
403 @: {- output_off() if $disabled{makedepend}; "" -}
404 @$(PERL) $(SRCDIR)/util/add-depends.pl {-
405 defined $makedepprog && $makedepprog =~ /\/makedepend/
406 ? 'makedepend' : 'gcc' -}
407 @: {- output_on() if $disabled{makedepend}; "" -}
409 # Install helper targets #############################################
411 install_sw: install_dev install_engines install_runtime
413 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
415 install_docs: install_man_docs install_html_docs
417 uninstall_docs: uninstall_man_docs uninstall_html_docs
418 $(RM) -r -v $(DESTDIR)$(DOCDIR)
421 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
422 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
423 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
424 @set -e; for x in dummy $(MISC_SCRIPTS); do \
425 if [ "$$x" = "dummy" ]; then continue; fi; \
426 x1=`echo "$$x" | cut -f1 -d:`; \
427 x2=`echo "$$x" | cut -f2 -d:`; \
428 fn=`basename $$x1`; \
429 $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
430 cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
431 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
432 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
433 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
434 if [ "$$x1" != "$$x2" ]; then \
435 ln=`basename "$$x2"`; \
436 : {- output_off() unless windowsdll(); "" -}; \
437 $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
438 cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
439 : {- output_on() unless windowsdll();
440 output_off() if windowsdll(); "" -}; \
441 $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
442 ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
443 : {- output_on() if windowsdll(); "" -}; \
446 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
447 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
448 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
449 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
450 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
451 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
452 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
453 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
455 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
456 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
457 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
458 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
459 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
460 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
461 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
462 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
465 install_dev: install_runtime_libs
466 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
467 @$(ECHO) "*** Installing development files"
468 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
469 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
470 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
471 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
472 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
473 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
474 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
475 $(BLDDIR)/include/openssl/*.h; do \
477 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
478 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
479 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
481 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
482 @set -e; for l in $(INSTALL_LIBS); do \
484 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
485 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
486 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
487 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
488 mv -f $(DESTDIR)$(libdir)/$$fn.new \
489 $(DESTDIR)$(libdir)/$$fn; \
491 @ : {- output_off() if $disabled{shared}; "" -}
492 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
493 s1=`echo "$$s" | cut -f1 -d";"`; \
494 s2=`echo "$$s" | cut -f2 -d";"`; \
495 fn1=`basename $$s1`; \
496 fn2=`basename $$s2`; \
497 : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
498 if [ "$$fn1" != "$$fn2" ]; then \
499 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
500 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
502 : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
503 $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
504 cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
505 chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
506 mv -f $(DESTDIR)$(libdir)/$$fn2.new \
507 $(DESTDIR)$(libdir)/$$fn2; \
508 : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
509 a=$(DESTDIR)$(libdir)/$$fn2; \
510 $(ECHO) "install $$s1 -> $$a"; \
511 if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
512 mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
514 for so in `$(AR) t $$a`; do \
517 strip -X32_64 -e $$so; \
518 $(AR) r $$a.new $$so; \
521 $(AR) r $$a.new $$s1; \
523 : {- output_off() if sharedaix(); output_on(); "" -}; \
525 @ : {- output_on() if $disabled{shared}; "" -}
526 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
527 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
528 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
529 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
530 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
531 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
532 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
533 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
534 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
535 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
537 uninstall_dev: uninstall_runtime_libs
538 @$(ECHO) "*** Uninstalling development files"
539 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
540 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
541 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
542 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
543 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
544 $(BLDDIR)/include/openssl/*.h; do \
546 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
547 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
549 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
550 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
551 @set -e; for l in $(INSTALL_LIBS); do \
553 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
554 $(RM) $(DESTDIR)$(libdir)/$$fn; \
556 @ : {- output_off() if $disabled{shared}; "" -}
557 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
558 s1=`echo "$$s" | cut -f1 -d";"`; \
559 s2=`echo "$$s" | cut -f2 -d";"`; \
560 fn1=`basename $$s1`; \
561 fn2=`basename $$s2`; \
562 : {- output_off() if windowsdll(); "" -}; \
563 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
564 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
565 if [ "$$fn1" != "$$fn2" -a -f "$(DESTDIR)$(libdir)/$$fn1" ]; then \
566 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
567 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
569 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
570 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
571 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
572 : {- output_on() unless windowsdll(); "" -}; \
574 @ : {- output_on() if $disabled{shared}; "" -}
575 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
576 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
577 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
578 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
579 -$(RMDIR) $(DESTDIR)$(libdir)
581 install_engines: install_runtime_libs build_engines
582 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
583 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
584 @$(ECHO) "*** Installing engines"
585 @set -e; for e in dummy $(INSTALL_ENGINES); do \
586 if [ "$$e" = "dummy" ]; then continue; fi; \
588 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
589 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
590 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
591 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
592 $(DESTDIR)$(ENGINESDIR)/$$fn; \
596 @$(ECHO) "*** Uninstalling engines"
597 @set -e; for e in dummy $(INSTALL_ENGINES); do \
598 if [ "$$e" = "dummy" ]; then continue; fi; \
600 if [ "$$fn" = '{- platform->dso("ossltest") -}' ]; then \
603 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
604 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
606 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
608 install_runtime: install_programs
610 install_runtime_libs: build_libs
611 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
612 @ : {- output_off() if windowsdll(); "" -}
613 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
614 @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
615 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
616 @ : {- output_on() unless windowsdll(); "" -}
617 @$(ECHO) "*** Installing runtime libraries"
618 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
619 if [ "$$s" = "dummy" ]; then continue; fi; \
621 : {- output_off() unless windowsdll(); "" -}; \
622 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
623 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
624 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
625 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
626 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
627 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
628 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
629 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
630 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
631 mv -f $(DESTDIR)$(libdir)/$$fn.new \
632 $(DESTDIR)$(libdir)/$$fn; \
633 : {- output_on() if windowsdll(); "" -}; \
636 install_programs: install_runtime_libs build_programs
637 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
638 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
639 @$(ECHO) "*** Installing runtime programs"
640 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
641 if [ "$$x" = "dummy" ]; then continue; fi; \
643 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
644 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
645 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
646 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
647 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
649 @set -e; for x in dummy $(BIN_SCRIPTS); do \
650 if [ "$$x" = "dummy" ]; then continue; fi; \
652 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
653 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
654 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
655 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
656 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
659 uninstall_runtime: uninstall_programs uninstall_runtime_libs
662 @$(ECHO) "*** Uninstalling runtime programs"
663 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
665 if [ "$$x" = "dummy" ]; then continue; fi; \
667 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
668 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
670 @set -e; for x in dummy $(BIN_SCRIPTS); \
672 if [ "$$x" = "dummy" ]; then continue; fi; \
674 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
675 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
677 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
679 uninstall_runtime_libs:
680 @$(ECHO) "*** Uninstalling runtime libraries"
681 @ : {- output_off() unless windowsdll(); "" -}
682 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
683 if [ "$$s" = "dummy" ]; then continue; fi; \
685 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
686 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
688 @ : {- output_on() unless windowsdll(); "" -}
692 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
693 @$(ECHO) "*** Installing manpages"
694 $(PERL) $(SRCDIR)/util/process_docs.pl \
695 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
698 @$(ECHO) "*** Uninstalling manpages"
699 $(PERL) $(SRCDIR)/util/process_docs.pl \
700 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
704 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
705 @$(ECHO) "*** Installing HTML manpages"
706 $(PERL) $(SRCDIR)/util/process_docs.pl \
707 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
710 @$(ECHO) "*** Uninstalling manpages"
711 $(PERL) $(SRCDIR)/util/process_docs.pl \
712 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
715 # Developer targets (note: these are only available on Unix) #########
717 update: generate errors ordinals
719 generate: generate_apps generate_crypto_bn generate_crypto_objects \
720 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
724 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
725 @if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \
726 else echo 'doc-nits: no errors.'; rm doc-nits ; fi
728 # Test coverage is a good idea for the future
729 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
733 lint -DLINT $(INCLUDES) $(SRCS)
736 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
737 < apps/openssl.cnf > apps/openssl-vms.cnf )
740 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
742 generate_crypto_objects:
743 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
744 crypto/objects/objects.txt \
745 crypto/objects/obj_mac.num \
746 > crypto/objects/obj_mac.new && \
747 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
748 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
749 crypto/objects/objects.txt \
750 crypto/objects/obj_mac.num \
751 > include/openssl/obj_mac.h )
752 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
753 include/openssl/obj_mac.h \
754 > crypto/objects/obj_dat.h )
755 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
756 crypto/objects/obj_mac.num \
757 crypto/objects/obj_xref.txt \
758 > crypto/objects/obj_xref.h )
760 generate_crypto_conf:
761 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
762 > crypto/conf/conf_def.h )
764 generate_crypto_asn1:
765 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
766 > crypto/asn1/charmap.h )
769 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
770 crypto/objects/obj_dat.h \
773 # Set to -force to force a rebuild
776 ( b=`pwd`; set -e; cd $(SRCDIR); \
777 $(PERL) util/ck_errf.pl -strict -internal; \
778 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
779 ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
781 $(PERL) ../util/ck_errf.pl -strict \
782 -conf $$E `basename $$E .ec`.c; \
783 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
784 -conf $$E `basename $$E .ec`.c ; \
787 {- use File::Basename;
790 qw( include/openssl/ssl.h
791 include/openssl/ssl2.h
792 include/openssl/ssl3.h
793 include/openssl/sslerr.h
794 include/openssl/tls1.h
795 include/openssl/dtls1.h
796 include/openssl/srtp.h );
798 qw( include/internal/dso.h
799 include/internal/o_dir.h
800 include/internal/o_str.h
801 include/internal/err.h
802 include/internal/sslconf.h );
803 our @cryptoskipheaders = ( @sslheaders,
804 qw( include/openssl/conf_api.h
805 include/openssl/ebcdic.h
806 include/openssl/opensslconf.h
807 include/openssl/symhacks.h ) );
808 foreach my $f ( glob(catfile($config{sourcedir},
809 'include','openssl','*.h')) ) {
810 my $fn = "include/openssl/" . basename($f);
811 push @cryptoheaders, $fn unless grep { $_ eq $fn } @cryptoskipheaders;
815 CRYPTOHEADERS={- join(" \\\n\t", sort @cryptoheaders) -}
816 SSLHEADERS={- join(" \\\n\t", sort @sslheaders) -}
819 $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
820 --ordinals util/libcrypto.num \
821 --symhacks include/openssl/symhacks.h \
824 $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
825 --ordinals util/libssl.num \
826 --symhacks include/openssl/symhacks.h \
831 SRCTOP=../$(SRCDIR) \
832 BLDTOP=../$(BLDDIR) \
833 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
838 -etags `find . -name '*.[ch]' -o -name '*.pm'`
840 # Release targets (note: only available on Unix) #####################
843 (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
845 # Helper targets #####################################################
847 link-utils: $(BLDDIR)/util/opensslwrap.sh
849 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
850 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
851 mkdir -p "$(BLDDIR)/util"; \
852 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
857 # Building targets ###################################################
859 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // () } @{$unified_info{libraries}}) -}
861 @ ( echo 'prefix=$(INSTALLTOP)'; \
862 echo 'exec_prefix=$${prefix}'; \
863 if [ -n "$(LIBDIR)" ]; then \
864 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
866 echo 'libdir=$(libdir)'; \
868 echo 'includedir=$${prefix}/include'; \
869 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
871 echo 'Name: OpenSSL-libcrypto'; \
872 echo 'Description: OpenSSL cryptography library'; \
873 echo 'Version: '$(VERSION); \
874 echo 'Libs: -L$${libdir} -lcrypto'; \
875 echo 'Libs.private: $(LIB_EX_LIBS)'; \
876 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
879 @ ( echo 'prefix=$(INSTALLTOP)'; \
880 echo 'exec_prefix=$${prefix}'; \
881 if [ -n "$(LIBDIR)" ]; then \
882 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
884 echo 'libdir=$(libdir)'; \
886 echo 'includedir=$${prefix}/include'; \
888 echo 'Name: OpenSSL-libssl'; \
889 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
890 echo 'Version: '$(VERSION); \
891 echo 'Requires.private: libcrypto'; \
892 echo 'Libs: -L$${libdir} -lssl'; \
893 echo 'Cflags: -I$${includedir}' ) > libssl.pc
896 @ ( echo 'prefix=$(INSTALLTOP)'; \
897 echo 'exec_prefix=$${prefix}'; \
898 if [ -n "$(LIBDIR)" ]; then \
899 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
901 echo 'libdir=$(libdir)'; \
903 echo 'includedir=$${prefix}/include'; \
905 echo 'Name: OpenSSL'; \
906 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
907 echo 'Version: '$(VERSION); \
908 echo 'Requires: libssl libcrypto' ) > openssl.pc
910 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
911 @echo "Detected changed: $?"
912 $(PERL) configdata.pm -r
913 @echo "**************************************************"
915 @echo "*** Please run the same make command again ***"
917 @echo "**************************************************"
921 $(PERL) configdata.pm -r
925 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
927 # Helper function to figure out dependencies on libraries
928 # It takes a list of library names and outputs a list of dependencies
929 sub compute_lib_depends {
930 # Depending on shared libraries:
931 # On Windows POSIX layers, we depend on {libname}.dll.a
932 # On Unix platforms, we depend on {shlibname}.so
933 return map { platform->sharedlib_simple($_) // platform->staticlib($_) } @_;
938 my $generator = join(" ", @{$args{generator}});
939 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
940 my $incs = join("", map { " -I".$_ } @{$args{incs}});
941 my $defs = join("", map { " -D".$_ } @{$args{defs}});
942 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
944 if (platform->isdef($args{src})) {
945 my $target = platform->def($args{src});
946 (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
947 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
948 my $ord_name = $args{generator}->[1] || $args{product};
950 $target: $args{generator}->[0] $deps \$(SRCDIR)/util/mkdef.pl
951 \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS $mkdef_os > $target
953 } elsif (!platform->isasm($args{src})) {
954 if ($args{generator}->[0] =~ m|^.*\.in$|) {
955 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
956 "util", "dofile.pl")),
957 rel2abs($config{builddir}));
959 $args{src}: $args{generator}->[0] $deps
960 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
961 "-o$target{build_file}" $generator > \$@
965 $args{src}: $args{generator}->[0] $deps
966 \$(PERL)$generator_incs $generator > \$@
970 if ($args{generator}->[0] =~ /\.pl$/) {
971 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
972 } elsif ($args{generator}->[0] =~ /\.m4$/) {
973 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
974 } elsif ($args{generator}->[0] =~ /\.S$/) {
977 die "Generator type for $args{src} unknown: $generator\n";
981 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
982 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
983 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
984 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
985 } -> {$args{intent}};
986 if (defined($generator)) {
988 $args{src}: $args{generator}->[0] $deps
993 $args{src}: $args{generator}->[0] $deps
994 \$(CC) $incs $cppflags $defs -E $args{generator}->[0] | \\
995 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
1000 # Should one wonder about the end of the Perl snippet, it's because this
1001 # second regexp eats up line endings as well, if the removed path is the
1002 # last in the line. We may therefore need to put back a line ending.
1005 my $obj = platform->obj($args{obj});
1006 my $dep = platform->dep($args{obj});
1007 my @srcs = @{$args{srcs}};
1008 my $srcs = join(" ", @srcs);
1009 my $deps = join(" ", @srcs, @{$args{deps}});
1010 my $incs = join("", map { " -I".$_ } @{$args{incs}});
1011 my $defs = join("", map { " -D".$_ } @{$args{defs}});
1015 if (grep /\.rc$/, @srcs) {
1017 $cmdflags = '$(RCFLAGS)';
1019 } elsif (grep /\.(cc|cpp)$/, @srcs) {
1021 $cmdcompile = ' -c';
1023 shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1024 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1025 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
1026 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
1027 } -> {$args{intent}};
1030 $cmdcompile = ' -c';
1032 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1033 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1034 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1035 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1036 } -> {$args{intent}};
1039 # extension-specific rules
1040 if (grep /\.s$/, @srcs) {
1043 $cmd $cmdflags -c -o \$\@ $srcs
1045 } elsif (grep /\.S$/, @srcs) {
1046 # Originally there was mutli-step rule with $(CC) -E file.S
1047 # followed by $(CC) -c file.s. It compensated for one of
1048 # legacy platform compiler's inability to handle .S files.
1049 # The platform is long discontinued by vendor so there is
1050 # hardly a point to drag it along...
1053 $cmd $incs $defs $cmdflags -c -o \$\@ $srcs
1055 } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
1056 && !grep /\.rc$/, @srcs) {
1059 $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -MT \$\@ -c -o \$\@ $srcs
1061 \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\
1064 mv $dep.tmp $dep; \\
1070 $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
1072 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
1074 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
1081 # We *know* this routine is only called when we've configure 'shared'.
1085 foreach (@{args{deps}}) {
1086 my $d = dirname($_);
1087 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1089 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1090 my $linklibs = join("", map { my $f = basename($_);
1091 (my $l = $f) =~ s/^lib//;
1092 " -l$l" } @{$args{deps}});
1093 my @objs = map { platform->obj($_) }
1094 grep { !platform->isdef($_) }
1096 my @defs = map { platform->def($_) }
1097 grep { platform->isdef($_) }
1099 my @deps = compute_lib_depends(@{$args{deps}});
1100 die "More than one exported symbol map" if scalar @defs > 1;
1101 my $objs = join(" ", @objs);
1102 my $deps = join(" ", @objs, @defs, @deps);
1103 my $simple = platform->sharedlib_simple($args{lib});
1104 my $full = platform->sharedlib($args{lib});
1105 my $shared_soname = "";
1106 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
1107 if defined $target{shared_sonameflag};
1108 my $shared_imp = "";
1109 $shared_imp .= ' '.$target{shared_impflag}.basename($simple)
1110 if defined $target{shared_impflag};
1111 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1112 my $recipe = <<"EOF";
1118 \$(AR) r $simple $full
1120 } elsif ($simple ne $full) {
1128 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1129 -o $full$shared_def $objs \\
1130 $linklibs \$(LIB_EX_LIBS)
1146 my $dso = platform->dso($args{lib});
1148 foreach (@{args{deps}}) {
1149 my $d = dirname($_);
1150 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1152 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1153 my $linklibs = join("", map { my $f = basename($_);
1154 (my $l = $f) =~ s/^lib//;
1155 " -l$l" } @{$args{deps}});
1156 my @objs = map { platform->obj($_) }
1157 grep { !platform->isdef($_) }
1159 my @defs = map { platform->def($_) }
1160 grep { platform->isdef($_) }
1162 my @deps = compute_lib_depends(@{$args{deps}});
1163 my $objs = join(" ", @objs);
1164 my $deps = join(" ", @objs, @defs, @deps);
1165 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1168 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1169 -o $dso$shared_def $objs \\
1170 $linklibs \$(DSO_EX_LIBS)
1175 my $lib = platform->staticlib($args{lib});
1176 my @objs = map { platform->obj($_) } @{$args{objs}};
1177 my $objs = join(" ", @objs);
1180 \$(AR) \$(ARFLAGS) \$\@ \$\?
1181 \$(RANLIB) \$\@ || echo Never mind.
1186 my $bin = platform->bin($args{bin});
1187 my $objs = join(" ", map { platform->obj($_) } @{$args{objs}});
1188 my $deps = join(" ", compute_lib_depends(@{$args{deps}}));
1190 foreach (@{args{deps}}) {
1191 next if $_ =~ /\.a$/;
1192 my $d = dirname($_);
1193 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1195 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1196 my $linklibs = join("", map { if ($_ =~ s/\.a$//) {
1197 " ".platform->staticlib($_);
1199 my $f = basename($_);
1200 (my $l = $f) =~ s/^lib//;
1205 my $cmdflags = '$(BIN_CFLAGS)';
1206 if (grep /_cc\.o$/, @{$args{objs}}) {
1208 $cmdflags = '$(BIN_CXXFLAGS)';
1213 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1215 $linklibs \$(BIN_EX_LIBS)
1220 my $script = $args{script};
1221 my $sources = join(" ", @{$args{sources}});
1222 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1223 "util", "dofile.pl")),
1224 rel2abs($config{builddir}));
1227 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1228 "-o$target{build_file}" $sources > "$script"
1234 my $dir = $args{dir};
1235 my @deps = map { platform->convertext($_) } @{$args{deps}};
1237 my %extinfo = ( dso => platform->dsoext(),
1238 lib => platform->libext(),
1239 bin => platform->binext() );
1241 # We already have a 'test' target, and the top directory is just plain
1243 return if $dir eq "test" || $dir eq ".";
1245 foreach my $type (("dso", "lib", "bin", "script")) {
1246 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1247 # For lib object files, we could update the library. However, it
1248 # was decided that it's enough to build the directory local object
1249 # files, so we don't need to add any actions, and the dependencies
1250 # are already taken care of.
1251 if ($type ne "lib") {
1252 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1253 if (dirname($prod) eq $dir) {
1254 push @deps, $prod.$extinfo{$type};
1256 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1262 my $deps = join(" ", @deps);
1263 my $actions = join("\n", "", @actions);
1265 $dir $dir/: $deps$actions
1268 "" # Important! This becomes part of the template result.