]> git.ipfire.org Git - thirdparty/openssl.git/blame_incremental - Configurations/unix-Makefile.tmpl
Configure: Recognise .rc and .def / .map / .opt as source files
[thirdparty/openssl.git] / Configurations / unix-Makefile.tmpl
... / ...
CommitLineData
1##
2## Makefile for OpenSSL
3##
4## {- join("\n## ", @autowarntext) -}
5{-
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
16 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
17
18 our $sover_dirname = $config{shlib_version_number};
19 $sover_dirname =~ s|\.|_|g
20 if $config{target} =~ /^mingw/;
21
22 # shlib and shlib_simple both take a static library name and figure
23 # out what the shlib name should be.
24 #
25 # When OpenSSL is configured "no-shared", these functions will just
26 # return empty lists, making them suitable to join().
27 #
28 # With Windows DLL producers, shlib($libname) will return the shared
29 # library name (which usually is different from the static library
30 # name) with the default shared extension appended to it, while
31 # shlib_simple($libname) will return the static library name with
32 # the shared extension followed by ".a" appended to it. The former
33 # result is used as the runtime shared library while the latter is
34 # used as the DLL import library.
35 #
36 # On all Unix systems, shlib($libname) will return the library name
37 # with the default shared extension, while shlib_simple($libname)
38 # will return the name from shlib($libname) with any SO version number
39 # removed. On some systems, they may therefore return the exact same
40 # string.
41 sub shlib {
42 my $lib = shift;
43 return () if $disabled{shared} || $lib =~ /\.a$/;
44 return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)';
45 }
46 sub shlib_simple {
47 my $lib = shift;
48 return () if $disabled{shared} || $lib =~ /\.a$/;
49
50 if (windowsdll()) {
51 return $lib . '$(SHLIB_EXT_IMPORT)';
52 }
53 return $lib . '$(SHLIB_EXT_SIMPLE)';
54 }
55
56 # Easy fixing of static library names
57 sub lib {
58 (my $lib = shift) =~ s/\.a$//;
59 return $lib . $libext;
60 }
61
62 # dso is a complement to shlib / shlib_simple that returns the
63 # given libname with the simple shared extension (possible SO version
64 # removed). This differs from shlib_simple() by being unconditional.
65 sub dso {
66 my $engine = shift;
67
68 return $engine . $dsoext;
69 }
70 # This makes sure things get built in the order they need
71 # to. You're welcome.
72 sub dependmagic {
73 my $target = shift;
74
75 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
76 }
77 '';
78-}
79PLATFORM={- $config{target} -}
80OPTIONS={- $config{options} -}
81CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
82SRCDIR={- $config{sourcedir} -}
83BLDDIR={- $config{builddir} -}
84
85VERSION={- $config{version} -}
86MAJOR={- $config{major} -}
87MINOR={- $config{minor} -}
88SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
89SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
90SHLIB_MAJOR={- $config{shlib_major} -}
91SHLIB_MINOR={- $config{shlib_minor} -}
92SHLIB_TARGET={- $target{shared_target} -}
93SHLIB_EXT={- $shlibext -}
94SHLIB_EXT_SIMPLE={- $shlibextsimple -}
95SHLIB_EXT_IMPORT={- $shlibextimport -}
96
97LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
98SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
99SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
100ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
101PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
102SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
103{- output_off() if $disabled{makedepend}; "" -}
104DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
105 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
106 keys %{$unified_info{sources}}); -}
107{- output_on() if $disabled{makedepend}; "" -}
108GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
109GENERATED={- join(" ",
110 ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
111 grep { defined $unified_info{generate}->{$_} }
112 map { @{$unified_info{sources}->{$_}} }
113 grep { /\.o$/ } keys %{$unified_info{sources}} ),
114 ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -}
115
116INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
117INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
118INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
119INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
120INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
121{- output_off() if $disabled{apps}; "" -}
122BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
123MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
124{- output_on() if $disabled{apps}; "" -}
125
126APPS_OPENSSL={- use File::Spec::Functions;
127 catfile("apps","openssl") -}
128
129# DESTDIR is for package builders so that they can configure for, say,
130# /usr/ and yet have everything installed to /tmp/somedir/usr/.
131# Normally it is left empty.
132DESTDIR=
133
134# Do not edit these manually. Use Configure with --prefix or --openssldir
135# to change this! Short explanation in the top comment in Configure
136INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
137 #
138 our $prefix = $config{prefix} || "/usr/local";
139 $prefix -}
140OPENSSLDIR={- #
141 # The logic here is that if no --openssldir was given,
142 # OPENSSLDIR will get the value from $prefix plus "/ssl".
143 # If --openssldir was given and the value is an absolute
144 # path, OPENSSLDIR will get its value without change.
145 # If the value from --openssldir is a relative path,
146 # OPENSSLDIR will get $prefix with the --openssldir
147 # value appended as a subdirectory.
148 #
149 use File::Spec::Functions;
150 our $openssldir =
151 $config{openssldir} ?
152 (file_name_is_absolute($config{openssldir}) ?
153 $config{openssldir}
154 : catdir($prefix, $config{openssldir}))
155 : catdir($prefix, "ssl");
156 $openssldir -}
157LIBDIR={- #
158 # if $prefix/lib$target{multilib} is not an existing
159 # directory, then assume that it's not searched by linker
160 # automatically, in which case adding $target{multilib} suffix
161 # causes more grief than we're ready to tolerate, so don't...
162 our $multilib =
163 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
164 our $libdir = $config{libdir} || "lib$multilib";
165 $libdir -}
166ENGINESDIR={- use File::Spec::Functions;
167 catdir($prefix,$libdir,"engines-$sover_dirname") -}
168
169# Convenience variable for those who want to set the rpath in shared
170# libraries and applications
171LIBRPATH=$(INSTALLTOP)/$(LIBDIR)
172
173MANDIR=$(INSTALLTOP)/share/man
174DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
175HTMLDIR=$(DOCDIR)/html
176
177# MANSUFFIX is for the benefit of anyone who may want to have a suffix
178# appended after the manpage file section number. "ssl" is popular,
179# resulting in files such as config.5ssl rather than config.5.
180MANSUFFIX=
181HTMLSUFFIX=html
182
183# For "optional" echo messages, to get "real" silence
184ECHO = echo
185
186CROSS_COMPILE= {- $config{cross_compile_prefix} -}
187CC= $(CROSS_COMPILE){- $target{cc} -}
188CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -}
189CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
190CXX= $(CROSS_COMPILE){- $target{cxx} -}
191CXXFLAGS={- our $cxxflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cxxflags} -} {- $config{cxxflags} -} -std=c++11
192LDFLAGS= {- $target{lflags} -}
193PLIB_LDFLAGS= {- $target{plib_lflags} -}
194EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
195LIB_CFLAGS={- $target{shared_cflag} || "" -}
196LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -}
197LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -}
198DSO_CFLAGS={- $target{dso_cflags} || "" -}
199DSO_CXXFLAGS={- $target{dso_cxxflags} || "" -}
200DSO_LDFLAGS={- $target{dso_lflags} || "" -}
201BIN_CFLAGS={- $target{bin_cflags} || "" -}
202BIN_CXXFLAGS={- $target{bin_cxxflags} || "" -}
203BIN_LDFLAGS={- $target{bin_lflags} || "" -}
204
205PERL={- $config{perl} -}
206
207ARFLAGS= {- $target{arflags} -}
208AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
209RANLIB= {- $target{ranlib} -}
210NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
211RCFLAGS={- $target{shared_rcflag} -}
212RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
213RM= rm -f
214RMDIR= rmdir
215TAR= {- $target{tar} || "tar" -}
216TARFLAGS= {- $target{tarflags} -}
217MAKEDEPEND={- $config{makedepprog} -}
218
219BASENAME= openssl
220NAME= $(BASENAME)-$(VERSION)
221TARFILE= ../$(NAME).tar
222
223# We let the C compiler driver to take care of .s files. This is done in
224# order to be excused from maintaining a separate set of architecture
225# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
226# gcc, then the driver will automatically translate it to -xarch=v8plus
227# and pass it down to assembler.
228AS=$(CC) -c
229ASFLAG=$(CFLAGS)
230PERLASM_SCHEME= {- $target{perlasm_scheme} -}
231
232# For x86 assembler: Set PROCESSOR to 386 if you want to support
233# the 80386.
234PROCESSOR= {- $config{processor} -}
235
236# We want error [and other] messages in English. Trouble is that make(1)
237# doesn't pass macros down as environment variables unless there already
238# was corresponding variable originally set. In other words we can only
239# reassign environment variables, but not set new ones, not in portable
240# manner that is. That's why we reassign several, just to be sure...
241LC_ALL=C
242LC_MESSAGES=C
243LANG=C
244
245# The main targets ###################################################
246
247{- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
248{- dependmagic('build_libs'); -}: build_libs_nodep
249{- dependmagic('build_engines'); -}: build_engines_nodep
250{- dependmagic('build_programs'); -}: build_programs_nodep
251
252build_generated: $(GENERATED_MANDATORY)
253build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
254build_engines_nodep: $(ENGINES)
255build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
256
257# Kept around for backward compatibility
258build_apps build_tests: build_programs
259
260# Convenience target to prebuild all generated files, not just the mandatory
261# ones
262build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
263
264test: tests
265{- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
266 @ : {- output_off() if $disabled{tests}; "" -}
267 ( cd test; \
268 mkdir -p test-runs; \
269 SRCTOP=../$(SRCDIR) \
270 BLDTOP=../$(BLDDIR) \
271 RESULT_D=test-runs \
272 PERL="$(PERL)" \
273 EXE_EXT={- $exeext -} \
274 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines; pwd` \
275 OPENSSL_DEBUG_MEMORY=on \
276 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
277 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
278 @echo "Tests are not supported with your chosen Configure options"
279 @ : {- output_on() if !$disabled{tests}; "" -}
280
281list-tests:
282 @ : {- output_off() if $disabled{tests}; "" -}
283 @SRCTOP="$(SRCDIR)" \
284 $(PERL) $(SRCDIR)/test/run_tests.pl list
285 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
286 @echo "Tests are not supported with your chosen Configure options"
287 @ : {- output_on() if !$disabled{tests}; "" -}
288
289install: install_sw install_ssldirs install_docs
290
291uninstall: uninstall_docs uninstall_sw
292
293libclean:
294 @set -e; for s in $(SHLIB_INFO); do \
295 s1=`echo "$$s" | cut -f1 -d";"`; \
296 s2=`echo "$$s" | cut -f2 -d";"`; \
297 $(ECHO) $(RM) $$s1; \
298 $(RM) $$s1; \
299 if [ "$$s1" != "$$s2" ]; then \
300 $(ECHO) $(RM) $$s2; \
301 $(RM) $$s2; \
302 fi; \
303 done
304 $(RM) $(LIBS)
305 $(RM) *.map
306
307clean: libclean
308 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
309 $(RM) $(GENERATED)
310 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
311 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
312 $(RM) core
313 $(RM) tags TAGS doc-nits
314 $(RM) test/.rnd
315 $(RM) openssl.pc libcrypto.pc libssl.pc
316 -$(RM) `find . -type l -a \! -path "./.git/*"`
317 $(RM) $(TARFILE)
318
319distclean: clean
320 $(RM) configdata.pm
321 $(RM) Makefile
322
323# We check if any depfile is newer than Makefile and decide to
324# concatenate only if that is true.
325depend:
326 @: {- output_off() if $disabled{makedepend}; "" -}
327 @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
328 ( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
329 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
330 echo; \
331 for f in $(DEPS); do \
332 if [ -f $$f ]; then cat $$f; fi; \
333 done ) > Makefile.new; \
334 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
335 rm -f Makefile.new; \
336 else \
337 mv -f Makefile.new Makefile; \
338 fi; \
339 fi
340 @: {- output_on() if $disabled{makedepend}; "" -}
341
342# Install helper targets #############################################
343
344install_sw: all install_dev install_engines install_runtime
345
346uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
347
348install_docs: install_man_docs install_html_docs
349
350uninstall_docs: uninstall_man_docs uninstall_html_docs
351 $(RM) -r -v $(DESTDIR)$(DOCDIR)
352
353install_ssldirs:
354 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
355 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
356 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
357 @set -e; for x in dummy $(MISC_SCRIPTS); do \
358 if [ "$$x" = "dummy" ]; then continue; fi; \
359 fn=`basename $$x`; \
360 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
361 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
362 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
363 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
364 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
365 done
366 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
367 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
368 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
369 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
370 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
371 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
372 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
373 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
374 fi
375 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
376 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
377 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
378 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
379 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
380 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
381 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
382 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
383 fi
384
385install_dev:
386 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
387 @$(ECHO) "*** Installing development files"
388 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
389 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
390 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
391 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
392 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
393 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
394 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
395 $(BLDDIR)/include/openssl/*.h; do \
396 fn=`basename $$i`; \
397 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
398 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
399 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
400 done
401 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
402 @set -e; for l in $(INSTALL_LIBS); do \
403 fn=`basename $$l`; \
404 $(ECHO) "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
405 cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
406 $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
407 chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
408 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
409 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
410 done
411 @ : {- output_off() if $disabled{shared}; "" -}
412 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
413 s1=`echo "$$s" | cut -f1 -d";"`; \
414 s2=`echo "$$s" | cut -f2 -d";"`; \
415 fn1=`basename $$s1`; \
416 fn2=`basename $$s2`; \
417 : {- output_off() if windowsdll(); "" -}; \
418 $(ECHO) "install $$s1 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
419 cp $$s1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
420 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new; \
421 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1.new \
422 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
423 if [ "$$fn1" != "$$fn2" ]; then \
424 $(ECHO) "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
425 ln -sf $$fn1 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
426 fi; \
427 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
428 $(ECHO) "install $$s2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
429 cp $$s2 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
430 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new; \
431 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2.new \
432 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
433 : {- output_on() unless windowsdll(); "" -}; \
434 done
435 @ : {- output_on() if $disabled{shared}; "" -}
436 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
437 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
438 @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
439 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
440 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc"
441 @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
442 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
443 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc"
444 @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
445 @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
446
447uninstall_dev:
448 @$(ECHO) "*** Uninstalling development files"
449 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
450 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
451 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
452 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
453 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
454 $(BLDDIR)/include/openssl/*.h; do \
455 fn=`basename $$i`; \
456 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
457 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
458 done
459 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
460 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
461 @set -e; for l in $(INSTALL_LIBS); do \
462 fn=`basename $$l`; \
463 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
464 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
465 done
466 @ : {- output_off() if $disabled{shared}; "" -}
467 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
468 s1=`echo "$$s" | cut -f1 -d";"`; \
469 s2=`echo "$$s" | cut -f2 -d";"`; \
470 fn1=`basename $$s1`; \
471 fn2=`basename $$s2`; \
472 : {- output_off() if windowsdll(); "" -}; \
473 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1"; \
474 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn1; \
475 if [ "$$fn1" != "$$fn2" ]; then \
476 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
477 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
478 fi; \
479 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
480 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \
481 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
482 : {- output_on() unless windowsdll(); "" -}; \
483 done
484 @ : {- output_on() if $disabled{shared}; "" -}
485 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
486 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
487 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
488 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
489 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
490
491install_engines:
492 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
493 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
494 @$(ECHO) "*** Installing engines"
495 @set -e; for e in dummy $(INSTALL_ENGINES); do \
496 if [ "$$e" = "dummy" ]; then continue; fi; \
497 fn=`basename $$e`; \
498 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
499 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
500 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
501 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
502 $(DESTDIR)$(ENGINESDIR)/$$fn; \
503 done
504
505uninstall_engines:
506 @$(ECHO) "*** Uninstalling engines"
507 @set -e; for e in dummy $(INSTALL_ENGINES); do \
508 if [ "$$e" = "dummy" ]; then continue; fi; \
509 fn=`basename $$e`; \
510 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
511 continue; \
512 fi; \
513 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
514 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
515 done
516 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
517
518install_runtime:
519 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
520 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
521 @ : {- output_off() if windowsdll(); "" -}
522 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)
523 @ : {- output_on() if windowsdll(); "" -}
524 @$(ECHO) "*** Installing runtime files"
525 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
526 if [ "$$s" = "dummy" ]; then continue; fi; \
527 fn=`basename $$s`; \
528 : {- output_off() unless windowsdll(); "" -}; \
529 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
530 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
531 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
532 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
533 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
534 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
535 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
536 cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
537 chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \
538 mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \
539 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
540 : {- output_on() if windowsdll(); "" -}; \
541 done
542 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
543 if [ "$$x" = "dummy" ]; then continue; fi; \
544 fn=`basename $$x`; \
545 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
546 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
547 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
548 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
549 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
550 done
551 @set -e; for x in dummy $(BIN_SCRIPTS); do \
552 if [ "$$x" = "dummy" ]; then continue; fi; \
553 fn=`basename $$x`; \
554 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
555 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
556 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
557 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
558 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
559 done
560
561uninstall_runtime:
562 @$(ECHO) "*** Uninstalling runtime files"
563 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
564 do \
565 if [ "$$x" = "dummy" ]; then continue; fi; \
566 fn=`basename $$x`; \
567 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
568 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
569 done;
570 @set -e; for x in dummy $(BIN_SCRIPTS); \
571 do \
572 if [ "$$x" = "dummy" ]; then continue; fi; \
573 fn=`basename $$x`; \
574 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
575 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
576 done
577 @ : {- output_off() unless windowsdll(); "" -}
578 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
579 if [ "$$s" = "dummy" ]; then continue; fi; \
580 fn=`basename $$s`; \
581 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
582 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
583 done
584 @ : {- output_on() unless windowsdll(); "" -}
585 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
586
587
588install_man_docs:
589 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
590 @$(ECHO) "*** Installing manpages"
591 $(PERL) $(SRCDIR)/util/process_docs.pl \
592 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
593
594uninstall_man_docs:
595 @$(ECHO) "*** Uninstalling manpages"
596 $(PERL) $(SRCDIR)/util/process_docs.pl \
597 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
598 --remove
599
600install_html_docs:
601 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
602 @$(ECHO) "*** Installing HTML manpages"
603 $(PERL) $(SRCDIR)/util/process_docs.pl \
604 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
605
606uninstall_html_docs:
607 @$(ECHO) "*** Uninstalling manpages"
608 $(PERL) $(SRCDIR)/util/process_docs.pl \
609 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
610
611
612# Developer targets (note: these are only available on Unix) #########
613
614update: generate errors ordinals
615
616generate: generate_apps generate_crypto_bn generate_crypto_objects \
617 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
618
619doc-nits:
620 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
621 if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
622
623# Test coverage is a good idea for the future
624#coverage: $(PROGRAMS) $(TESTPROGRAMS)
625# ...
626
627lint:
628 lint -DLINT $(INCLUDES) $(SRCS)
629
630generate_apps:
631 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
632 < apps/openssl.cnf > apps/openssl-vms.cnf )
633
634generate_crypto_bn:
635 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
636
637generate_crypto_objects:
638 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
639 crypto/objects/objects.txt \
640 crypto/objects/obj_mac.num \
641 include/openssl/obj_mac.h )
642 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
643 include/openssl/obj_mac.h \
644 crypto/objects/obj_dat.h )
645 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
646 crypto/objects/obj_mac.num \
647 crypto/objects/obj_xref.txt \
648 > crypto/objects/obj_xref.h )
649
650generate_crypto_conf:
651 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
652 > crypto/conf/conf_def.h )
653
654generate_crypto_asn1:
655 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
656 > crypto/asn1/charmap.h )
657
658generate_fuzz_oids:
659 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
660 crypto/objects/obj_dat.h \
661 > fuzz/oids.txt )
662
663# Set to -force to force a rebuild
664ERROR_REBUILD=
665errors:
666 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
667 ( cd $(SRCDIR); $(PERL) util/mkerr.pl $(ERROR_REBUILD) -internal )
668 ( cd $(SRCDIR)/engines; \
669 for E in *.ec ; do \
670 $(PERL) ../util/mkerr.pl $(ERROR_REBUILD) -static \
671 -conf $$E `basename $$E .ec`.c ; \
672 done )
673
674ordinals:
675 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
676 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
677
678test_ordinals:
679 ( cd test; \
680 SRCTOP=../$(SRCDIR) \
681 BLDTOP=../$(BLDDIR) \
682 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
683
684tags TAGS: FORCE
685 rm -f TAGS tags
686 -ctags -R .
687 -etags `find . -name '*.[ch]' -o -name '*.pm'`
688
689# Release targets (note: only available on Unix) #####################
690
691# If your tar command doesn't support --owner and --group, make sure to
692# use one that does, for example GNU tar
693TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
694PREPARE_CMD=:
695tar:
696 set -e; \
697 TMPDIR=/var/tmp/openssl-copy.$$$$; \
698 DISTDIR=$(NAME); \
699 mkdir -p $$TMPDIR/$$DISTDIR; \
700 (cd $(SRCDIR); \
701 excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
702 excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
703 echo "$$excl_re"; \
704 git ls-tree -r --name-only --full-tree HEAD \
705 | egrep -v "$$excl_re" \
706 | while read F; do \
707 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
708 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
709 done); \
710 (cd $$TMPDIR/$$DISTDIR; \
711 $(PREPARE_CMD); \
712 find . -type d -print | xargs chmod 755; \
713 find . -type f -print | xargs chmod a+r; \
714 find . -type f -perm -0100 -print | xargs chmod a+x); \
715 (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
716 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
717 rm -rf $$TMPDIR
718 cd $(SRCDIR); ls -l $(TARFILE).gz
719
720dist:
721 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
722
723# Helper targets #####################################################
724
725link-utils: $(BLDDIR)/util/opensslwrap.sh
726
727$(BLDDIR)/util/opensslwrap.sh: configdata.pm
728 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
729 mkdir -p "$(BLDDIR)/util"; \
730 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
731 fi
732
733FORCE:
734
735# Building targets ###################################################
736
737libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
738libcrypto.pc:
739 @ ( echo 'prefix=$(INSTALLTOP)'; \
740 echo 'exec_prefix=$${prefix}'; \
741 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
742 echo 'includedir=$${prefix}/include'; \
743 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
744 echo ''; \
745 echo 'Name: OpenSSL-libcrypto'; \
746 echo 'Description: OpenSSL cryptography library'; \
747 echo 'Version: '$(VERSION); \
748 echo 'Libs: -L$${libdir} -lcrypto'; \
749 echo 'Libs.private: $(EX_LIBS)'; \
750 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
751
752libssl.pc:
753 @ ( echo 'prefix=$(INSTALLTOP)'; \
754 echo 'exec_prefix=$${prefix}'; \
755 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
756 echo 'includedir=$${prefix}/include'; \
757 echo ''; \
758 echo 'Name: OpenSSL-libssl'; \
759 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
760 echo 'Version: '$(VERSION); \
761 echo 'Requires.private: libcrypto'; \
762 echo 'Libs: -L$${libdir} -lssl'; \
763 echo 'Libs.private: $(EX_LIBS)'; \
764 echo 'Cflags: -I$${includedir}' ) > libssl.pc
765
766openssl.pc:
767 @ ( echo 'prefix=$(INSTALLTOP)'; \
768 echo 'exec_prefix=$${prefix}'; \
769 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
770 echo 'includedir=$${prefix}/include'; \
771 echo ''; \
772 echo 'Name: OpenSSL'; \
773 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
774 echo 'Version: '$(VERSION); \
775 echo 'Requires: libssl libcrypto' ) > openssl.pc
776
777configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
778 @echo "Detected changed: $?"
779 @echo "Reconfiguring..."
780 $(PERL) $(SRCDIR)/Configure reconf
781 @echo "**************************************************"
782 @echo "*** ***"
783 @echo "*** Please run the same make command again ***"
784 @echo "*** ***"
785 @echo "**************************************************"
786 @false
787
788{-
789 use File::Basename;
790 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
791
792 # Helper function to figure out dependencies on libraries
793 # It takes a list of library names and outputs a list of dependencies
794 sub compute_lib_depends {
795 if ($disabled{shared}) {
796 return map { lib($_) } @_;
797 }
798
799 # Depending on shared libraries:
800 # On Windows POSIX layers, we depend on {libname}.dll.a
801 # On Unix platforms, we depend on {shlibname}.so
802 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
803 }
804
805 sub generatesrc {
806 my %args = @_;
807 my $generator = join(" ", @{$args{generator}});
808 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
809 my $incs = join("", map { " -I".$_ } @{$args{incs}});
810 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
811
812 if ($args{src} !~ /\.[sS]$/) {
813 if ($args{generator}->[0] =~ m|^.*\.in$|) {
814 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
815 "util", "dofile.pl")),
816 rel2abs($config{builddir}));
817 return <<"EOF";
818$args{src}: $args{generator}->[0] $deps
819 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
820 "-o$target{build_file}" $generator > \$@
821EOF
822 } else {
823 return <<"EOF";
824$args{src}: $args{generator}->[0] $deps
825 \$(PERL)$generator_incs $generator > \$@
826EOF
827 }
828 } else {
829 if ($args{generator}->[0] =~ /\.pl$/) {
830 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
831 } elsif ($args{generator}->[0] =~ /\.m4$/) {
832 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
833 } elsif ($args{generator}->[0] =~ /\.S$/) {
834 $generator = undef;
835 } else {
836 die "Generator type for $args{src} unknown: $generator\n";
837 }
838
839 if (defined($generator)) {
840 # If the target is named foo.S in build.info, we want to
841 # end up generating foo.s in two steps.
842 if ($args{src} =~ /\.S$/) {
843 (my $target = $args{src}) =~ s|\.S$|.s|;
844 return <<"EOF";
845$target: $args{generator}->[0] $deps
846 ( trap "rm -f \$@.*" INT 0; \\
847 $generator \$@.S; \\
848 \$(CC) $incs \$(CFLAGS) -E \$@.S | \\
849 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
850 mv -f \$@.i \$@ )
851EOF
852 }
853 # Otherwise....
854 return <<"EOF";
855$args{src}: $args{generator}->[0] $deps
856 $generator \$@
857EOF
858 }
859 return <<"EOF";
860$args{src}: $args{generator}->[0] $deps
861 \$(CC) $incs \$(CFLAGS) -E $args{generator}->[0] | \\
862 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
863EOF
864 }
865 }
866
867 # Should one wonder about the end of the Perl snippet, it's because this
868 # second regexp eats up line endings as well, if the removed path is the
869 # last in the line. We may therefore need to put back a line ending.
870 sub src2obj {
871 my %args = @_;
872 my $obj = $args{obj};
873 my @srcs = map { if ($unified_info{generate}->{$_}) {
874 (my $x = $_) =~ s/\.S$/.s/; $x
875 } else {
876 $_
877 }
878 } ( @{$args{srcs}} );
879 my $srcs = join(" ", @srcs);
880 my $deps = join(" ", @srcs, @{$args{deps}});
881 my $incs = join("", map { " -I".$_ } @{$args{incs}});
882 unless ($disabled{zlib}) {
883 if ($withargs{zlib_include}) {
884 $incs .= " -I".$withargs{zlib_include};
885 }
886 }
887 my $cc = '$(CC)';
888 my $cflags = '$(CFLAGS)';
889 if (grep /\.(cc|cpp)$/, @srcs) {
890 $cc = '$(CXX)';
891 $cflags = '$(CXXFLAGS)';
892 $cflags .= ' ' . { lib => '$(LIB_CXXFLAGS)',
893 dso => '$(DSO_CXXFLAGS)',
894 bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}};
895 } else {
896 $cflags .= ' ' . { lib => '$(LIB_CFLAGS)',
897 dso => '$(DSO_CFLAGS)',
898 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
899 }
900 my $makedepprog = $config{makedepprog};
901 my $recipe = <<"EOF";
902$obj$objext: $deps
903EOF
904 if (!$disabled{makedepend} && $makedepprog !~ /\/makedepend/) {
905 $recipe .= <<"EOF";
906 $cc $incs $cflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
907 \@touch $obj$depext.tmp
908 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
909 rm -f $obj$depext.tmp; \\
910 else \\
911 mv $obj$depext.tmp $obj$depext; \\
912 fi
913EOF
914 } else {
915 $recipe .= <<"EOF";
916 $cc $incs $cflags -c -o \$\@ $srcs
917EOF
918 if (!$disabled{makedepend} && $makedepprog =~ /\/makedepend/) {
919 $recipe .= <<"EOF";
920 -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cflags -- $srcs \\
921 >$obj$depext.tmp 2>/dev/null
922 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
923 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
924 rm -f $obj$depext.tmp; \\
925 else \\
926 mv $obj$depext.tmp $obj$depext; \\
927 fi
928EOF
929 }
930 }
931 return $recipe;
932 }
933 # On Unix, we build shlibs from static libs, so we're ignoring the
934 # object file array. We *know* this routine is only called when we've
935 # configure 'shared'.
936 sub libobj2shlib {
937 my %args = @_;
938 my $lib = $args{lib};
939 my $shlib = $args{shlib};
940 my $libd = dirname($lib);
941 my $libn = basename($lib);
942 (my $libname = $libn) =~ s/^lib//;
943 my $linklibs = join("", map { my $d = dirname($_);
944 my $f = basename($_);
945 (my $l = $f) =~ s/^lib//;
946 " -L$d -l$l" } @{$args{deps}});
947 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
948 my $shlib_target = $target{shared_target};
949 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
950 my $target = shlib_simple($lib);
951 my $target_full = shlib($lib);
952 return <<"EOF"
953# With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
954# that two files get produced, {shlibname}.dll and {libname}.dll.a.
955# With all other Unix platforms, we often build a shared library with the
956# SO version built into the file name and a symlink without the SO version
957# It's not necessary to have both as targets. The choice falls on the
958# simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
959# {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
960$target: $lib$libext $deps $ordinalsfile
961 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
962 ECHO=\$(ECHO) \\
963 PLATFORM=\$(PLATFORM) \\
964 PERL="\$(PERL)" SRCDIR='\$(SRCDIR)' DSTDIR="$libd" \\
965 INSTALLTOP='\$(INSTALLTOP)' LIBDIR='\$(LIBDIR)' \\
966 LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
967 LIBNAME=$libname SHLIBVERSION=\$(SHLIB_VERSION_NUMBER) \\
968 STLIBNAME=$lib$libext \\
969 SHLIBNAME=$target SHLIBNAME_FULL=$target_full \\
970 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(LIB_CFLAGS)' \\
971 LDFLAGS='\$(LDFLAGS)' SHARED_LDFLAGS='\$(LIB_LDFLAGS)' \\
972 RC='\$(RC)' SHARED_RCFLAGS='\$(RCFLAGS)' \\
973 link_shlib.$shlib_target
974EOF
975 . (windowsdll() ? <<"EOF" : "");
976 rm -f apps/$shlib'\$(SHLIB_EXT)'
977 rm -f test/$shlib'\$(SHLIB_EXT)'
978 cp -p $shlib'\$(SHLIB_EXT)' apps/
979 cp -p $shlib'\$(SHLIB_EXT)' test/
980EOF
981 }
982 sub obj2dso {
983 my %args = @_;
984 my $dso = $args{lib};
985 my $dsod = dirname($dso);
986 my $dson = basename($dso);
987 my $shlibdeps = join("", map { my $d = dirname($_);
988 my $f = basename($_);
989 (my $l = $f) =~ s/^lib//;
990 " -L$d -l$l" } @{$args{deps}});
991 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
992 my $shlib_target = $target{shared_target};
993 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
994 my $target = dso($dso);
995 return <<"EOF";
996$target: $objs $deps
997 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
998 PLATFORM=\$(PLATFORM) \\
999 PERL="\$(PERL)" SRCDIR='\$(SRCDIR)' DSTDIR="$dsod" \\
1000 LIBDEPS='\$(PLIB_LDFLAGS) '"$shlibdeps"' \$(EX_LIBS)' \\
1001 SHLIBNAME_FULL=$target LDFLAGS='\$(LDFLAGS)' \\
1002 CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(DSO_CFLAGS)' \\
1003 SHARED_LDFLAGS='\$(DSO_LDFLAGS)' \\
1004 LIBEXTRAS="$objs" \\
1005 link_dso.$shlib_target
1006EOF
1007 }
1008 sub obj2lib {
1009 my %args = @_;
1010 (my $lib = $args{lib}) =~ s/\.a$//;
1011 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
1012 return <<"EOF";
1013$lib$libext: $objs
1014 \$(AR) \$\@ \$\?
1015 \$(RANLIB) \$\@ || echo Never mind.
1016EOF
1017 }
1018 sub obj2bin {
1019 my %args = @_;
1020 my $bin = $args{bin};
1021 my $bind = dirname($bin);
1022 my $binn = basename($bin);
1023 my $objs = join(" ", map { $_.$objext } @{$args{objs}});
1024 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1025 my $linklibs = join("", map { if ($_ =~ /\.a$/) {
1026 " $_";
1027 } else {
1028 my $d = dirname($_);
1029 my $f = basename($_);
1030 $d = "." if $d eq $f;
1031 (my $l = $f) =~ s/^lib//;
1032 " -L$d -l$l"
1033 }
1034 } @{$args{deps}});
1035 my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
1036 my $cc = '$(CC)';
1037 my $cflags = '$(CFLAGS) $(BIN_CFLAGS)';
1038 if (grep /_cc$/, @{$args{objs}}) {
1039 $cc = '$(CXX)';
1040 $cflags = '$(CXXFLAGS) $(BIN_CXXFLAGS)';
1041 }
1042 return <<"EOF";
1043$bin$exeext: $objs $deps
1044 \$(RM) $bin$exeext
1045 \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
1046 PERL="\$(PERL)" SRCDIR=\$(SRCDIR) \\
1047 APPNAME=$bin$exeext OBJECTS="$objs" \\
1048 LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
1049 CC='$cc' CFLAGS='$cflags' \\
1050 LDFLAGS='\$(LDFLAGS)' \\
1051 link_app.$shlib_target
1052EOF
1053 }
1054 sub in2script {
1055 my %args = @_;
1056 my $script = $args{script};
1057 my $sources = join(" ", @{$args{sources}});
1058 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1059 "util", "dofile.pl")),
1060 rel2abs($config{builddir}));
1061 return <<"EOF";
1062$script: $sources
1063 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1064 "-o$target{build_file}" $sources > "$script"
1065 chmod a+x $script
1066EOF
1067 }
1068 sub generatedir {
1069 my %args = @_;
1070 my $dir = $args{dir};
1071 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1072 my @actions = ();
1073 my %extinfo = ( dso => $dsoext,
1074 lib => $libext,
1075 bin => $exeext );
1076
1077 foreach my $type (("dso", "lib", "bin", "script")) {
1078 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1079 # For lib object files, we could update the library. However, it
1080 # was decided that it's enough to build the directory local object
1081 # files, so we don't need to add any actions, and the dependencies
1082 # are already taken care of.
1083 if ($type ne "lib") {
1084 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1085 if (dirname($prod) eq $dir) {
1086 push @deps, $prod.$extinfo{$type};
1087 } else {
1088 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1089 }
1090 }
1091 }
1092 }
1093
1094 my $deps = join(" ", @deps);
1095 my $actions = join("\n", "", @actions);
1096 return <<"EOF";
1097$args{dir} $args{dir}/: $deps$actions
1098EOF
1099 }
1100 "" # Important! This becomes part of the template result.
1101-}