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