]> git.ipfire.org Git - thirdparty/openssl.git/blame - Configurations/unix-Makefile.tmpl
Configure et al: rename all dso_* to module_* in shared-info.pl
[thirdparty/openssl.git] / Configurations / unix-Makefile.tmpl
CommitLineData
567a9e6f
RL
1##
2## Makefile for OpenSSL
3##
4## {- join("\n## ", @autowarntext) -}
5{-
834aae2a
BL
6 our $objext = $target{obj_extension} || ".o";
7 our $depext = $target{dep_extension} || ".d";
8 our $exeext = $target{exe_extension} || "";
9 our $libext = $target{lib_extension} || ".a";
10 our $shlibext = $target{shared_extension} || ".so";
822b5e26 11 our $shlibvariant = $target{shlib_variant} || "";
834aae2a
BL
12 our $shlibextsimple = $target{shared_extension_simple} || ".so";
13 our $shlibextimport = $target{shared_import_extension} || "";
14 our $dsoext = $target{dso_extension} || ".so";
15
567a9e6f 16 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
f5c174ff 17
d4453024
RL
18 our $sover_dirname = $config{shlib_version_number};
19 $sover_dirname =~ s|\.|_|g
20 if $config{target} =~ /^mingw/;
b2de11c5 21
f5c174ff
RL
22 # shlib and shlib_simple both take a static library name and figure
23 # out what the shlib name should be.
24 #
25 # When OpenSSL is configured "no-shared", these functions will just
26 # return empty lists, making them suitable to join().
27 #
28 # With Windows DLL producers, shlib($libname) will return the shared
29 # library name (which usually is different from the static library
30 # name) with the default shared extension appended to it, while
31 # shlib_simple($libname) will return the static library name with
32 # the shared extension followed by ".a" appended to it. The former
33 # result is used as the runtime shared library while the latter is
34 # used as the DLL import library.
35 #
36 # On all Unix systems, shlib($libname) will return the library name
37 # with the default shared extension, while shlib_simple($libname)
38 # will return the name from shlib($libname) with any SO version number
39 # removed. On some systems, they may therefore return the exact same
40 # string.
41 sub shlib {
f5c174ff 42 my $lib = shift;
33105818 43 return () if $disabled{shared} || $lib =~ /\.a$/;
822b5e26 44 return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)';
f5c174ff
RL
45 }
46 sub shlib_simple {
f5c174ff 47 my $lib = shift;
33105818
RL
48 return () if $disabled{shared} || $lib =~ /\.a$/;
49
f5c174ff 50 if (windowsdll()) {
d4453024 51 return $lib . '$(SHLIB_EXT_IMPORT)';
f5c174ff 52 }
d4453024 53 return $lib . '$(SHLIB_EXT_SIMPLE)';
f5c174ff
RL
54 }
55
33105818
RL
56 # Easy fixing of static library names
57 sub lib {
58 (my $lib = shift) =~ s/\.a$//;
59 return $lib . $libext;
60 }
61
f5c174ff
RL
62 # dso is a complement to shlib / shlib_simple that returns the
63 # given libname with the simple shared extension (possible SO version
64 # removed). This differs from shlib_simple() by being unconditional.
65 sub dso {
f5c174ff
RL
66 my $engine = shift;
67
834aae2a 68 return $engine . $dsoext;
f5c174ff 69 }
27c40a93
BL
70 # This makes sure things get built in the order they need
71 # to. You're welcome.
72 sub dependmagic {
73 my $target = shift;
74
75 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
76 }
834aae2a 77 '';
567a9e6f
RL
78-}
79PLATFORM={- $config{target} -}
80OPTIONS={- $config{options} -}
81CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
82SRCDIR={- $config{sourcedir} -}
83BLDDIR={- $config{builddir} -}
84
85VERSION={- $config{version} -}
86MAJOR={- $config{major} -}
87MINOR={- $config{minor} -}
88SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
89SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
90SHLIB_MAJOR={- $config{shlib_major} -}
91SHLIB_MINOR={- $config{shlib_minor} -}
92SHLIB_TARGET={- $target{shared_target} -}
d4453024
RL
93SHLIB_EXT={- $shlibext -}
94SHLIB_EXT_SIMPLE={- $shlibextsimple -}
95SHLIB_EXT_IMPORT={- $shlibextimport -}
567a9e6f 96
33105818 97LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
f5c174ff 98SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
0f01b7bc 99SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
f5c174ff 100ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
1e3d16b0 101PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
567a9e6f 102SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
29eed3dd 103{- output_off() if $disabled{makedepend}; "" -}
834aae2a 104DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
c058fcd7
RL
105 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
106 keys %{$unified_info{sources}}); -}
29eed3dd 107{- output_on() if $disabled{makedepend}; "" -}
7cae3864 108GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
05a7aee0
RL
109GENERATED={- join(" ",
110 ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
111 grep { defined $unified_info{generate}->{$_} }
112 map { @{$unified_info{sources}->{$_}} }
113 grep { /\.o$/ } keys %{$unified_info{sources}} ),
114 ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -}
c058fcd7 115
33105818 116INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
0f01b7bc
RL
117INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
118INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
119INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
120INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
df653379 121{- output_off() if $disabled{apps}; "" -}
567a9e6f 122BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
b8a9af68 123MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
df653379 124{- output_on() if $disabled{apps}; "" -}
567a9e6f 125
6a74806e
RL
126APPS_OPENSSL={- use File::Spec::Functions;
127 catfile("apps","openssl") -}
128
3c65577f
RL
129# DESTDIR is for package builders so that they can configure for, say,
130# /usr/ and yet have everything installed to /tmp/somedir/usr/.
567a9e6f 131# Normally it is left empty.
3c65577f 132DESTDIR=
567a9e6f
RL
133
134# Do not edit these manually. Use Configure with --prefix or --openssldir
135# to change this! Short explanation in the top comment in Configure
136INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
137 #
138 our $prefix = $config{prefix} || "/usr/local";
139 $prefix -}
140OPENSSLDIR={- #
141 # The logic here is that if no --openssldir was given,
142 # OPENSSLDIR will get the value from $prefix plus "/ssl".
143 # If --openssldir was given and the value is an absolute
144 # path, OPENSSLDIR will get its value without change.
145 # If the value from --openssldir is a relative path,
146 # OPENSSLDIR will get $prefix with the --openssldir
147 # value appended as a subdirectory.
148 #
149 use File::Spec::Functions;
150 our $openssldir =
151 $config{openssldir} ?
152 (file_name_is_absolute($config{openssldir}) ?
153 $config{openssldir}
154 : catdir($prefix, $config{openssldir}))
155 : catdir($prefix, "ssl");
156 $openssldir -}
e454f3ad
RL
157LIBDIR={- our $libdir = $config{libdir};
158 unless ($libdir) {
159 #
160 # if $prefix/lib$target{multilib} is not an existing
161 # directory, then assume that it's not searched by linker
162 # automatically, in which case adding $target{multilib} suffix
163 # causes more grief than we're ready to tolerate, so don't...
164 our $multilib =
165 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
166 $libdir = "lib$multilib";
167 }
168 file_name_is_absolute($libdir) ? "" : $libdir -}
169# $(libdir) is chosen to be compatible with the GNU coding standards
170libdir={- file_name_is_absolute($libdir)
171 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
172ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
567a9e6f 173
fad599f7
RL
174# Convenience variable for those who want to set the rpath in shared
175# libraries and applications
e454f3ad 176LIBRPATH=$(libdir)
fad599f7 177
dde10ab4 178MANDIR=$(INSTALLTOP)/share/man
8be7bdb5
RL
179DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
180HTMLDIR=$(DOCDIR)/html
567a9e6f 181
3544091a
RL
182# MANSUFFIX is for the benefit of anyone who may want to have a suffix
183# appended after the manpage file section number. "ssl" is popular,
184# resulting in files such as config.5ssl rather than config.5.
185MANSUFFIX=
567a9e6f
RL
186HTMLSUFFIX=html
187
5407338a
RS
188# For "optional" echo messages, to get "real" silence
189ECHO = echo
567a9e6f
RL
190
191CROSS_COMPILE= {- $config{cross_compile_prefix} -}
8c3bc594 192CPPFLAGS={- our $cppflags = join(" ",
5b18235a
RL
193 (map { "-D".$_} @{$config{defines}}),
194 (map { "-I".$_} @{$config{includes}}),
195 @{$config{cppflags}}) -}
8c3bc594 196CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -}
5b18235a
RL
197CC= $(CROSS_COMPILE){- $config{cc} -}
198CFLAGS={- join(' ', @{$config{cflags}}) -}
8590b1f3 199CXX={- $config{cxx} ? "\$(CROSS_COMPILE)$config{cxx}" : '' -}
fa153b57 200CXXFLAGS={- join(' ', @{$config{cxxflags}}) -}
5b18235a
RL
201LDFLAGS= {- join(' ', @{$config{lflags}}) -}
202PLIB_LDFLAGS= {- join(' ', @{$config{plib_lflags}}) -}
203EX_LIBS= {- join(' ', @{$config{ex_libs}}) -}
722c9762
RL
204
205LIB_CPPFLAGS={- join(' ', '$(CPPFLAGS)',
206 $target{shared_cppflag} || (),
207 (map { '-D'.$_ }
208 ('OPENSSLDIR="\"$(OPENSSLDIR)\""',
209 'ENGINESDIR="\"$(ENGINESDIR)\""'))) -}
210LIB_CFLAGS={- join(' ', '$(CFLAGS)', $target{shared_cflag} || ()) -}
211LIB_CXXFLAGS={- join(' ', '$(CXXFLAGS)', $target{shared_cxxflag} || ()) -}
212LIB_LDFLAGS={- join(' ', '$(LDFLAGS)', $target{shared_ldflag} || (), $config{shared_ldflag} || ()) -}
213DSO_CPPFLAGS={- join(' ', '$(CPPFLAGS)', $target{dso_cppflags} || ()) -}
214DSO_CFLAGS={- join(' ', '$(CFLAGS)', $target{dso_cflags} || ()) -}
215DSO_CXXFLAGS={- join(' ', '$(CXXFLAGS)', $target{dso_cxxflags} || ()) -}
216DSO_LDFLAGS={- join(' ', '$(LDFLAGS)', $target{dso_lflags} || ()) -}
217BIN_CPPFLAGS={- join(' ', '$(CPPFLAGS)', $target{bin_cppflags} || ()) -}
218BIN_CFLAGS={- join(' ', '$(CFLAGS)', $target{bin_cflags} || ()) -}
219BIN_CXXFLAGS={- join(' ', '$(CXXFLAGS)', $target{bin_cxxflags} || ()) -}
220BIN_LDFLAGS={- join(' ', '$(LDFLAGS)', $target{bin_lflags} || ()) -}
567a9e6f
RL
221
222PERL={- $config{perl} -}
223
5b18235a
RL
224AR=$(CROSS_COMPILE){- $config{ar} -}
225ARFLAGS= {- join(' ', @{$config{arflags}}) -}
5f2e18bc 226RANLIB={- $config{ranlib} ? "\$(CROSS_COMPILE)$config{ranlib}" : "true"; -}
8f41ff2d 227RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
5b18235a 228RCFLAGS={- join(' ', @{$config{rcflags}}) -} {- $target{shared_rcflag} -}
567a9e6f 229RM= rm -f
98e5534e 230RMDIR= rmdir
567a9e6f
RL
231TAR= {- $target{tar} || "tar" -}
232TARFLAGS= {- $target{tarflags} -}
29eed3dd 233MAKEDEPEND={- $config{makedepprog} -}
567a9e6f
RL
234
235BASENAME= openssl
236NAME= $(BASENAME)-$(VERSION)
237TARFILE= ../$(NAME).tar
238
239# We let the C compiler driver to take care of .s files. This is done in
240# order to be excused from maintaining a separate set of architecture
241# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
242# gcc, then the driver will automatically translate it to -xarch=v8plus
61ab6919
RL
243# and pass it down to assembler. In any case, we do not define AS or
244# ASFLAGS for this reason.
567a9e6f
RL
245PERLASM_SCHEME= {- $target{perlasm_scheme} -}
246
247# For x86 assembler: Set PROCESSOR to 386 if you want to support
248# the 80386.
249PROCESSOR= {- $config{processor} -}
250
9c7ce40b
AP
251# We want error [and other] messages in English. Trouble is that make(1)
252# doesn't pass macros down as environment variables unless there already
253# was corresponding variable originally set. In other words we can only
254# reassign environment variables, but not set new ones, not in portable
255# manner that is. That's why we reassign several, just to be sure...
256LC_ALL=C
257LC_MESSAGES=C
258LANG=C
259
567a9e6f
RL
260# The main targets ###################################################
261
1e3d16b0 262{- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
27c40a93
BL
263{- dependmagic('build_libs'); -}: build_libs_nodep
264{- dependmagic('build_engines'); -}: build_engines_nodep
1e3d16b0 265{- dependmagic('build_programs'); -}: build_programs_nodep
567a9e6f 266
27c40a93 267build_generated: $(GENERATED_MANDATORY)
c058fcd7 268build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
c058fcd7 269build_engines_nodep: $(ENGINES)
1e3d16b0
RL
270build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
271
272# Kept around for backward compatibility
273build_apps build_tests: build_programs
68a5f1a2 274
9b03b91b
RL
275# Convenience target to prebuild all generated files, not just the mandatory
276# ones
277build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
278
1b741653 279test: tests
1e3d16b0 280{- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
d90a6beb 281 @ : {- output_off() if $disabled{tests}; "" -}
567a9e6f 282 ( cd test; \
41f571e1 283 mkdir -p test-runs; \
567a9e6f
RL
284 SRCTOP=../$(SRCDIR) \
285 BLDTOP=../$(BLDDIR) \
41f571e1 286 RESULT_D=test-runs \
cbece220 287 PERL="$(PERL)" \
834aae2a 288 EXE_EXT={- $exeext -} \
41f571e1 289 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines; pwd` \
6d4bc8a3 290 OPENSSL_DEBUG_MEMORY=on \
567a9e6f 291 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
d90a6beb
MC
292 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
293 @echo "Tests are not supported with your chosen Configure options"
294 @ : {- output_on() if !$disabled{tests}; "" -}
567a9e6f
RL
295
296list-tests:
4813ad2d
RL
297 @ : {- output_off() if $disabled{tests}; "" -}
298 @SRCTOP="$(SRCDIR)" \
299 $(PERL) $(SRCDIR)/test/run_tests.pl list
300 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
301 @echo "Tests are not supported with your chosen Configure options"
302 @ : {- output_on() if !$disabled{tests}; "" -}
303
304install: install_sw install_ssldirs install_docs
305
306uninstall: uninstall_docs uninstall_sw
567a9e6f
RL
307
308libclean:
f99f91f1
RL
309 @set -e; for s in $(SHLIB_INFO); do \
310 s1=`echo "$$s" | cut -f1 -d";"`; \
311 s2=`echo "$$s" | cut -f2 -d";"`; \
5407338a 312 $(ECHO) $(RM) $$s1; \
f99f91f1
RL
313 $(RM) $$s1; \
314 if [ "$$s1" != "$$s2" ]; then \
5407338a 315 $(ECHO) $(RM) $$s2; \
f99f91f1
RL
316 $(RM) $$s2; \
317 fi; \
318 done
319 $(RM) $(LIBS)
4813ad2d 320 $(RM) *.map
567a9e6f
RL
321
322clean: libclean
4813ad2d
RL
323 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
324 $(RM) $(GENERATED)
325 -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
326 -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
327 $(RM) core
9e183d22 328 $(RM) tags TAGS doc-nits
d016d1ec 329 $(RM) -r test/test-runs
4813ad2d
RL
330 $(RM) openssl.pc libcrypto.pc libssl.pc
331 -$(RM) `find . -type l -a \! -path "./.git/*"`
332 $(RM) $(TARFILE)
567a9e6f 333
7cae3864 334distclean: clean
4813ad2d
RL
335 $(RM) configdata.pm
336 $(RM) Makefile
7cae3864 337
f8d9d6e4 338# We check if any depfile is newer than Makefile and decide to
a6adf099 339# concatenate only if that is true.
ea80a25e 340depend:
29eed3dd 341 @: {- output_off() if $disabled{makedepend}; "" -}
d423c5ad 342 @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
ebca7961 343 ( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
f8d9d6e4
RL
344 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
345 echo; \
a6adf099
RL
346 for f in $(DEPS); do \
347 if [ -f $$f ]; then cat $$f; fi; \
f8d9d6e4 348 done ) > Makefile.new; \
29b28eee 349 if cmp Makefile.new Makefile >/dev/null 2>&1; then \
f8d9d6e4 350 rm -f Makefile.new; \
29b28eee
RL
351 else \
352 mv -f Makefile.new Makefile; \
f8d9d6e4 353 fi; \
c058fcd7 354 fi
29eed3dd 355 @: {- output_on() if $disabled{makedepend}; "" -}
567a9e6f
RL
356
357# Install helper targets #############################################
358
359install_sw: all install_dev install_engines install_runtime
360
f99f91f1 361uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
567a9e6f
RL
362
363install_docs: install_man_docs install_html_docs
364
365uninstall_docs: uninstall_man_docs uninstall_html_docs
8be7bdb5 366 $(RM) -r -v $(DESTDIR)$(DOCDIR)
567a9e6f 367
dde10ab4
RL
368install_ssldirs:
369 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
370 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
66c2eb8b 371 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
4813ad2d
RL
372 @set -e; for x in dummy $(MISC_SCRIPTS); do \
373 if [ "$$x" = "dummy" ]; then continue; fi; \
374 fn=`basename $$x`; \
5407338a 375 $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
4813ad2d
RL
376 cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
377 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
378 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
379 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
380 done
5407338a 381 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
4813ad2d
RL
382 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
383 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
cb926df2 384 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
c7af65c7 385 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
5407338a 386 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
cb926df2
RL
387 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
388 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
389 fi
5407338a 390 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
c7af65c7
RS
391 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
392 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
393 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
394 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
5407338a 395 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
c7af65c7
RS
396 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
397 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
398 fi
dde10ab4 399
567a9e6f
RL
400install_dev:
401 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 402 @$(ECHO) "*** Installing development files"
3c65577f 403 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
24c4f736 404 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
5407338a 405 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
24c4f736
RL
406 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
407 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
408 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
567a9e6f
RL
409 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
410 $(BLDDIR)/include/openssl/*.h; do \
411 fn=`basename $$i`; \
5407338a 412 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
3c65577f
RL
413 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
414 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 415 done
e454f3ad 416 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
0f01b7bc 417 @set -e; for l in $(INSTALL_LIBS); do \
567a9e6f 418 fn=`basename $$l`; \
e454f3ad
RL
419 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
420 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
421 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
422 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
423 mv -f $(DESTDIR)$(libdir)/$$fn.new \
424 $(DESTDIR)$(libdir)/$$fn; \
567a9e6f 425 done
84af1bae 426 @ : {- output_off() if $disabled{shared}; "" -}
0f01b7bc 427 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
c8c2b779
RL
428 s1=`echo "$$s" | cut -f1 -d";"`; \
429 s2=`echo "$$s" | cut -f2 -d";"`; \
430 fn1=`basename $$s1`; \
431 fn2=`basename $$s2`; \
432 : {- output_off() if windowsdll(); "" -}; \
e454f3ad
RL
433 $(ECHO) "install $$s1 -> $(DESTDIR)$(libdir)/$$fn1"; \
434 cp $$s1 $(DESTDIR)$(libdir)/$$fn1.new; \
435 chmod 755 $(DESTDIR)$(libdir)/$$fn1.new; \
436 mv -f $(DESTDIR)$(libdir)/$$fn1.new \
437 $(DESTDIR)$(libdir)/$$fn1; \
c8c2b779 438 if [ "$$fn1" != "$$fn2" ]; then \
e454f3ad
RL
439 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
440 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
567a9e6f 441 fi; \
c8c2b779 442 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
e454f3ad
RL
443 $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
444 cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
445 chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
446 mv -f $(DESTDIR)$(libdir)/$$fn2.new \
447 $(DESTDIR)$(libdir)/$$fn2; \
ce5ed82f 448 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 449 done
84af1bae 450 @ : {- output_on() if $disabled{shared}; "" -}
e454f3ad
RL
451 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
452 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
453 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
454 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
455 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
456 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
457 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
458 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
459 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
460 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
567a9e6f
RL
461
462uninstall_dev:
5407338a 463 @$(ECHO) "*** Uninstalling development files"
24c4f736 464 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
5407338a 465 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
24c4f736
RL
466 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
467 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
567a9e6f
RL
468 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
469 $(BLDDIR)/include/openssl/*.h; do \
470 fn=`basename $$i`; \
5407338a 471 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
3c65577f 472 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
567a9e6f 473 done
98e5534e
RL
474 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
475 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
0f01b7bc 476 @set -e; for l in $(INSTALL_LIBS); do \
567a9e6f 477 fn=`basename $$l`; \
e454f3ad
RL
478 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
479 $(RM) $(DESTDIR)$(libdir)/$$fn; \
567a9e6f 480 done
84af1bae 481 @ : {- output_off() if $disabled{shared}; "" -}
0f01b7bc 482 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
c8c2b779
RL
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() if windowsdll(); "" -}; \
e454f3ad
RL
488 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
489 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
c8c2b779 490 if [ "$$fn1" != "$$fn2" ]; then \
e454f3ad
RL
491 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
492 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
567a9e6f 493 fi; \
c8c2b779 494 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
e454f3ad
RL
495 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
496 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
ce5ed82f 497 : {- output_on() unless windowsdll(); "" -}; \
567a9e6f 498 done
c8cca980 499 @ : {- output_on() if $disabled{shared}; "" -}
e454f3ad
RL
500 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
501 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
502 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
503 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
504 -$(RMDIR) $(DESTDIR)$(libdir)
567a9e6f
RL
505
506install_engines:
507 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
b2de11c5 508 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
5407338a 509 @$(ECHO) "*** Installing engines"
0f01b7bc 510 @set -e; for e in dummy $(INSTALL_ENGINES); do \
2b364f61 511 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 512 fn=`basename $$e`; \
5407338a 513 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
b2de11c5
RL
514 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
515 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
516 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
517 $(DESTDIR)$(ENGINESDIR)/$$fn; \
567a9e6f
RL
518 done
519
520uninstall_engines:
5407338a 521 @$(ECHO) "*** Uninstalling engines"
0f01b7bc 522 @set -e; for e in dummy $(INSTALL_ENGINES); do \
2b364f61 523 if [ "$$e" = "dummy" ]; then continue; fi; \
567a9e6f 524 fn=`basename $$e`; \
f0c93a85
RL
525 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
526 continue; \
527 fi; \
5407338a 528 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
b2de11c5 529 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
567a9e6f 530 done
b2de11c5 531 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
567a9e6f
RL
532
533install_runtime:
534 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
3c65577f 535 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
36b53720 536 @ : {- output_off() if windowsdll(); "" -}
e454f3ad 537 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
36b53720 538 @ : {- output_on() if windowsdll(); "" -}
5407338a 539 @$(ECHO) "*** Installing runtime files"
0f01b7bc 540 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
2b364f61 541 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 542 fn=`basename $$s`; \
36b53720 543 : {- output_off() unless windowsdll(); "" -}; \
5407338a 544 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
545 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
546 chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
547 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
548 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
36b53720 549 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
e454f3ad
RL
550 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
551 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
552 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
553 mv -f $(DESTDIR)$(libdir)/$$fn.new \
554 $(DESTDIR)$(libdir)/$$fn; \
36b53720 555 : {- output_on() if windowsdll(); "" -}; \
fcf80c46 556 done
0f01b7bc 557 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
2b364f61 558 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 559 fn=`basename $$x`; \
5407338a 560 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
561 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
562 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
563 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
564 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 565 done
2b364f61
RL
566 @set -e; for x in dummy $(BIN_SCRIPTS); do \
567 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 568 fn=`basename $$x`; \
5407338a 569 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f
RL
570 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
571 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
572 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
573 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 574 done
567a9e6f
RL
575
576uninstall_runtime:
5407338a 577 @$(ECHO) "*** Uninstalling runtime files"
0f01b7bc 578 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
567a9e6f 579 do \
2b364f61 580 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 581 fn=`basename $$x`; \
5407338a 582 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 583 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 584 done;
2b364f61 585 @set -e; for x in dummy $(BIN_SCRIPTS); \
567a9e6f 586 do \
2b364f61 587 if [ "$$x" = "dummy" ]; then continue; fi; \
567a9e6f 588 fn=`basename $$x`; \
5407338a 589 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 590 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
567a9e6f 591 done
b1837abd 592 @ : {- output_off() unless windowsdll(); "" -}
0f01b7bc 593 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
2b364f61 594 if [ "$$s" = "dummy" ]; then continue; fi; \
f99f91f1 595 fn=`basename $$s`; \
5407338a 596 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
3c65577f 597 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
fcf80c46 598 done
b1837abd 599 @ : {- output_on() unless windowsdll(); "" -}
b894054e 600 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
567a9e6f 601
567a9e6f
RL
602
603install_man_docs:
604 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 605 @$(ECHO) "*** Installing manpages"
cadb015b
RL
606 $(PERL) $(SRCDIR)/util/process_docs.pl \
607 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
567a9e6f
RL
608
609uninstall_man_docs:
5407338a 610 @$(ECHO) "*** Uninstalling manpages"
cadb015b
RL
611 $(PERL) $(SRCDIR)/util/process_docs.pl \
612 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
613 --remove
567a9e6f
RL
614
615install_html_docs:
616 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
5407338a 617 @$(ECHO) "*** Installing HTML manpages"
cadb015b
RL
618 $(PERL) $(SRCDIR)/util/process_docs.pl \
619 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
567a9e6f
RL
620
621uninstall_html_docs:
5407338a 622 @$(ECHO) "*** Uninstalling manpages"
cadb015b
RL
623 $(PERL) $(SRCDIR)/util/process_docs.pl \
624 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
567a9e6f
RL
625
626
627# Developer targets (note: these are only available on Unix) #########
628
6bb2106e
RL
629update: generate errors ordinals
630
b7650c67 631generate: generate_apps generate_crypto_bn generate_crypto_objects \
8e32e1ab 632 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
567a9e6f 633
65c1f979 634doc-nits:
1722496f 635 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
9e183d22 636 if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
65c1f979 637
567a9e6f
RL
638# Test coverage is a good idea for the future
639#coverage: $(PROGRAMS) $(TESTPROGRAMS)
640# ...
641
567a9e6f
RL
642lint:
643 lint -DLINT $(INCLUDES) $(SRCS)
644
9a9f8ee7
RL
645generate_apps:
646 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
647 < apps/openssl.cnf > apps/openssl-vms.cnf )
9a9f8ee7
RL
648
649generate_crypto_bn:
650 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
651
652generate_crypto_objects:
22defb43
RS
653 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
654 crypto/objects/objects.txt \
655 crypto/objects/obj_mac.num \
656 > crypto/objects/obj_mac.new && \
657 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
9a9f8ee7
RL
658 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
659 crypto/objects/objects.txt \
660 crypto/objects/obj_mac.num \
22defb43 661 > include/openssl/obj_mac.h )
e6f2bb66
KM
662 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
663 include/openssl/obj_mac.h \
22defb43 664 > crypto/objects/obj_dat.h )
9a9f8ee7
RL
665 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
666 crypto/objects/obj_mac.num \
667 crypto/objects/obj_xref.txt \
668 > crypto/objects/obj_xref.h )
6bb2106e 669
b7650c67
RL
670generate_crypto_conf:
671 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
672 > crypto/conf/conf_def.h )
673
674generate_crypto_asn1:
675 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
676 > crypto/asn1/charmap.h )
677
8e32e1ab
RL
678generate_fuzz_oids:
679 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
680 crypto/objects/obj_dat.h \
681 > fuzz/oids.txt )
682
52df25cf
RS
683# Set to -force to force a rebuild
684ERROR_REBUILD=
567a9e6f
RL
685errors:
686 ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
cb7b7275
RL
687 ( b=`pwd`; cd $(SRCDIR); \
688 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
689 ( b=`pwd`; cd $(SRCDIR)/engines; \
52df25cf 690 for E in *.ec ; do \
cb7b7275 691 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
52df25cf
RS
692 -conf $$E `basename $$E .ec`.c ; \
693 done )
567a9e6f
RL
694
695ordinals:
696 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
697 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
698
699test_ordinals:
700 ( cd test; \
701 SRCTOP=../$(SRCDIR) \
702 BLDTOP=../$(BLDDIR) \
703 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
704
705tags TAGS: FORCE
706 rm -f TAGS tags
707 -ctags -R .
708 -etags `find . -name '*.[ch]' -o -name '*.pm'`
709
710# Release targets (note: only available on Unix) #####################
711
77a9c26e
RL
712# If your tar command doesn't support --owner and --group, make sure to
713# use one that does, for example GNU tar
a1bce642 714TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
54bb8f74 715PREPARE_CMD=:
567a9e6f 716tar:
34a5b7d7 717 set -e; \
567a9e6f 718 TMPDIR=/var/tmp/openssl-copy.$$$$; \
54bb8f74 719 DISTDIR=$(NAME); \
567a9e6f
RL
720 mkdir -p $$TMPDIR/$$DISTDIR; \
721 (cd $(SRCDIR); \
5b7b0115
RL
722 excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
723 excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
724 echo "$$excl_re"; \
567a9e6f 725 git ls-tree -r --name-only --full-tree HEAD \
17c84aa7 726 | egrep -v "$$excl_re" \
567a9e6f
RL
727 | while read F; do \
728 mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
729 cp $$F $$TMPDIR/$$DISTDIR/$$F; \
730 done); \
17c84aa7 731 (cd $$TMPDIR/$$DISTDIR; \
54bb8f74 732 $(PREPARE_CMD); \
17c84aa7
RL
733 find . -type d -print | xargs chmod 755; \
734 find . -type f -print | xargs chmod a+r; \
735 find . -type f -perm -0100 -print | xargs chmod a+x); \
736 (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
567a9e6f
RL
737 | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
738 rm -rf $$TMPDIR
739 cd $(SRCDIR); ls -l $(TARFILE).gz
740
741dist:
bffa1ff8 742 @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
567a9e6f
RL
743
744# Helper targets #####################################################
745
342a1a23 746link-utils: $(BLDDIR)/util/opensslwrap.sh
567a9e6f 747
27f42b46 748$(BLDDIR)/util/opensslwrap.sh: configdata.pm
567a9e6f
RL
749 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
750 mkdir -p "$(BLDDIR)/util"; \
751 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
752 fi
342a1a23 753
c058fcd7 754FORCE:
567a9e6f
RL
755
756# Building targets ###################################################
757
8478a703 758libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
567a9e6f
RL
759libcrypto.pc:
760 @ ( echo 'prefix=$(INSTALLTOP)'; \
761 echo 'exec_prefix=$${prefix}'; \
e454f3ad
RL
762 if [ -n "$(LIBDIR)" ]; then \
763 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
764 else \
765 echo 'libdir=$(libdir)'; \
766 fi; \
567a9e6f 767 echo 'includedir=$${prefix}/include'; \
d4453024 768 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
567a9e6f
RL
769 echo ''; \
770 echo 'Name: OpenSSL-libcrypto'; \
771 echo 'Description: OpenSSL cryptography library'; \
772 echo 'Version: '$(VERSION); \
773 echo 'Libs: -L$${libdir} -lcrypto'; \
774 echo 'Libs.private: $(EX_LIBS)'; \
775 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
776
777libssl.pc:
778 @ ( echo 'prefix=$(INSTALLTOP)'; \
779 echo 'exec_prefix=$${prefix}'; \
e454f3ad
RL
780 if [ -n "$(LIBDIR)" ]; then \
781 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
782 else \
783 echo 'libdir=$(libdir)'; \
784 fi; \
567a9e6f
RL
785 echo 'includedir=$${prefix}/include'; \
786 echo ''; \
787 echo 'Name: OpenSSL-libssl'; \
788 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
789 echo 'Version: '$(VERSION); \
790 echo 'Requires.private: libcrypto'; \
791 echo 'Libs: -L$${libdir} -lssl'; \
567a9e6f
RL
792 echo 'Cflags: -I$${includedir}' ) > libssl.pc
793
794openssl.pc:
795 @ ( echo 'prefix=$(INSTALLTOP)'; \
796 echo 'exec_prefix=$${prefix}'; \
e454f3ad
RL
797 if [ -n "$(LIBDIR)" ]; then \
798 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
799 else \
800 echo 'libdir=$(libdir)'; \
801 fi; \
567a9e6f
RL
802 echo 'includedir=$${prefix}/include'; \
803 echo ''; \
804 echo 'Name: OpenSSL'; \
805 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
806 echo 'Version: '$(VERSION); \
807 echo 'Requires: libssl libcrypto' ) > openssl.pc
808
41240e68 809configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
27f42b46 810 @echo "Detected changed: $?"
a1b6933e 811 $(PERL) configdata.pm -r
567a9e6f
RL
812 @echo "**************************************************"
813 @echo "*** ***"
814 @echo "*** Please run the same make command again ***"
815 @echo "*** ***"
816 @echo "**************************************************"
817 @false
818
bf01fbbf 819reconfigure reconf:
a1b6933e 820 $(PERL) configdata.pm -r
bf01fbbf 821
567a9e6f
RL
822{-
823 use File::Basename;
824 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
cedbb146
RL
825
826 # Helper function to figure out dependencies on libraries
827 # It takes a list of library names and outputs a list of dependencies
828 sub compute_lib_depends {
84af1bae 829 if ($disabled{shared}) {
33105818 830 return map { lib($_) } @_;
cedbb146
RL
831 }
832
833 # Depending on shared libraries:
834 # On Windows POSIX layers, we depend on {libname}.dll.a
835 # On Unix platforms, we depend on {shlibname}.so
186a31e5 836 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
cedbb146
RL
837 }
838
66ddf178
RL
839 sub generatesrc {
840 my %args = @_;
841 my $generator = join(" ", @{$args{generator}});
8d34daf0 842 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
d4605727 843 my $incs = join("", map { " -I".$_ } @{$args{incs}});
8d34daf0 844 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
66ddf178
RL
845
846 if ($args{src} !~ /\.[sS]$/) {
7cae3864
RL
847 if ($args{generator}->[0] =~ m|^.*\.in$|) {
848 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
849 "util", "dofile.pl")),
850 rel2abs($config{builddir}));
851 return <<"EOF";
852$args{src}: $args{generator}->[0] $deps
853 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
854 "-o$target{build_file}" $generator > \$@
855EOF
856 } else {
857 return <<"EOF";
769777b0 858$args{src}: $args{generator}->[0] $deps
8d34daf0 859 \$(PERL)$generator_incs $generator > \$@
66ddf178 860EOF
7cae3864 861 }
66ddf178 862 } else {
8458f1bf 863 if ($args{generator}->[0] =~ /\.pl$/) {
8d34daf0 864 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
8458f1bf 865 } elsif ($args{generator}->[0] =~ /\.m4$/) {
8d34daf0 866 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
8458f1bf
RL
867 } elsif ($args{generator}->[0] =~ /\.S$/) {
868 $generator = undef;
869 } else {
870 die "Generator type for $args{src} unknown: $generator\n";
871 }
872
722c9762 873 my $cppflags = {
8bc0147f
RL
874 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
875 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
876 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
722c9762 877 } -> {$args{intent}};
8458f1bf
RL
878 if (defined($generator)) {
879 # If the target is named foo.S in build.info, we want to
880 # end up generating foo.s in two steps.
881 if ($args{src} =~ /\.S$/) {
882 (my $target = $args{src}) =~ s|\.S$|.s|;
883 return <<"EOF";
769777b0 884$target: $args{generator}->[0] $deps
0218fc37 885 ( trap "rm -f \$@.*" INT 0; \\
8458f1bf 886 $generator \$@.S; \\
d8e2b4f9 887 \$(CPP) $incs $cppflags \$@.S | \\
39199fb3
AP
888 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
889 mv -f \$@.i \$@ )
66ddf178 890EOF
8458f1bf
RL
891 }
892 # Otherwise....
66ddf178 893 return <<"EOF";
769777b0 894$args{src}: $args{generator}->[0] $deps
8458f1bf 895 $generator \$@
66ddf178 896EOF
66ddf178 897 }
8458f1bf 898 return <<"EOF";
769777b0 899$args{src}: $args{generator}->[0] $deps
d8e2b4f9 900 \$(CPP) $incs $cppflags $args{generator}->[0] | \\
39199fb3 901 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
8458f1bf 902EOF
66ddf178
RL
903 }
904 }
905
bb26842d
RL
906 # Should one wonder about the end of the Perl snippet, it's because this
907 # second regexp eats up line endings as well, if the removed path is the
908 # last in the line. We may therefore need to put back a line ending.
88297284 909 sub src2obj {
567a9e6f 910 my %args = @_;
81183680 911 (my $obj = $args{obj}) =~ s|\.o$||;
674d5858
RL
912 my @srcs = map { if ($unified_info{generate}->{$_}) {
913 (my $x = $_) =~ s/\.S$/.s/; $x
914 } else {
915 $_
916 }
917 } ( @{$args{srcs}} );
8458f1bf
RL
918 my $srcs = join(" ", @srcs);
919 my $deps = join(" ", @srcs, @{$args{deps}});
45502bfe 920 my $incs = join("", map { " -I".$_ } @{$args{incs}});
722c9762
RL
921 my $cmd;
922 my $cmdflags;
923 my $cmdcompile;
81183680
RL
924 my $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
925 if (grep /\.rc$/, @srcs) {
926 $cmd = '$(RC)';
927 $cmdflags = '$(RCFLAGS)';
8c3bc594 928 $cmdcompile = '';
81183680
RL
929 $makedepprog = undef;
930 } elsif (grep /\.(cc|cpp)$/, @srcs) {
931 $cmd = '$(CXX)';
722c9762
RL
932 $cmdcompile = ' -c';
933 $cmdflags = {
934 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
935 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
936 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
937 } -> {$args{intent}};
7763472f 938 } else {
722c9762
RL
939 $cmd = '$(CC)';
940 $cmdcompile = ' -c';
941 $cmdflags = {
942 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
943 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
944 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
945 } -> {$args{intent}};
7763472f 946 }
8c3bc594 947 $cmdflags .= $cmdcompile;
7e5b8b93
RL
948 my $recipe = <<"EOF";
949$obj$objext: $deps
950EOF
81183680 951 if (defined $makedepprog && $makedepprog !~ /\/makedepend/) {
29eed3dd 952 $recipe .= <<"EOF";
81183680 953 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
7e5b8b93
RL
954 \@touch $obj$depext.tmp
955 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
956 rm -f $obj$depext.tmp; \\
29b28eee 957 else \\
7e5b8b93 958 mv $obj$depext.tmp $obj$depext; \\
987dbc7f 959 fi
29eed3dd 960EOF
7e5b8b93 961 } else {
29eed3dd 962 $recipe .= <<"EOF";
81183680 963 $cmd $incs $cmdflags -o \$\@ $srcs
567a9e6f 964EOF
81183680 965 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
7e5b8b93 966 $recipe .= <<"EOF";
81183680 967 -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cmdflags -- $srcs \\
7e5b8b93
RL
968 >$obj$depext.tmp 2>/dev/null
969 -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
29b28eee 970 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
987dbc7f 971 rm -f $obj$depext.tmp; \\
29b28eee
RL
972 else \\
973 mv $obj$depext.tmp $obj$depext; \\
340da949 974 fi
567a9e6f 975EOF
7e5b8b93 976 }
29eed3dd
RL
977 }
978 return $recipe;
567a9e6f
RL
979 }
980 # On Unix, we build shlibs from static libs, so we're ignoring the
981 # object file array. We *know* this routine is only called when we've
982 # configure 'shared'.
983 sub libobj2shlib {
984 my %args = @_;
985 my $lib = $args{lib};
986 my $shlib = $args{shlib};
987 my $libd = dirname($lib);
988 my $libn = basename($lib);
989 (my $libname = $libn) =~ s/^lib//;
47eeaf45
RL
990 my @linkdirs = ();
991 foreach (@{args{deps}}) {
992 my $d = dirname($_);
993 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
994 }
995 my $linkflags = join("", map { "-L$_ " } @linkdirs);
996 my $linklibs = join("", map { my $f = basename($_);
cedbb146 997 (my $l = $f) =~ s/^lib//;
47eeaf45 998 " -l$l" } @{$args{deps}});
81183680
RL
999 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
1000 grep { $_ =~ m|\.o$| }
1001 @{$args{objs}};
1002 my @defs = grep { $_ =~ /\.(def|map)$/ } @{$args{objs}};
1003 my @deps = compute_lib_depends(@{$args{deps}});
1004 die "More than one exported symbol map" if scalar @defs > 1;
1005 my $objs = join(" ", @objs);
1006 my $deps = join(" ", @objs, @defs, @deps);
f5c174ff 1007 my $target = shlib_simple($lib);
d07abe13 1008 my $target_full = shlib($lib);
81183680
RL
1009 my $shared_soname = "";
1010 $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
1011 if defined $target{shared_sonameflag};
1012 my $shared_imp = "";
1013 $shared_imp .= ' '.$target{shared_impflag}.basename($target)
1014 if defined $target{shared_impflag};
1015 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1016 my $recipe = <<"EOF";
1017# When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
cedbb146
RL
1018# that two files get produced, {shlibname}.dll and {libname}.dll.a.
1019# With all other Unix platforms, we often build a shared library with the
1020# SO version built into the file name and a symlink without the SO version
1021# It's not necessary to have both as targets. The choice falls on the
d4453024
RL
1022# simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
1023# {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
81183680 1024$target: $deps
722c9762 1025 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
81183680
RL
1026 -o $target_full$shared_def $objs \\
1027 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
fcf80c46 1028EOF
81183680
RL
1029 if (windowsdll()) {
1030 $recipe .= <<"EOF";
d4453024
RL
1031 rm -f apps/$shlib'\$(SHLIB_EXT)'
1032 rm -f test/$shlib'\$(SHLIB_EXT)'
81183680 1033 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
d4453024
RL
1034 cp -p $shlib'\$(SHLIB_EXT)' apps/
1035 cp -p $shlib'\$(SHLIB_EXT)' test/
81183680
RL
1036 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1037EOF
1038 } else {
1039 $recipe .= <<"EOF";
50625bf5
RL
1040 if [ '$target' != '$target_full' ]; then \\
1041 rm -f $target; \\
1042 ln -s $target_full $target; \\
1043 fi
567a9e6f 1044EOF
81183680 1045 }
567a9e6f 1046 }
5386287c 1047 sub obj2dso {
567a9e6f 1048 my %args = @_;
d07abe13
RL
1049 my $dso = $args{lib};
1050 my $dsod = dirname($dso);
1051 my $dson = basename($dso);
47eeaf45
RL
1052 my @linkdirs = ();
1053 foreach (@{args{deps}}) {
1054 my $d = dirname($_);
1055 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1056 }
1057 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1058 my $linklibs = join("", map { my $f = basename($_);
81183680 1059 (my $l = $f) =~ s/^lib//;
47eeaf45 1060 " -l$l" } @{$args{deps}});
81183680
RL
1061 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1062 my @deps = compute_lib_depends(@{$args{deps}});
1063 my $objs = join(" ", @objs);
1064 my $deps = join(" ", @deps);
d07abe13 1065 my $target = dso($dso);
567a9e6f 1066 return <<"EOF";
f5c174ff 1067$target: $objs $deps
722c9762 1068 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
81183680
RL
1069 -o $target $objs \\
1070 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
567a9e6f
RL
1071EOF
1072 }
1073 sub obj2lib {
1074 my %args = @_;
33105818 1075 (my $lib = $args{lib}) =~ s/\.a$//;
81183680
RL
1076 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1077 my $objs = join(" ", @objs);
567a9e6f 1078 return <<"EOF";
834aae2a 1079$lib$libext: $objs
5b18235a 1080 \$(AR) \$(ARFLAGS) \$\@ \$\?
567a9e6f
RL
1081 \$(RANLIB) \$\@ || echo Never mind.
1082EOF
1083 }
1084 sub obj2bin {
1085 my %args = @_;
1086 my $bin = $args{bin};
1087 my $bind = dirname($bin);
1088 my $binn = basename($bin);
81183680
RL
1089 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$|$objext|; $x }
1090 @{$args{objs}});
cedbb146 1091 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
47eeaf45
RL
1092 my @linkdirs = ();
1093 foreach (@{args{deps}}) {
1094 next if $_ =~ /\.a$/;
1095 my $d = dirname($_);
1096 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1097 }
1098 my $linkflags = join("", map { "-L$_ " } @linkdirs);
186a31e5
RL
1099 my $linklibs = join("", map { if ($_ =~ /\.a$/) {
1100 " $_";
1101 } else {
186a31e5 1102 my $f = basename($_);
186a31e5 1103 (my $l = $f) =~ s/^lib//;
47eeaf45 1104 " -l$l"
186a31e5
RL
1105 }
1106 } @{$args{deps}});
81183680 1107 my $cmd = '$(CC)';
722c9762 1108 my $cmdflags = '$(BIN_CFLAGS)';
81183680
RL
1109 if (grep /_cc\.o$/, @{$args{objs}}) {
1110 $cmd = '$(CXX)';
722c9762 1111 $cmdflags = '$(BIN_CXXFLAGS)';
7763472f 1112 }
567a9e6f 1113 return <<"EOF";
834aae2a 1114$bin$exeext: $objs $deps
81183680 1115 rm -f $bin$exeext
722c9762 1116 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
47eeaf45 1117 -o $bin$exeext $objs \\
81183680 1118 \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
567a9e6f
RL
1119EOF
1120 }
1121 sub in2script {
1122 my %args = @_;
1123 my $script = $args{script};
1124 my $sources = join(" ", @{$args{sources}});
1125 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1126 "util", "dofile.pl")),
1127 rel2abs($config{builddir}));
1128 return <<"EOF";
88297284 1129$script: $sources
4b799cea 1130 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
ba327ade 1131 "-o$target{build_file}" $sources > "$script"
567a9e6f 1132 chmod a+x $script
0ad1d94d
RL
1133EOF
1134 }
1135 sub generatedir {
1136 my %args = @_;
1137 my $dir = $args{dir};
1138 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1139 my @actions = ();
1140 my %extinfo = ( dso => $dsoext,
1141 lib => $libext,
1142 bin => $exeext );
1143
1144 foreach my $type (("dso", "lib", "bin", "script")) {
1145 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
850000aa
RL
1146 # For lib object files, we could update the library. However, it
1147 # was decided that it's enough to build the directory local object
1148 # files, so we don't need to add any actions, and the dependencies
1149 # are already taken care of.
1150 if ($type ne "lib") {
0ad1d94d
RL
1151 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1152 if (dirname($prod) eq $dir) {
1153 push @deps, $prod.$extinfo{$type};
1154 } else {
1155 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1156 }
1157 }
1158 }
1159 }
1160
1161 my $deps = join(" ", @deps);
1162 my $actions = join("\n", "", @actions);
1163 return <<"EOF";
1164$args{dir} $args{dir}/: $deps$actions
567a9e6f
RL
1165EOF
1166 }
1167 "" # Important! This becomes part of the template result.
1168-}