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