]>
Commit | Line | Data |
---|---|---|
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 | -} |
79 | PLATFORM={- $config{target} -} | |
80 | OPTIONS={- $config{options} -} | |
81 | CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -}) | |
82 | SRCDIR={- $config{sourcedir} -} | |
83 | BLDDIR={- $config{builddir} -} | |
84 | ||
85 | VERSION={- $config{version} -} | |
86 | MAJOR={- $config{major} -} | |
87 | MINOR={- $config{minor} -} | |
88 | SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -} | |
89 | SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -} | |
90 | SHLIB_MAJOR={- $config{shlib_major} -} | |
91 | SHLIB_MINOR={- $config{shlib_minor} -} | |
92 | SHLIB_TARGET={- $target{shared_target} -} | |
d4453024 RL |
93 | SHLIB_EXT={- $shlibext -} |
94 | SHLIB_EXT_SIMPLE={- $shlibextsimple -} | |
95 | SHLIB_EXT_IMPORT={- $shlibextimport -} | |
567a9e6f | 96 | |
33105818 | 97 | LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -} |
f5c174ff | 98 | SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -} |
0f01b7bc | 99 | SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -} |
f5c174ff | 100 | ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -} |
1e3d16b0 | 101 | PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -} |
567a9e6f | 102 | SCRIPTS={- join(" ", @{$unified_info{scripts}}) -} |
29eed3dd | 103 | {- output_off() if $disabled{makedepend}; "" -} |
834aae2a | 104 | DEPS={- 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 | 108 | GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -} |
05a7aee0 RL |
109 | GENERATED={- 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 | 116 | INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -} |
0f01b7bc RL |
117 | INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -} |
118 | INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -} | |
119 | INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -} | |
120 | INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -} | |
df653379 | 121 | {- output_off() if $disabled{apps}; "" -} |
567a9e6f | 122 | BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash |
b8a9af68 | 123 | MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget |
df653379 | 124 | {- output_on() if $disabled{apps}; "" -} |
567a9e6f | 125 | |
6a74806e RL |
126 | APPS_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 | 132 | DESTDIR= |
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 | |
136 | INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet | |
137 | # | |
138 | our $prefix = $config{prefix} || "/usr/local"; | |
139 | $prefix -} | |
140 | OPENSSLDIR={- # | |
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 -} | |
157 | LIBDIR={- # | |
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 -} | |
166 | ENGINESDIR={- 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 | |
171 | LIBRPATH=$(INSTALLTOP)/$(LIBDIR) | |
172 | ||
dde10ab4 | 173 | MANDIR=$(INSTALLTOP)/share/man |
8be7bdb5 RL |
174 | DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME) |
175 | HTMLDIR=$(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. | |
180 | MANSUFFIX= | |
567a9e6f RL |
181 | HTMLSUFFIX=html |
182 | ||
5407338a RS |
183 | # For "optional" echo messages, to get "real" silence |
184 | ECHO = echo | |
567a9e6f RL |
185 | |
186 | CROSS_COMPILE= {- $config{cross_compile_prefix} -} | |
187 | CC= $(CROSS_COMPILE){- $target{cc} -} | |
2952b9b8 | 188 | CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -} |
076e596f | 189 | CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -} |
7763472f | 190 | CXX= $(CROSS_COMPILE){- $target{cxx} -} |
a60150e9 | 191 | CXXFLAGS={- our $cxxflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cxxflags} -} {- $config{cxxflags} -} -std=c++11 |
47eeaf45 | 192 | LDFLAGS= {- $config{lflags} -} {- $target{lflags} -} |
940a09ba | 193 | PLIB_LDFLAGS= {- $target{plib_lflags} -} |
2952b9b8 | 194 | EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -} |
bbd9a50f | 195 | LIB_CFLAGS={- $target{shared_cflag} || "" -} |
7763472f | 196 | LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -} |
075f7e2c | 197 | LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -} |
793077d0 RL |
198 | DSO_CFLAGS={- $target{dso_cflags} || "" -} |
199 | DSO_CXXFLAGS={- $target{dso_cxxflags} || "" -} | |
200 | DSO_LDFLAGS={- $target{dso_lflags} || "" -} | |
201 | BIN_CFLAGS={- $target{bin_cflags} || "" -} | |
202 | BIN_CXXFLAGS={- $target{bin_cxxflags} || "" -} | |
203 | BIN_LDFLAGS={- $target{bin_lflags} || "" -} | |
567a9e6f RL |
204 | |
205 | PERL={- $config{perl} -} | |
206 | ||
207 | ARFLAGS= {- $target{arflags} -} | |
208 | AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r | |
209 | RANLIB= {- $target{ranlib} -} | |
210 | NM= $(CROSS_COMPILE){- $target{nm} || "nm" -} | |
8f41ff2d RL |
211 | RCFLAGS={- $target{shared_rcflag} -} |
212 | RC= $(CROSS_COMPILE){- $target{rc} || "windres" -} | |
567a9e6f | 213 | RM= rm -f |
98e5534e | 214 | RMDIR= rmdir |
567a9e6f RL |
215 | TAR= {- $target{tar} || "tar" -} |
216 | TARFLAGS= {- $target{tarflags} -} | |
29eed3dd | 217 | MAKEDEPEND={- $config{makedepprog} -} |
567a9e6f RL |
218 | |
219 | BASENAME= openssl | |
220 | NAME= $(BASENAME)-$(VERSION) | |
221 | TARFILE= ../$(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. | |
228 | AS=$(CC) -c | |
229 | ASFLAG=$(CFLAGS) | |
230 | PERLASM_SCHEME= {- $target{perlasm_scheme} -} | |
231 | ||
232 | # For x86 assembler: Set PROCESSOR to 386 if you want to support | |
233 | # the 80386. | |
234 | PROCESSOR= {- $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... | |
241 | LC_ALL=C | |
242 | LC_MESSAGES=C | |
243 | LANG=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 | 252 | build_generated: $(GENERATED_MANDATORY) |
c058fcd7 | 253 | build_libs_nodep: libcrypto.pc libssl.pc openssl.pc |
c058fcd7 | 254 | build_engines_nodep: $(ENGINES) |
1e3d16b0 RL |
255 | build_programs_nodep: $(PROGRAMS) $(SCRIPTS) |
256 | ||
257 | # Kept around for backward compatibility | |
258 | build_apps build_tests: build_programs | |
68a5f1a2 | 259 | |
9b03b91b RL |
260 | # Convenience target to prebuild all generated files, not just the mandatory |
261 | # ones | |
262 | build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) | |
263 | ||
1b741653 | 264 | test: 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 | |
281 | list-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 | ||
289 | install: install_sw install_ssldirs install_docs | |
290 | ||
291 | uninstall: uninstall_docs uninstall_sw | |
567a9e6f RL |
292 | |
293 | libclean: | |
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 | |
307 | clean: 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 |
d016d1ec | 314 | $(RM) -r test/test-runs |
4813ad2d RL |
315 | $(RM) openssl.pc libcrypto.pc libssl.pc |
316 | -$(RM) `find . -type l -a \! -path "./.git/*"` | |
317 | $(RM) $(TARFILE) | |
567a9e6f | 318 | |
7cae3864 | 319 | distclean: 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 | 325 | depend: |
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 | ||
344 | install_sw: all install_dev install_engines install_runtime | |
345 | ||
f99f91f1 | 346 | uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev |
567a9e6f RL |
347 | |
348 | install_docs: install_man_docs install_html_docs | |
349 | ||
350 | uninstall_docs: uninstall_man_docs uninstall_html_docs | |
8be7bdb5 | 351 | $(RM) -r -v $(DESTDIR)$(DOCDIR) |
567a9e6f | 352 | |
dde10ab4 RL |
353 | install_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 |
385 | install_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 | |
447 | uninstall_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 | |
491 | install_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 | ||
505 | uninstall_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 | |
518 | install_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 | |
561 | uninstall_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 | |
588 | install_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 | |
594 | uninstall_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 | |
600 | install_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 | |
606 | uninstall_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 |
614 | update: generate errors ordinals |
615 | ||
b7650c67 | 616 | generate: generate_apps generate_crypto_bn generate_crypto_objects \ |
8e32e1ab | 617 | generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids |
567a9e6f | 618 | |
65c1f979 | 619 | doc-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 |
627 | lint: |
628 | lint -DLINT $(INCLUDES) $(SRCS) | |
629 | ||
9a9f8ee7 RL |
630 | generate_apps: |
631 | ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \ | |
632 | < apps/openssl.cnf > apps/openssl-vms.cnf ) | |
9a9f8ee7 RL |
633 | |
634 | generate_crypto_bn: | |
635 | ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h ) | |
636 | ||
637 | generate_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 |
650 | generate_crypto_conf: |
651 | ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \ | |
652 | > crypto/conf/conf_def.h ) | |
653 | ||
654 | generate_crypto_asn1: | |
655 | ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \ | |
656 | > crypto/asn1/charmap.h ) | |
657 | ||
8e32e1ab RL |
658 | generate_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 |
664 | ERROR_REBUILD= | |
567a9e6f RL |
665 | errors: |
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 | |
674 | ordinals: | |
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 | ||
678 | test_ordinals: | |
679 | ( cd test; \ | |
680 | SRCTOP=../$(SRCDIR) \ | |
681 | BLDTOP=../$(BLDDIR) \ | |
682 | $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals ) | |
683 | ||
684 | tags 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 | 693 | TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - |
54bb8f74 | 694 | PREPARE_CMD=: |
567a9e6f | 695 | tar: |
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 | ||
720 | dist: | |
bffa1ff8 | 721 | @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar |
567a9e6f RL |
722 | |
723 | # Helper targets ##################################################### | |
724 | ||
342a1a23 | 725 | link-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 | 733 | FORCE: |
567a9e6f RL |
734 | |
735 | # Building targets ################################################### | |
736 | ||
8478a703 | 737 | libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -} |
567a9e6f RL |
738 | libcrypto.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 | ||
752 | libssl.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 | ||
766 | openssl.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 | 777 | configdata.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 > \$@ | |
821 | EOF | |
822 | } else { | |
823 | return <<"EOF"; | |
769777b0 | 824 | $args{src}: $args{generator}->[0] $deps |
8d34daf0 | 825 | \$(PERL)$generator_incs $generator > \$@ |
66ddf178 | 826 | EOF |
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 | 851 | EOF |
8458f1bf RL |
852 | } |
853 | # Otherwise.... | |
66ddf178 | 854 | return <<"EOF"; |
769777b0 | 855 | $args{src}: $args{generator}->[0] $deps |
8458f1bf | 856 | $generator \$@ |
66ddf178 | 857 | EOF |
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 | 863 | EOF |
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 = @_; |
81183680 | 872 | (my $obj = $args{obj}) =~ s|\.o$||; |
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 | } | |
81183680 RL |
887 | my $cmd = '$(CC)'; |
888 | my $cmdflags = '$(CFLAGS) -c'; | |
889 | my $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog}; | |
890 | if (grep /\.rc$/, @srcs) { | |
891 | $cmd = '$(RC)'; | |
892 | $cmdflags = '$(RCFLAGS)'; | |
893 | $makedepprog = undef; | |
894 | } elsif (grep /\.(cc|cpp)$/, @srcs) { | |
895 | $cmd = '$(CXX)'; | |
896 | $cmdflags = '$(CXXFLAGS) -c'; | |
897 | $cmdflags .= ' ' . { lib => '$(LIB_CXXFLAGS)', | |
898 | dso => '$(DSO_CXXFLAGS)', | |
899 | bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}}; | |
7763472f | 900 | } else { |
81183680 RL |
901 | $cmdflags .= ' ' . { lib => '$(LIB_CFLAGS)', |
902 | dso => '$(DSO_CFLAGS)', | |
903 | bin => '$(BIN_CFLAGS)' } -> {$args{intent}}; | |
7763472f | 904 | } |
7e5b8b93 RL |
905 | my $recipe = <<"EOF"; |
906 | $obj$objext: $deps | |
907 | EOF | |
81183680 | 908 | if (defined $makedepprog && $makedepprog !~ /\/makedepend/) { |
29eed3dd | 909 | $recipe .= <<"EOF"; |
81183680 | 910 | $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs |
7e5b8b93 RL |
911 | \@touch $obj$depext.tmp |
912 | \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\ | |
913 | rm -f $obj$depext.tmp; \\ | |
29b28eee | 914 | else \\ |
7e5b8b93 | 915 | mv $obj$depext.tmp $obj$depext; \\ |
987dbc7f | 916 | fi |
29eed3dd | 917 | EOF |
7e5b8b93 | 918 | } else { |
29eed3dd | 919 | $recipe .= <<"EOF"; |
81183680 | 920 | $cmd $incs $cmdflags -o \$\@ $srcs |
567a9e6f | 921 | EOF |
81183680 | 922 | if (defined $makedepprog && $makedepprog =~ /\/makedepend/) { |
7e5b8b93 | 923 | $recipe .= <<"EOF"; |
81183680 | 924 | -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cmdflags -- $srcs \\ |
7e5b8b93 RL |
925 | >$obj$depext.tmp 2>/dev/null |
926 | -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp | |
29b28eee | 927 | \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\ |
987dbc7f | 928 | rm -f $obj$depext.tmp; \\ |
29b28eee RL |
929 | else \\ |
930 | mv $obj$depext.tmp $obj$depext; \\ | |
340da949 | 931 | fi |
567a9e6f | 932 | EOF |
7e5b8b93 | 933 | } |
29eed3dd RL |
934 | } |
935 | return $recipe; | |
567a9e6f RL |
936 | } |
937 | # On Unix, we build shlibs from static libs, so we're ignoring the | |
938 | # object file array. We *know* this routine is only called when we've | |
939 | # configure 'shared'. | |
940 | sub libobj2shlib { | |
941 | my %args = @_; | |
942 | my $lib = $args{lib}; | |
943 | my $shlib = $args{shlib}; | |
944 | my $libd = dirname($lib); | |
945 | my $libn = basename($lib); | |
946 | (my $libname = $libn) =~ s/^lib//; | |
47eeaf45 RL |
947 | my @linkdirs = (); |
948 | foreach (@{args{deps}}) { | |
949 | my $d = dirname($_); | |
950 | push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; | |
951 | } | |
952 | my $linkflags = join("", map { "-L$_ " } @linkdirs); | |
953 | my $linklibs = join("", map { my $f = basename($_); | |
cedbb146 | 954 | (my $l = $f) =~ s/^lib//; |
47eeaf45 | 955 | " -l$l" } @{$args{deps}}); |
81183680 RL |
956 | my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } |
957 | grep { $_ =~ m|\.o$| } | |
958 | @{$args{objs}}; | |
959 | my @defs = grep { $_ =~ /\.(def|map)$/ } @{$args{objs}}; | |
960 | my @deps = compute_lib_depends(@{$args{deps}}); | |
961 | die "More than one exported symbol map" if scalar @defs > 1; | |
962 | my $objs = join(" ", @objs); | |
963 | my $deps = join(" ", @objs, @defs, @deps); | |
f5c174ff | 964 | my $target = shlib_simple($lib); |
d07abe13 | 965 | my $target_full = shlib($lib); |
81183680 RL |
966 | my $shared_soname = ""; |
967 | $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full) | |
968 | if defined $target{shared_sonameflag}; | |
969 | my $shared_imp = ""; | |
970 | $shared_imp .= ' '.$target{shared_impflag}.basename($target) | |
971 | if defined $target{shared_impflag}; | |
972 | my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); | |
973 | my $recipe = <<"EOF"; | |
974 | # When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact | |
cedbb146 RL |
975 | # that two files get produced, {shlibname}.dll and {libname}.dll.a. |
976 | # With all other Unix platforms, we often build a shared library with the | |
977 | # SO version built into the file name and a symlink without the SO version | |
978 | # It's not necessary to have both as targets. The choice falls on the | |
d4453024 RL |
979 | # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and |
980 | # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms. | |
81183680 | 981 | $target: $deps |
47eeaf45 | 982 | \$(CC) \$(CFLAGS) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\ |
81183680 RL |
983 | -o $target_full$shared_def $objs \\ |
984 | \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS) | |
fcf80c46 | 985 | EOF |
81183680 RL |
986 | if (windowsdll()) { |
987 | $recipe .= <<"EOF"; | |
d4453024 RL |
988 | rm -f apps/$shlib'\$(SHLIB_EXT)' |
989 | rm -f test/$shlib'\$(SHLIB_EXT)' | |
81183680 | 990 | rm -f fuzz/$shlib'\$(SHLIB_EXT)' |
d4453024 RL |
991 | cp -p $shlib'\$(SHLIB_EXT)' apps/ |
992 | cp -p $shlib'\$(SHLIB_EXT)' test/ | |
81183680 RL |
993 | cp -p $shlib'\$(SHLIB_EXT)' fuzz/ |
994 | EOF | |
995 | } else { | |
996 | $recipe .= <<"EOF"; | |
997 | rm -f $target | |
998 | ln -s $target_full $target | |
567a9e6f | 999 | EOF |
81183680 | 1000 | } |
567a9e6f | 1001 | } |
5386287c | 1002 | sub obj2dso { |
567a9e6f | 1003 | my %args = @_; |
d07abe13 RL |
1004 | my $dso = $args{lib}; |
1005 | my $dsod = dirname($dso); | |
1006 | my $dson = basename($dso); | |
47eeaf45 RL |
1007 | my @linkdirs = (); |
1008 | foreach (@{args{deps}}) { | |
1009 | my $d = dirname($_); | |
1010 | push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; | |
1011 | } | |
1012 | my $linkflags = join("", map { "-L$_ " } @linkdirs); | |
1013 | my $linklibs = join("", map { my $f = basename($_); | |
81183680 | 1014 | (my $l = $f) =~ s/^lib//; |
47eeaf45 | 1015 | " -l$l" } @{$args{deps}}); |
81183680 RL |
1016 | my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}}; |
1017 | my @deps = compute_lib_depends(@{$args{deps}}); | |
1018 | my $objs = join(" ", @objs); | |
1019 | my $deps = join(" ", @deps); | |
d07abe13 | 1020 | my $target = dso($dso); |
567a9e6f | 1021 | return <<"EOF"; |
f5c174ff | 1022 | $target: $objs $deps |
47eeaf45 | 1023 | \$(CC) \$(CFLAGS) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\ |
81183680 RL |
1024 | -o $target $objs \\ |
1025 | \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS) | |
567a9e6f RL |
1026 | EOF |
1027 | } | |
1028 | sub obj2lib { | |
1029 | my %args = @_; | |
33105818 | 1030 | (my $lib = $args{lib}) =~ s/\.a$//; |
81183680 RL |
1031 | my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}}; |
1032 | my $objs = join(" ", @objs); | |
567a9e6f | 1033 | return <<"EOF"; |
834aae2a | 1034 | $lib$libext: $objs |
68cd4e3f | 1035 | \$(AR) \$\@ \$\? |
567a9e6f RL |
1036 | \$(RANLIB) \$\@ || echo Never mind. |
1037 | EOF | |
1038 | } | |
1039 | sub obj2bin { | |
1040 | my %args = @_; | |
1041 | my $bin = $args{bin}; | |
1042 | my $bind = dirname($bin); | |
1043 | my $binn = basename($bin); | |
81183680 RL |
1044 | my $objs = join(" ", map { (my $x = $_) =~ s|\.o$|$objext|; $x } |
1045 | @{$args{objs}}); | |
cedbb146 | 1046 | my $deps = join(" ",compute_lib_depends(@{$args{deps}})); |
47eeaf45 RL |
1047 | my @linkdirs = (); |
1048 | foreach (@{args{deps}}) { | |
1049 | next if $_ =~ /\.a$/; | |
1050 | my $d = dirname($_); | |
1051 | push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; | |
1052 | } | |
1053 | my $linkflags = join("", map { "-L$_ " } @linkdirs); | |
186a31e5 RL |
1054 | my $linklibs = join("", map { if ($_ =~ /\.a$/) { |
1055 | " $_"; | |
1056 | } else { | |
186a31e5 | 1057 | my $f = basename($_); |
186a31e5 | 1058 | (my $l = $f) =~ s/^lib//; |
47eeaf45 | 1059 | " -l$l" |
186a31e5 RL |
1060 | } |
1061 | } @{$args{deps}}); | |
81183680 RL |
1062 | my $cmd = '$(CC)'; |
1063 | my $cmdflags = '$(CFLAGS) $(BIN_CFLAGS)'; | |
1064 | if (grep /_cc\.o$/, @{$args{objs}}) { | |
1065 | $cmd = '$(CXX)'; | |
1066 | $cmdflags = '$(CXXFLAGS) $(BIN_CXXFLAGS)'; | |
7763472f | 1067 | } |
567a9e6f | 1068 | return <<"EOF"; |
834aae2a | 1069 | $bin$exeext: $objs $deps |
81183680 | 1070 | rm -f $bin$exeext |
47eeaf45 RL |
1071 | \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(LDFLAGS) \$(BIN_LDFLAGS) \\ |
1072 | -o $bin$exeext $objs \\ | |
81183680 | 1073 | \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS) |
567a9e6f RL |
1074 | EOF |
1075 | } | |
1076 | sub in2script { | |
1077 | my %args = @_; | |
1078 | my $script = $args{script}; | |
1079 | my $sources = join(" ", @{$args{sources}}); | |
1080 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, | |
1081 | "util", "dofile.pl")), | |
1082 | rel2abs($config{builddir})); | |
1083 | return <<"EOF"; | |
88297284 | 1084 | $script: $sources |
4b799cea | 1085 | \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ |
ba327ade | 1086 | "-o$target{build_file}" $sources > "$script" |
567a9e6f | 1087 | chmod a+x $script |
0ad1d94d RL |
1088 | EOF |
1089 | } | |
1090 | sub generatedir { | |
1091 | my %args = @_; | |
1092 | my $dir = $args{dir}; | |
1093 | my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}}; | |
1094 | my @actions = (); | |
1095 | my %extinfo = ( dso => $dsoext, | |
1096 | lib => $libext, | |
1097 | bin => $exeext ); | |
1098 | ||
1099 | foreach my $type (("dso", "lib", "bin", "script")) { | |
1100 | next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); | |
850000aa RL |
1101 | # For lib object files, we could update the library. However, it |
1102 | # was decided that it's enough to build the directory local object | |
1103 | # files, so we don't need to add any actions, and the dependencies | |
1104 | # are already taken care of. | |
1105 | if ($type ne "lib") { | |
0ad1d94d RL |
1106 | foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) { |
1107 | if (dirname($prod) eq $dir) { | |
1108 | push @deps, $prod.$extinfo{$type}; | |
1109 | } else { | |
1110 | push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}}); | |
1111 | } | |
1112 | } | |
1113 | } | |
1114 | } | |
1115 | ||
1116 | my $deps = join(" ", @deps); | |
1117 | my $actions = join("\n", "", @actions); | |
1118 | return <<"EOF"; | |
1119 | $args{dir} $args{dir}/: $deps$actions | |
567a9e6f RL |
1120 | EOF |
1121 | } | |
1122 | "" # Important! This becomes part of the template result. | |
1123 | -} |