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