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