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