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