]>
Commit | Line | Data |
---|---|---|
567a9e6f RL |
1 | ## |
2 | ## Makefile for OpenSSL | |
3 | ## | |
4 | ## {- join("\n## ", @autowarntext) -} | |
5 | {- | |
6 | sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ } | |
7 | sub shlib_ext { $target{shared_extension} || ".so" } | |
8 | sub shlib_ext_simple { (my $x = $target{shared_extension}) | |
9 | =~ s/\.\$\(SHLIB_MAJOR\)\.\$\(SHLIB_MINOR\)//; | |
10 | $x } | |
11 | -} | |
12 | PLATFORM={- $config{target} -} | |
13 | OPTIONS={- $config{options} -} | |
14 | CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -}) | |
15 | SRCDIR={- $config{sourcedir} -} | |
16 | BLDDIR={- $config{builddir} -} | |
17 | ||
18 | VERSION={- $config{version} -} | |
19 | MAJOR={- $config{major} -} | |
20 | MINOR={- $config{minor} -} | |
21 | SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -} | |
22 | SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -} | |
23 | SHLIB_MAJOR={- $config{shlib_major} -} | |
24 | SHLIB_MINOR={- $config{shlib_minor} -} | |
25 | SHLIB_TARGET={- $target{shared_target} -} | |
26 | ||
27 | EXE_EXT={- $target{exe_extension} || "" -} | |
28 | LIB_EXT={- $target{lib_extension} || ".a" -} | |
29 | SHLIB_EXT={- shlib_ext() -} | |
30 | SHLIB_EXT_SIMPLE={- shlib_ext_simple() -} | |
31 | OBJ_EXT={- $target{obj_extension} || ".o" -} | |
32 | DEP_EXT={- $target{dep_extension} || ".d" -} | |
33 | ||
34 | LIBS={- join(" ", map { $_."\$(LIB_EXT)" } @{$unified_info{libraries}}) -} | |
35 | SHLIBS={- join(" ", map { $_."\$(SHLIB_EXT)" } map { $unified_info{sharednames}->{$_} || () } @{$unified_info{libraries}}) -} | |
36 | ENGINES={- join(" ", map { $_."\$(SHLIB_EXT_SIMPLE)" } @{$unified_info{engines}}) -} | |
37 | PROGRAMS={- join(" ", map { $_."\$(EXE_EXT)" } grep { !m|^test/| } @{$unified_info{programs}}) -} | |
38 | TESTPROGS={- join(" ", map { $_."\$(EXE_EXT)" } grep { m|^test/| } @{$unified_info{programs}}) -} | |
39 | SCRIPTS={- join(" ", @{$unified_info{scripts}}) -} | |
40 | BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash | |
41 | MISC_SCRIPTS=$(SRCDIR)/tools/c_hash $(SRCDIR)/tools/c_info \ | |
42 | $(SRCDIR)/tools/c_issuer $(SRCDIR)/tools/c_name \ | |
43 | $(BLDDIR)/apps/CA.pl $(SRCDIR)/apps/tsget | |
44 | ||
3c65577f RL |
45 | # DESTDIR is for package builders so that they can configure for, say, |
46 | # /usr/ and yet have everything installed to /tmp/somedir/usr/. | |
567a9e6f | 47 | # Normally it is left empty. |
3c65577f | 48 | DESTDIR= |
567a9e6f RL |
49 | |
50 | # Do not edit these manually. Use Configure with --prefix or --openssldir | |
51 | # to change this! Short explanation in the top comment in Configure | |
52 | INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet | |
53 | # | |
54 | our $prefix = $config{prefix} || "/usr/local"; | |
55 | $prefix -} | |
56 | OPENSSLDIR={- # | |
57 | # The logic here is that if no --openssldir was given, | |
58 | # OPENSSLDIR will get the value from $prefix plus "/ssl". | |
59 | # If --openssldir was given and the value is an absolute | |
60 | # path, OPENSSLDIR will get its value without change. | |
61 | # If the value from --openssldir is a relative path, | |
62 | # OPENSSLDIR will get $prefix with the --openssldir | |
63 | # value appended as a subdirectory. | |
64 | # | |
65 | use File::Spec::Functions; | |
66 | our $openssldir = | |
67 | $config{openssldir} ? | |
68 | (file_name_is_absolute($config{openssldir}) ? | |
69 | $config{openssldir} | |
70 | : catdir($prefix, $config{openssldir})) | |
71 | : catdir($prefix, "ssl"); | |
72 | $openssldir -} | |
73 | LIBDIR={- # | |
74 | # if $prefix/lib$target{multilib} is not an existing | |
75 | # directory, then assume that it's not searched by linker | |
76 | # automatically, in which case adding $target{multilib} suffix | |
77 | # causes more grief than we're ready to tolerate, so don't... | |
78 | our $multilib = | |
79 | -d "$prefix/lib$target{multilib}" ? $target{multilib} : ""; | |
80 | our $libdir = $config{libdir} || "lib$multilib"; | |
81 | $libdir -} | |
82 | ENGINESDIR={- use File::Spec::Functions; | |
83 | catdir($prefix,$libdir,"engines") -} | |
84 | ||
85 | MANDIR=$(OPENSSLDIR)/man | |
86 | HTMLDIR=$(OPENSSLDIR)/html | |
87 | ||
88 | MANSUFFIX=ssl | |
89 | HTMLSUFFIX=html | |
90 | ||
91 | ||
92 | ||
93 | CROSS_COMPILE= {- $config{cross_compile_prefix} -} | |
94 | CC= $(CROSS_COMPILE){- $target{cc} -} | |
076e596f RL |
95 | CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $config{cflags} -} |
96 | CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -} | |
567a9e6f RL |
97 | DEPFLAGS= {- join(" ",map { "-D".$_} @{$config{depdefines}}) -} |
98 | LDFLAGS= {- $config{lflags} -} | |
99 | PLIB_LDFLAGS= {- $config{plib_lflags} -} | |
100 | EX_LIBS= {- $config{ex_libs} -} | |
101 | SHARED_LDFLAGS={- $target{shared_ldflag} | |
102 | # Unlike other OSes (like Solaris, Linux, Tru64, | |
103 | # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD | |
104 | # and FreeBSD) "demand" RPATH set on .so objects. | |
105 | # Apparently application RPATH is not global and | |
106 | # does not apply to .so linked with other .so. | |
107 | # Problem manifests itself when libssl.so fails to | |
108 | # load libcrypto.so. One can argue that we should | |
109 | # engrave this into Makefile.shared rules or into | |
110 | # BSD-* config lines above. Meanwhile let's try to | |
111 | # be cautious and pass -rpath to linker only when | |
112 | # $prefix is not /usr. | |
113 | . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$| | |
114 | ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -} | |
af093bf4 | 115 | SHARED_RCFLAGS={- $target{shared_rcflag} -} |
567a9e6f RL |
116 | |
117 | PERL={- $config{perl} -} | |
118 | ||
119 | ARFLAGS= {- $target{arflags} -} | |
120 | AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r | |
121 | RANLIB= {- $target{ranlib} -} | |
122 | NM= $(CROSS_COMPILE){- $target{nm} || "nm" -} | |
123 | RM= rm -f | |
124 | TAR= {- $target{tar} || "tar" -} | |
125 | TARFLAGS= {- $target{tarflags} -} | |
126 | ||
127 | BASENAME= openssl | |
128 | NAME= $(BASENAME)-$(VERSION) | |
129 | TARFILE= ../$(NAME).tar | |
130 | ||
131 | # We let the C compiler driver to take care of .s files. This is done in | |
132 | # order to be excused from maintaining a separate set of architecture | |
133 | # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC | |
134 | # gcc, then the driver will automatically translate it to -xarch=v8plus | |
135 | # and pass it down to assembler. | |
136 | AS=$(CC) -c | |
137 | ASFLAG=$(CFLAGS) | |
138 | PERLASM_SCHEME= {- $target{perlasm_scheme} -} | |
139 | ||
140 | # For x86 assembler: Set PROCESSOR to 386 if you want to support | |
141 | # the 80386. | |
142 | PROCESSOR= {- $config{processor} -} | |
143 | ||
144 | # The main targets ################################################### | |
145 | ||
03ed5e99 | 146 | all: Makefile libcrypto.pc libssl.pc openssl.pc $(ENGINES) $(PROGRAMS) $(SCRIPTS) $(TESTPROGS) link-utils |
567a9e6f RL |
147 | |
148 | test tests: $(TESTPROGS) rehash | |
149 | ( cd test; \ | |
150 | SRCTOP=../$(SRCDIR) \ | |
151 | BLDTOP=../$(BLDDIR) \ | |
152 | $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) ) | |
153 | ||
154 | list-tests: | |
155 | @TOP=$(SRCDIR) PERL=$(PERL) $(PERL) $(SRCDIR)/test/run_tests.pl list | |
156 | ||
157 | libclean: | |
158 | -rm -f `find $(BLDDIR) -name '*$(LIB_EXT)' -o -name '*$(SHLIB_EXT)'` | |
159 | ||
160 | install: install_sw install_docs | |
161 | ||
162 | uninstall: uninstall_docs uninstall_sw | |
163 | ||
164 | clean: libclean | |
165 | rm -f $(PROGRAMS) $(TESTPROGS) | |
166 | rm -f `find $(BLDDIR) -name '*$(DEP_EXT)'` | |
167 | rm -f `find $(BLDDIR) -name '*$(OBJ_EXT)'` | |
168 | rm -f $(BLDDIR)/core $(BLDDIR)/rehash.time | |
169 | rm -f $(BLDDIR)/tags $(BLDDIR)/TAGS | |
170 | rm -f $(BLDDIR)/openssl.pc $(BLDDIR)/libcrypto.pc $(BLDDIR)/libssl.pc | |
171 | -rm -f `find $(BLDDIR) -type l` | |
172 | rm -f $(TARFILE) | |
173 | ||
174 | DCLEAN_CMD=sed -e '/^DO NOT DELETE.*/,$$d' | |
175 | dclean: | |
176 | $(DCLEAN_CMD) < Makefile >Makefile.new | |
177 | mv -f Makefile.new Makefile | |
178 | ||
179 | DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; } | |
180 | grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } | |
181 | keys %{$unified_info{sources}}); -} | |
182 | depend: $(DEPS) | |
183 | ( $(DCLEAN_CMD) < Makefile; \ | |
184 | echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \ | |
185 | echo; \ | |
186 | cat `find . -name '*$(DEP_EXT)'` ) > Makefile.new | |
187 | mv -f Makefile.new Makefile | |
188 | ||
189 | # Install helper targets ############################################# | |
190 | ||
191 | install_sw: all install_dev install_engines install_runtime | |
192 | ||
193 | uninstall_sw: uninstall_dev uninstall_engines uninstall_runtime | |
194 | ||
195 | install_docs: install_man_docs install_html_docs | |
196 | ||
197 | uninstall_docs: uninstall_man_docs uninstall_html_docs | |
198 | ||
199 | install_dev: | |
200 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
201 | @echo "*** Installing development files" | |
3c65577f | 202 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl |
567a9e6f RL |
203 | @set -e; for i in $(SRCDIR)/include/openssl/*.h \ |
204 | $(BLDDIR)/include/openssl/*.h; do \ | |
205 | fn=`basename $$i`; \ | |
3c65577f RL |
206 | echo "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ |
207 | cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ | |
208 | chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ | |
567a9e6f | 209 | done |
3c65577f | 210 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR) |
567a9e6f RL |
211 | @set -e; for l in $(LIBS); do \ |
212 | fn=`basename $$l`; \ | |
3c65577f RL |
213 | echo "install $$l -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \ |
214 | cp $$l $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \ | |
215 | $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \ | |
216 | chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \ | |
217 | mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \ | |
218 | $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \ | |
567a9e6f RL |
219 | done |
220 | @ : {- output_off() if $config{no_shared}; "" -} | |
221 | @set -e; for s in $(SHLIBS); do \ | |
222 | fn=`basename $$s`; \ | |
3c65577f RL |
223 | echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \ |
224 | cp $$s $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \ | |
225 | chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new; \ | |
226 | mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.new \ | |
227 | $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \ | |
567a9e6f | 228 | if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \ |
3c65577f | 229 | echo "link $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2 -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \ |
567a9e6f | 230 | fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \ |
3c65577f | 231 | ln -sf $$fn $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \ |
567a9e6f | 232 | fi; \ |
fcf80c46 | 233 | : {- output_off() unless windowsdll(); "" -}; \ |
3c65577f RL |
234 | echo "install $$s.a -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \ |
235 | cp $$s.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \ | |
236 | chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \ | |
237 | mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \ | |
238 | $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \ | |
dac494d2 | 239 | : {- output_on() unless windowsdll(); "" -}; \ |
567a9e6f | 240 | done |
dac494d2 | 241 | @ : {- output_on() if $config{no_shared}; "" -} |
3c65577f RL |
242 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig |
243 | @echo "install libcrypto.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc" | |
244 | @cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig | |
245 | @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc | |
246 | @echo "install libssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc" | |
247 | @cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig | |
248 | @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc | |
249 | @echo "install openssl.pc -> $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc" | |
250 | @cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig | |
251 | @chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc | |
567a9e6f RL |
252 | |
253 | uninstall_dev: | |
254 | @echo "*** Uninstalling development files" | |
255 | @set -e; for i in $(SRCDIR)/include/openssl/*.h \ | |
256 | $(BLDDIR)/include/openssl/*.h; do \ | |
257 | fn=`basename $$i`; \ | |
3c65577f RL |
258 | echo "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ |
259 | $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ | |
567a9e6f RL |
260 | done |
261 | @set -e; for l in $(LIBS); do \ | |
262 | fn=`basename $$l`; \ | |
3c65577f RL |
263 | echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \ |
264 | $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \ | |
567a9e6f RL |
265 | done |
266 | @set -e; for s in $(SHLIBS); do \ | |
267 | fn=`basename $$s`; \ | |
268 | if [ "$(SHLIB_EXT)" != "$(SHLIB_EXT_SIMPLE)" ]; then \ | |
269 | fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \ | |
3c65577f RL |
270 | echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2"; \ |
271 | $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \ | |
567a9e6f | 272 | fi; \ |
3c65577f RL |
273 | echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \ |
274 | $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn; \ | |
fcf80c46 | 275 | : {- output_off() unless windowsdll(); "" -}; \ |
3c65577f RL |
276 | echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \ |
277 | $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \ | |
dac494d2 | 278 | : {- output_on() unless windowsdll(); "" -}; \ |
567a9e6f | 279 | done |
3c65577f RL |
280 | @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc" |
281 | @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc | |
282 | @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc" | |
283 | @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc | |
284 | @echo "$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc" | |
285 | @$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc | |
567a9e6f RL |
286 | |
287 | install_engines: | |
288 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
3c65577f | 289 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/ |
567a9e6f RL |
290 | @echo "*** Installing engines" |
291 | @set -e; for e in $(ENGINES); do \ | |
292 | fn=`basename $$e`; \ | |
3c65577f RL |
293 | echo "install $$e -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
294 | cp $$e $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \ | |
295 | chmod 755 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new; \ | |
296 | mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn.new \ | |
297 | $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \ | |
567a9e6f RL |
298 | done |
299 | ||
300 | uninstall_engines: | |
301 | @echo "*** Uninstalling engines" | |
302 | @set -e; for e in $(ENGINES); do \ | |
303 | fn=`basename $$e`; \ | |
3c65577f RL |
304 | echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
305 | $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines/$$fn; \ | |
567a9e6f RL |
306 | done |
307 | ||
308 | install_runtime: | |
309 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
3c65577f RL |
310 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin |
311 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc | |
567a9e6f | 312 | @echo "*** Installing runtime files" |
fcf80c46 RL |
313 | : {- output_off() unless windowsdll(); "" -}; |
314 | @set -e; for s in $(SHLIBS); do \ | |
315 | fn=`basename $$i`; \ | |
3c65577f RL |
316 | echo "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
317 | cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
318 | chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
319 | mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ | |
320 | $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
fcf80c46 | 321 | done |
dac494d2 | 322 | : {- output_on() unless windowsdll(); "" -}; |
567a9e6f RL |
323 | @set -e; for x in $(PROGRAMS); do \ |
324 | fn=`basename $$x`; \ | |
3c65577f RL |
325 | echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
326 | cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
327 | chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
328 | mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ | |
329 | $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
567a9e6f RL |
330 | done |
331 | @set -e; for x in $(BIN_SCRIPTS); do \ | |
332 | fn=`basename $$x`; \ | |
3c65577f RL |
333 | echo "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
334 | cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
335 | chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
336 | mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ | |
337 | $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
567a9e6f RL |
338 | done |
339 | @set -e; for x in $(MISC_SCRIPTS); do \ | |
340 | fn=`basename $$x`; \ | |
3c65577f RL |
341 | echo "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ |
342 | cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \ | |
343 | chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \ | |
344 | mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \ | |
345 | $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \ | |
567a9e6f | 346 | done |
3c65577f RL |
347 | @echo "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf" |
348 | @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new | |
349 | @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new | |
350 | @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf | |
567a9e6f RL |
351 | |
352 | uninstall_runtime: | |
353 | @echo "*** Uninstalling runtime files" | |
354 | @set -e; for x in $(PROGRAMS); \ | |
355 | do \ | |
356 | fn=`basename $$x`; \ | |
3c65577f RL |
357 | echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
358 | $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
567a9e6f RL |
359 | done; |
360 | @set -e; for x in $(BIN_SCRIPTS); \ | |
361 | do \ | |
362 | fn=`basename $$x`; \ | |
3c65577f RL |
363 | echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
364 | $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
567a9e6f RL |
365 | done |
366 | @set -e; for x in $(MISC_SCRIPTS); \ | |
367 | do \ | |
368 | fn=`basename $$x`; \ | |
3c65577f RL |
369 | echo "$(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ |
370 | $(RM) $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \ | |
567a9e6f | 371 | done |
fcf80c46 RL |
372 | : {- output_off() unless windowsdll(); "" -}; |
373 | @set -e; for s in $(SHLIBS); do \ | |
374 | fn=`basename $$i`; \ | |
3c65577f RL |
375 | echo "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
376 | $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
fcf80c46 | 377 | done |
dac494d2 | 378 | : {- output_on() unless windowsdll(); "" -}; |
3c65577f | 379 | $(RM) $(DESTDIR)$(OPENSSLDIR)/openssl.cnf |
567a9e6f RL |
380 | |
381 | # A method to extract all names from a .pod file | |
382 | # The first sed extracts everything between "=head1 NAME" and the next =head1 | |
383 | # The second sed joins all the lines into one | |
384 | # The third sed removes the description and turns all commas into spaces | |
385 | # Voilà , you have a space separated list of names! | |
386 | EXTRACT_NAMES=sed -e '1,/^=head1 *NAME *$$/d;/^=head1/,$$d' | \ | |
387 | sed -e ':a;{N;s/\n/ /;ba}' | \ | |
388 | sed -e 's/ - .*$$//;s/,/ /g' | |
389 | PROCESS_PODS=\ | |
390 | set -e; \ | |
391 | here=`cd $(SRCDIR); pwd`; \ | |
392 | point=$$here/util/point.sh; \ | |
393 | for ds in apps:1 crypto:3 ssl:3; do \ | |
394 | defdir=`echo $$ds | cut -f1 -d:`; \ | |
395 | defsec=`echo $$ds | cut -f2 -d:`; \ | |
396 | for p in $(SRCDIR)/doc/$$defdir/*.pod; do \ | |
397 | SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \ | |
398 | [ -z "$$SEC" ] && SEC=$$defsec; \ | |
399 | fn=`basename $$p .pod`; \ | |
400 | NAME=`echo $$fn | tr [a-z] [A-Z]`; \ | |
401 | suf=`eval "echo $$OUTSUFFIX"`; \ | |
402 | top=`eval "echo $$OUTTOP"`; \ | |
403 | $(PERL) $(SRCDIR)/util/mkdir-p.pl $$top/man$$SEC; \ | |
404 | echo "install $$p -> $$top/man$$SEC/$$fn$$suf"; \ | |
405 | cat $$p | eval "$$GENERATE" \ | |
406 | > $$top/man$$SEC/$$fn$$suf; \ | |
407 | names=`cat $$p | $(EXTRACT_NAMES)`; \ | |
408 | ( cd $$top/man$$SEC; \ | |
409 | for n in $$names; do \ | |
3af104f3 RL |
410 | comp_n="$$n"; \ |
411 | comp_fn="$$fn"; \ | |
412 | case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \ | |
413 | comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \ | |
414 | comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \ | |
415 | ;; \ | |
416 | esac; \ | |
417 | if [ "$$comp_n" != "$$comp_fn" ]; then \ | |
567a9e6f RL |
418 | echo "link $$top/man$$SEC/$$n$$suf -> $$top/man$$SEC/$$fn$$suf"; \ |
419 | PLATFORM=$(PLATFORM) $$point $$fn$$suf $$n$$suf; \ | |
420 | fi; \ | |
421 | done ); \ | |
422 | done; \ | |
423 | done | |
424 | UNINSTALL_DOCS=\ | |
425 | set -e; \ | |
426 | here=`cd $(SRCDIR); pwd`; \ | |
427 | for ds in apps:1 crypto:3 ssl:3; do \ | |
428 | defdir=`echo $$ds | cut -f1 -d:`; \ | |
429 | defsec=`echo $$ds | cut -f2 -d:`; \ | |
430 | for p in $(SRCDIR)/doc/$$defdir/*.pod; do \ | |
431 | SEC=`sed -ne 's/^=for *comment *openssl_manual_section: *\([0-9]\) *$$/\1/p' $$p`; \ | |
432 | [ -z "$$SEC" ] && SEC=$$defsec; \ | |
433 | fn=`basename $$p .pod`; \ | |
434 | suf=`eval "echo $$OUTSUFFIX"`; \ | |
435 | top=`eval "echo $$OUTTOP"`; \ | |
436 | echo "$(RM) $$top/man$$SEC/$$fn$$suf"; \ | |
437 | $(RM) $$top/man$$SEC/$$fn$$suf; \ | |
438 | names=`cat $$p | $(EXTRACT_NAMES)`; \ | |
439 | for n in $$names; do \ | |
3af104f3 RL |
440 | comp_n="$$n"; \ |
441 | comp_fn="$$fn"; \ | |
442 | case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \ | |
443 | comp_n=`echo "$$n" | tr [A-Z] [a-z]`; \ | |
444 | comp_fn=`echo "$$fn" | tr [A-Z] [a-z]`; \ | |
445 | ;; \ | |
446 | esac; \ | |
447 | if [ "$$comp_n" != "$$comp_fn" ]; then \ | |
567a9e6f RL |
448 | echo "$(RM) $$top/man$$SEC/$$n$$suf"; \ |
449 | $(RM) $$top/man$$SEC/$$n$$suf; \ | |
450 | fi; \ | |
451 | done; \ | |
452 | done; \ | |
453 | done | |
454 | ||
455 | install_man_docs: | |
456 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
457 | @echo "*** Installing manpages" | |
458 | @\ | |
459 | OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \ | |
3c65577f | 460 | OUTTOP="$(DESTDIR)$(MANDIR)"; \ |
567a9e6f RL |
461 | GENERATE='pod2man --name=$$NAME --section=$$SEC --center=OpenSSL --release=$(VERSION)'; \ |
462 | $(PROCESS_PODS) | |
463 | ||
464 | uninstall_man_docs: | |
465 | @echo "*** Uninstalling manpages" | |
466 | @\ | |
467 | OUTSUFFIX='.$${SEC}$(MANSUFFIX)'; \ | |
3c65577f | 468 | OUTTOP="$(DESTDIR)$(MANDIR)"; \ |
567a9e6f RL |
469 | $(UNINSTALL_DOCS) |
470 | ||
471 | install_html_docs: | |
472 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
473 | @echo "*** Installing HTML manpages" | |
474 | @\ | |
475 | OUTSUFFIX='.$(HTMLSUFFIX)'; \ | |
3c65577f | 476 | OUTTOP="$(DESTDIR)$(HTMLDIR)"; \ |
567a9e6f RL |
477 | GENERATE="pod2html --podroot=$(SRCDIR)/doc --htmldir=.. \ |
478 | --podpath=apps:crypto:ssl \ | |
479 | | sed -e 's|href=\"http://man.he.net/man|href=\"../man|g'"; \ | |
480 | $(PROCESS_PODS) | |
481 | ||
482 | uninstall_html_docs: | |
483 | @echo "*** Uninstalling manpages" | |
484 | @\ | |
485 | OUTSUFFIX='.$(HTMLSUFFIX)'; \ | |
3c65577f | 486 | OUTTOP="$(DESTDIR)$(HTMLDIR)"; \ |
567a9e6f RL |
487 | $(UNINSTALL_DOCS) |
488 | ||
489 | ||
490 | # Developer targets (note: these are only available on Unix) ######### | |
491 | ||
6bb2106e RL |
492 | update: generate errors ordinals |
493 | ||
494 | generate: generate_apps generate_crypto_bn generate_crypto_objects | |
567a9e6f RL |
495 | |
496 | # Test coverage is a good idea for the future | |
497 | #coverage: $(PROGRAMS) $(TESTPROGRAMS) | |
498 | # ... | |
499 | ||
500 | # Currently disabled, util/selftest.pl needs a rewrite | |
501 | #report: | |
502 | # SRCDIR=$(SRCDIR) @$(PERL) util/selftest.pl | |
503 | ||
504 | lint: | |
505 | lint -DLINT $(INCLUDES) $(SRCS) | |
506 | ||
fb3e2a88 | 507 | generate_apps: $(SRCDIR)/apps/openssl-vms.cnf $(SRCDIR)/apps/progs.h |
6bb2106e RL |
508 | |
509 | generate_crypto_bn: $(SRCDIR)/crypto/bn/bn_prime.h | |
510 | ||
511 | generate_crypto_objects: $(SRCDIR)/crypto/objects/obj_dat.h \ | |
512 | $(SRCDIR)/include/openssl/obj_mac.h \ | |
513 | $(SRCDIR)/crypto/objects/obj_xref.h | |
514 | ||
567a9e6f RL |
515 | errors: |
516 | ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c ) | |
517 | ( cd $(SRCDIR); $(PERL) util/mkerr.pl -recurse -write ) | |
518 | ( cd $(SRCDIR)/engines; \ | |
519 | for e in *.ec; do \ | |
520 | $(PERL) ../util/mkerr.pl -conf $$e \ | |
521 | -nostatic -staticloader -write *.c; \ | |
522 | done ) | |
523 | ( cd $(SRCDIR)/crypto/ct; \ | |
524 | $(PERL) ../../util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c ) | |
525 | ||
526 | ordinals: | |
527 | ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update ) | |
528 | ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update ) | |
529 | ||
530 | test_ordinals: | |
531 | ( cd test; \ | |
532 | SRCTOP=../$(SRCDIR) \ | |
533 | BLDTOP=../$(BLDDIR) \ | |
534 | $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals ) | |
535 | ||
536 | tags TAGS: FORCE | |
537 | rm -f TAGS tags | |
538 | -ctags -R . | |
539 | -etags `find . -name '*.[ch]' -o -name '*.pm'` | |
540 | ||
541 | # Release targets (note: only available on Unix) ##################### | |
542 | ||
543 | tar: | |
544 | TMPDIR=/var/tmp/openssl-copy.$$$$; \ | |
545 | DISTDIR=openssl-$(VERSION); \ | |
546 | mkdir -p $$TMPDIR/$$DISTDIR; \ | |
547 | (cd $(SRCDIR); \ | |
548 | git ls-tree -r --name-only --full-tree HEAD \ | |
549 | | while read F; do \ | |
550 | mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \ | |
551 | cp $$F $$TMPDIR/$$DISTDIR/$$F; \ | |
552 | done); \ | |
553 | (cd $$TMPDIR; \ | |
554 | [ -n "$(PREPARE_CMD)" ] && $(PREPARE_CMD); \ | |
555 | find $$TMPDIR/$$DISTDIR -type d -print | xargs chmod 755; \ | |
556 | find $$TMPDIR/$$DISTDIR -type f -print | xargs chmod a+r; \ | |
557 | find $$TMPDIR/$$DISTDIR -type f -perm -0100 -print | xargs chmod a+x; \ | |
558 | $(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf - $$DISTDIR) \ | |
559 | | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \ | |
560 | rm -rf $$TMPDIR | |
561 | cd $(SRCDIR); ls -l $(TARFILE).gz | |
562 | ||
563 | dist: | |
564 | @$(MAKE) PREPARE_CMD='./Configure dist' tar | |
565 | ||
566 | # Helper targets ##################################################### | |
567 | ||
568 | rehash: link-utils copy-certs | |
569 | @if [ -z "$(CROSS_COMPILE)" ]; then \ | |
570 | (OPENSSL="$(BLDDIR)/util/shlib_wrap.sh apps/openssl"; \ | |
571 | [ -x "$(BLDDIR)/openssl.exe" ] && OPENSSL="$(BLDDIR)/openssl.exe" || :; \ | |
572 | OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \ | |
573 | export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \ | |
574 | $$OPENSSL rehash certs/demo \ | |
575 | || $(PERL) tools/c_rehash certs/demo) && \ | |
576 | touch rehash.time; \ | |
577 | else :; fi | |
578 | ||
579 | link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh | |
580 | ||
581 | $(BLDDIR)/util/opensslwrap.sh: Makefile | |
582 | @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \ | |
583 | mkdir -p "$(BLDDIR)/util"; \ | |
584 | ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \ | |
585 | fi | |
586 | $(BLDDIR)/util/shlib_wrap.sh: Makefile | |
587 | @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \ | |
588 | mkdir -p "$(BLDDIR)/util"; \ | |
589 | ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \ | |
590 | fi | |
591 | ||
592 | copy-certs: FORCE | |
593 | @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \ | |
594 | cp -R "$(SRCDIR)/certs" "$(BLDDIR)/"; \ | |
595 | fi | |
596 | ||
6bb2106e RL |
597 | $(SRCDIR)/apps/openssl-vms.cnf: $(SRCDIR)/apps/openssl.cnf |
598 | $(PERL) $(SRCDIR)/VMS/VMSify-conf.pl \ | |
599 | < $(SRCDIR)/apps/openssl.cnf > $(SRCDIR)/apps/openssl-vms.cnf | |
600 | ||
fb3e2a88 RL |
601 | {- # because the program apps/openssl has object files as sources, and |
602 | # they then have the corresponding C files as source, we need to chain | |
603 | # the lookups in %unified_info | |
604 | my $apps_openssl = catfile("apps","openssl"); | |
605 | our @openssl_source = map { @{$unified_info{sources}->{$_}} } | |
606 | @{$unified_info{sources}->{$apps_openssl}}; | |
607 | ""; -} | |
608 | $(SRCDIR)/apps/progs.h: | |
609 | $(RM) $@ | |
610 | $(PERL) $(SRCDIR)/apps/progs.pl {- join(" ", @openssl_source) -} > $@ | |
611 | ||
6bb2106e RL |
612 | $(SRCDIR)/crypto/bn/bn_prime.h: $(SRCDIR)/crypto/bn/bn_prime.pl |
613 | $(PERL) $(SRCDIR)/crypto/bn/bn_prime.pl > $(SRCDIR)/crypto/bn/bn_prime.h | |
614 | ||
615 | $(SRCDIR)/crypto/objects/obj_dat.h: $(SRCDIR)/crypto/objects/obj_dat.pl \ | |
616 | $(SRCDIR)/include/openssl/obj_mac.h | |
617 | $(PERL) $(SRCDIR)/crypto/objects/obj_dat.pl \ | |
618 | $(SRCDIR)/include/openssl/obj_mac.h \ | |
619 | $(SRCDIR)/crypto/objects/obj_dat.h | |
620 | ||
621 | # objects.pl both reads and writes obj_mac.num | |
622 | $(SRCDIR)/include/openssl/obj_mac.h: $(SRCDIR)/crypto/objects/objects.pl \ | |
623 | $(SRCDIR)/crypto/objects/objects.txt \ | |
624 | $(SRCDIR)/crypto/objects/obj_mac.num | |
625 | $(PERL) $(SRCDIR)/crypto/objects/objects.pl \ | |
626 | $(SRCDIR)/crypto/objects/objects.txt \ | |
627 | $(SRCDIR)/crypto/objects/obj_mac.num \ | |
628 | $(SRCDIR)/include/openssl/obj_mac.h | |
629 | @sleep 1; touch $(SRCDIR)/include/openssl/obj_mac.h; sleep 1 | |
630 | ||
631 | $(SRCDIR)/crypto/objects/obj_xref.h: $(SRCDIR)/crypto/objects/objxref.pl \ | |
632 | $(SRCDIR)/crypto/objects/obj_xref.txt \ | |
633 | $(SRCDIR)/crypto/objects/obj_mac.num | |
634 | $(PERL) $(SRCDIR)/crypto/objects/objxref.pl \ | |
635 | $(SRCDIR)/crypto/objects/obj_mac.num \ | |
636 | $(SRCDIR)/crypto/objects/obj_xref.txt \ | |
637 | > $(SRCDIR)/crypto/objects/obj_xref.h | |
638 | @sleep 1; touch $(SRCDIR)/crypto/objects/obj_xref.h; sleep 1 | |
639 | ||
567a9e6f RL |
640 | FORCE : |
641 | ||
642 | # Building targets ################################################### | |
643 | ||
644 | libcrypto.pc libssl.pc openssl.pc: Makefile $(LIBS) | |
645 | libcrypto.pc: | |
646 | @ ( echo 'prefix=$(INSTALLTOP)'; \ | |
647 | echo 'exec_prefix=$${prefix}'; \ | |
648 | echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \ | |
649 | echo 'includedir=$${prefix}/include'; \ | |
650 | echo ''; \ | |
651 | echo 'Name: OpenSSL-libcrypto'; \ | |
652 | echo 'Description: OpenSSL cryptography library'; \ | |
653 | echo 'Version: '$(VERSION); \ | |
654 | echo 'Libs: -L$${libdir} -lcrypto'; \ | |
655 | echo 'Libs.private: $(EX_LIBS)'; \ | |
656 | echo 'Cflags: -I$${includedir}' ) > libcrypto.pc | |
657 | ||
658 | libssl.pc: | |
659 | @ ( echo 'prefix=$(INSTALLTOP)'; \ | |
660 | echo 'exec_prefix=$${prefix}'; \ | |
661 | echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \ | |
662 | echo 'includedir=$${prefix}/include'; \ | |
663 | echo ''; \ | |
664 | echo 'Name: OpenSSL-libssl'; \ | |
665 | echo 'Description: Secure Sockets Layer and cryptography libraries'; \ | |
666 | echo 'Version: '$(VERSION); \ | |
667 | echo 'Requires.private: libcrypto'; \ | |
668 | echo 'Libs: -L$${libdir} -lssl'; \ | |
669 | echo 'Libs.private: $(EX_LIBS)'; \ | |
670 | echo 'Cflags: -I$${includedir}' ) > libssl.pc | |
671 | ||
672 | openssl.pc: | |
673 | @ ( echo 'prefix=$(INSTALLTOP)'; \ | |
674 | echo 'exec_prefix=$${prefix}'; \ | |
675 | echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \ | |
676 | echo 'includedir=$${prefix}/include'; \ | |
677 | echo ''; \ | |
678 | echo 'Name: OpenSSL'; \ | |
679 | echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \ | |
680 | echo 'Version: '$(VERSION); \ | |
681 | echo 'Requires: libssl libcrypto' ) > openssl.pc | |
682 | ||
683 | # Note on the use of $(MFLAGS): this was an older variant of MAKEFLAGS which | |
684 | # wasn't passed down automatically. It's quite safe to use it like we do | |
685 | # below; if it doesn't exist, the result will be empty and 'make' will pick | |
686 | # up $(MAKEFLAGS) which is passed down as an environment variable. | |
687 | Makefile: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/config | |
688 | @echo "Makefile is older than {- $config{build_file_template} -}, $(SRCDIR)/Configure or $(SRCDIR)/config." | |
689 | @echo "Reconfiguring..." | |
690 | $(SRCDIR)/Configure reconf | |
691 | @echo "**************************************************" | |
692 | @echo "*** ***" | |
693 | @echo "*** Please run the same make command again ***" | |
694 | @echo "*** ***" | |
695 | @echo "**************************************************" | |
696 | @false | |
697 | ||
698 | {- | |
699 | use File::Basename; | |
700 | use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; | |
cedbb146 RL |
701 | |
702 | # Helper function to figure out dependencies on libraries | |
703 | # It takes a list of library names and outputs a list of dependencies | |
704 | sub compute_lib_depends { | |
705 | if ($config{no_shared}) { | |
706 | return map { $_."\$(LIB_EXT)" } @_; | |
707 | } | |
708 | ||
709 | # Depending on shared libraries: | |
710 | # On Windows POSIX layers, we depend on {libname}.dll.a | |
711 | # On Unix platforms, we depend on {shlibname}.so | |
712 | return map { if (windowsdll()) { | |
713 | "$_\$(SHLIB_EXT_SIMPLE).a" | |
714 | } else { | |
715 | my $libname = | |
716 | $unified_info{sharednames}->{$_} || $_; | |
717 | "$libname\$(SHLIB_EXT_SIMPLE)" | |
718 | } } @_; | |
719 | } | |
720 | ||
567a9e6f RL |
721 | sub src2dep { |
722 | my %args = @_; | |
723 | my $dep = $args{obj}.'$(DEP_EXT)'; | |
724 | my $obj = $args{obj}.'$(OBJ_EXT)'; | |
725 | my $srcs = join(" ", @{$args{srcs}}); | |
50e83cdd | 726 | my $deps = join(" ", @{$args{srcs}}, @{$args{deps}}); |
567a9e6f RL |
727 | my $incs = join(" ", map { " -I".$_ } @{$args{incs}}); |
728 | my $makedepprog = $config{makedepprog}; | |
729 | if ($makedepprog eq "makedepend") { | |
730 | return <<"EOF"; | |
50e83cdd | 731 | $dep : $deps |
567a9e6f RL |
732 | rm -f \$\@.tmp; touch \$\@.tmp |
733 | \$(MAKEDEPEND) -f\$\@.tmp -o"|$obj"\ | |
734 | -- -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs \ | |
735 | -- $srcs | |
736 | sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$/d' -e '/^\\(#.*\\| *\\)\$/d' \$\@.tmp > \$\@ | |
737 | rm \$\@.tmp | |
738 | EOF | |
739 | } | |
740 | return <<"EOF"; | |
50e83cdd | 741 | $dep : $deps Makefile |
567a9e6f RL |
742 | \$(CC) -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs |
743 | EOF | |
744 | } | |
745 | sub src2obj { | |
746 | my %args = @_; | |
747 | my $obj = $args{obj}.'$(OBJ_EXT)'; | |
748 | my $srcs = join(" ", @{$args{srcs}}); | |
749 | my $deps = join(" ", @{$args{srcs}}, @{$args{deps}}); | |
750 | my $incs = join(" ", map { " -I".$_ } @{$args{incs}}); | |
751 | return <<"EOF"; | |
752 | $obj : $deps | |
753 | \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs | |
754 | EOF | |
755 | } | |
756 | # On Unix, we build shlibs from static libs, so we're ignoring the | |
757 | # object file array. We *know* this routine is only called when we've | |
758 | # configure 'shared'. | |
759 | sub libobj2shlib { | |
760 | my %args = @_; | |
761 | my $lib = $args{lib}; | |
762 | my $shlib = $args{shlib}; | |
763 | my $libd = dirname($lib); | |
764 | my $libn = basename($lib); | |
765 | (my $libname = $libn) =~ s/^lib//; | |
cedbb146 RL |
766 | my $linklibs = join("", map { my $d = dirname($_); |
767 | my $f = basename($_); | |
768 | (my $l = $f) =~ s/^lib//; | |
769 | " -L$d -l$l" } @{$args{deps}}); | |
770 | my $deps = join(" ",compute_lib_depends(@{$args{deps}})); | |
567a9e6f RL |
771 | my $shlib_target = $target{shared_target}; |
772 | my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : ""; | |
cedbb146 RL |
773 | my $shlibtarget = windowsdll() ? |
774 | "$lib\$(SHLIB_EXT_SIMPLE).a" : "$shlib\$(SHLIB_EXT_SIMPLE)"; | |
567a9e6f | 775 | return <<"EOF" |
cedbb146 RL |
776 | # With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact |
777 | # that two files get produced, {shlibname}.dll and {libname}.dll.a. | |
778 | # With all other Unix platforms, we often build a shared library with the | |
779 | # SO version built into the file name and a symlink without the SO version | |
780 | # It's not necessary to have both as targets. The choice falls on the | |
781 | # simplest, {libname}\$(SHLIB_EXT_SIMPLE).a for Windows POSIX layers and | |
782 | # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms. | |
783 | $shlibtarget : $lib\$(LIB_EXT) $deps $ordinalsfile | |
567a9e6f | 784 | \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\ |
cedbb146 | 785 | PLATFORM=\$(PLATFORM) \\ |
567a9e6f | 786 | PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\ |
cedbb146 RL |
787 | INSTALLTOP="\$(INSTALLTOP)" LIBDIR="\$(LIBDIR)" \\ |
788 | LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\ | |
789 | LIBNAME=$libname LIBVERSION=\$(SHLIB_MAJOR).\$(SHLIB_MINOR) \\ | |
790 | LIBCOMPATVERSIONS=";\$(SHLIB_VERSION_HISTORY)" \\ | |
791 | CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\ | |
792 | CROSS_COMPILE="\$(CROSS_COMPILE)" \\ | |
793 | SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\ | |
af093bf4 | 794 | SHARED_RCFLAGS="\$(SHARED_RCFLAGS)" \\ |
cedbb146 | 795 | link_a.$shlib_target |
fcf80c46 RL |
796 | EOF |
797 | . (windowsdll() ? <<"EOF" : ""); | |
798 | rm -f apps/$shlib\$(SHLIB_EXT) | |
799 | rm -f test/$shlib\$(SHLIB_EXT) | |
800 | cp -p $shlib\$(SHLIB_EXT) apps/ | |
801 | cp -p $shlib\$(SHLIB_EXT) test/ | |
567a9e6f RL |
802 | EOF |
803 | } | |
804 | sub obj2dynlib { | |
805 | my %args = @_; | |
806 | my $lib = $args{lib}; | |
807 | my $libd = dirname($lib); | |
808 | my $libn = basename($lib); | |
809 | (my $libname = $libn) =~ s/^lib//; | |
810 | my $shlibdeps = join("", map { my $d = dirname($_); | |
811 | my $f = basename($_); | |
812 | (my $l = $f) =~ s/^lib//; | |
813 | " -L$d -l$l" } @{$args{deps}}); | |
cedbb146 | 814 | my $deps = join(" ",compute_lib_depends(@{$args{deps}})); |
567a9e6f RL |
815 | my $shlib_target = $target{shared_target}; |
816 | my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}}); | |
817 | return <<"EOF"; | |
818 | $lib\$(SHLIB_EXT_SIMPLE): $objs $deps | |
819 | \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\ | |
cedbb146 RL |
820 | PLATFORM=\$(PLATFORM) \\ |
821 | PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\ | |
822 | LIBDEPS="\$(PLIB_LDFLAGS) $shlibdeps \$(EX_LIBS)" \\ | |
823 | LIBNAME=$libname LDFLAGS="\$(LDFLAGS)" \\ | |
824 | CC="\$(CC)" CFLAGS="\$(CFLAGS)" \\ | |
825 | SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" \\ | |
567a9e6f RL |
826 | SHLIB_EXT=\$(SHLIB_EXT_SIMPLE) \\ |
827 | LIBEXTRAS="$objs" \\ | |
cedbb146 | 828 | link_o.$shlib_target |
567a9e6f RL |
829 | EOF |
830 | } | |
831 | sub obj2lib { | |
832 | my %args = @_; | |
833 | my $lib = $args{lib}; | |
834 | my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}}); | |
835 | return <<"EOF"; | |
836 | $lib\$(LIB_EXT) : $objs | |
837 | \$(AR) \$\@ $objs | |
838 | \$(RANLIB) \$\@ || echo Never mind. | |
839 | EOF | |
840 | } | |
841 | sub obj2bin { | |
842 | my %args = @_; | |
843 | my $bin = $args{bin}; | |
844 | my $bind = dirname($bin); | |
845 | my $binn = basename($bin); | |
846 | my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}}); | |
cedbb146 RL |
847 | my $deps = join(" ",compute_lib_depends(@{$args{deps}})); |
848 | my $linklibs = join("", map { my $d = dirname($_); | |
849 | my $f = basename($_); | |
850 | $d = "." if $d eq $f; | |
851 | (my $l = $f) =~ s/^lib//; | |
852 | " -L$d -l$l" } @{$args{deps}}); | |
567a9e6f RL |
853 | my $shlib_target = $config{no_shared} ? "" : $target{shared_target}; |
854 | return <<"EOF"; | |
cedbb146 | 855 | $bin\$(EXE_EXT) : $objs $deps |
567a9e6f RL |
856 | \$(RM) $bin\$(EXE_EXT) |
857 | \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\ | |
cedbb146 | 858 | PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\ |
567a9e6f | 859 | APPNAME=$bin OBJECTS="$objs" \\ |
af093bf4 | 860 | LIBDEPS="\$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)" \\ |
cedbb146 RL |
861 | CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\ |
862 | LIBRPATH="\$(INSTALLTOP)/\$(LIBDIR)" \\ | |
567a9e6f RL |
863 | link_app.$shlib_target |
864 | EOF | |
865 | } | |
866 | sub in2script { | |
867 | my %args = @_; | |
868 | my $script = $args{script}; | |
869 | my $sources = join(" ", @{$args{sources}}); | |
870 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, | |
871 | "util", "dofile.pl")), | |
872 | rel2abs($config{builddir})); | |
873 | return <<"EOF"; | |
874 | $script : $sources | |
875 | \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" $sources > "$script" | |
876 | chmod a+x $script | |
877 | EOF | |
878 | } | |
879 | "" # Important! This becomes part of the template result. | |
880 | -} |