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