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