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