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