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