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