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