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