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