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