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