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