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