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