1 | #!/bin/sh |
---|
2 | # configure script for zlib. |
---|
3 | # |
---|
4 | # Normally configure builds both a static and a shared library. |
---|
5 | # If you want to build just a static library, use: ./configure --static |
---|
6 | # |
---|
7 | # To impose specific compiler or flags or install directory, use for example: |
---|
8 | # prefix=$HOME CC=cc CFLAGS="-O4" ./configure |
---|
9 | # or for csh/tcsh users: |
---|
10 | # (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure) |
---|
11 | |
---|
12 | # Incorrect settings of CC or CFLAGS may prevent creating a shared library. |
---|
13 | # If you have problems, try without defining CC and CFLAGS before reporting |
---|
14 | # an error. |
---|
15 | |
---|
16 | STATICLIB=libz.a |
---|
17 | LDFLAGS="${LDFLAGS} -L. ${STATICLIB}" |
---|
18 | VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` |
---|
19 | VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h` |
---|
20 | VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h` |
---|
21 | VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h` |
---|
22 | AR=${AR-"ar"} |
---|
23 | AR_RC="${AR} rc" |
---|
24 | RANLIB=${RANLIB-"ranlib"} |
---|
25 | prefix=${prefix-/usr/local} |
---|
26 | exec_prefix=${exec_prefix-'${prefix}'} |
---|
27 | libdir=${libdir-'${exec_prefix}/lib'} |
---|
28 | includedir=${includedir-'${prefix}/include'} |
---|
29 | mandir=${mandir-'${prefix}/share/man'} |
---|
30 | shared_ext='.so' |
---|
31 | shared=1 |
---|
32 | zprefix=0 |
---|
33 | build64=0 |
---|
34 | gcc=0 |
---|
35 | old_cc="$CC" |
---|
36 | old_cflags="$CFLAGS" |
---|
37 | |
---|
38 | while test $# -ge 1 |
---|
39 | do |
---|
40 | case "$1" in |
---|
41 | -h* | --help) |
---|
42 | echo 'usage:' |
---|
43 | echo ' configure [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' |
---|
44 | echo ' [--static] [--64] [--libdir=LIBDIR] [--includedir=INCLUDEDIR]' |
---|
45 | exit 0 ;; |
---|
46 | -p*=* | --prefix=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift ;; |
---|
47 | -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift ;; |
---|
48 | -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift ;; |
---|
49 | -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift ;; |
---|
50 | -u*=* | --uname=*) uname=`echo $1 | sed 's/[-a-z_]*=//'`;shift ;; |
---|
51 | -p* | --prefix) prefix="$2"; shift; shift ;; |
---|
52 | -e* | --eprefix) exec_prefix="$2"; shift; shift ;; |
---|
53 | -l* | --libdir) libdir="$2"; shift; shift ;; |
---|
54 | -i* | --includedir) includedir="$2"; shift; shift ;; |
---|
55 | -s* | --shared | --enable-shared) shared=1; shift ;; |
---|
56 | -t | --static) shared=0; shift ;; |
---|
57 | -z* | --zprefix) zprefix=1; shift ;; |
---|
58 | -6* | --64) build64=1; shift ;; |
---|
59 | --sysconfdir=*) echo "ignored option: --sysconfdir"; shift ;; |
---|
60 | --localstatedir=*) echo "ignored option: --localstatedir"; shift ;; |
---|
61 | *) echo "unknown option: $1"; echo "$0 --help for help"; exit 1 ;; |
---|
62 | esac |
---|
63 | done |
---|
64 | |
---|
65 | test=ztest$$ |
---|
66 | cat > $test.c <<EOF |
---|
67 | extern int getchar(); |
---|
68 | int hello() {return getchar();} |
---|
69 | EOF |
---|
70 | |
---|
71 | test -z "$CC" && echo Checking for gcc... |
---|
72 | cc=${CC-gcc} |
---|
73 | cflags=${CFLAGS-"-O3"} |
---|
74 | # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure |
---|
75 | case "$cc" in |
---|
76 | *gcc*) gcc=1 ;; |
---|
77 | esac |
---|
78 | |
---|
79 | if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then |
---|
80 | CC="$cc" |
---|
81 | SFLAGS="${CFLAGS-"-O3"} -fPIC" |
---|
82 | CFLAGS="${CFLAGS-"-O3"}" |
---|
83 | if test $build64 -eq 1; then |
---|
84 | CFLAGS="${CFLAGS} -m64" |
---|
85 | SFLAGS="${SFLAGS} -m64" |
---|
86 | fi |
---|
87 | if test "${ZLIBGCCWARN}" = "YES"; then |
---|
88 | CFLAGS="${CFLAGS} -Wall -Wextra -pedantic" |
---|
89 | fi |
---|
90 | if test -z "$uname"; then |
---|
91 | uname=`(uname -s || echo unknown) 2>/dev/null` |
---|
92 | fi |
---|
93 | case "$uname" in |
---|
94 | Linux | linux | GNU | GNU/* | *BSD | DragonFly) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;; |
---|
95 | CYGWIN* | Cygwin* | cygwin* | OS/2* ) |
---|
96 | EXE='.exe' ;; |
---|
97 | QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 |
---|
98 | # (alain.bonnefoy@icbt.com) |
---|
99 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;; |
---|
100 | HP-UX*) |
---|
101 | LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} |
---|
102 | case `(uname -m || echo unknown) 2>/dev/null` in |
---|
103 | ia64) |
---|
104 | shared_ext='.so' |
---|
105 | SHAREDLIB='libz.so' ;; |
---|
106 | *) |
---|
107 | shared_ext='.sl' |
---|
108 | SHAREDLIB='libz.sl' ;; |
---|
109 | esac ;; |
---|
110 | Darwin*) shared_ext='.dylib' |
---|
111 | SHAREDLIB=libz$shared_ext |
---|
112 | SHAREDLIBV=libz.$VER$shared_ext |
---|
113 | SHAREDLIBM=libz.$VER1$shared_ext |
---|
114 | LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} ;; |
---|
115 | *) LDSHARED=${LDSHARED-"$cc -shared"} ;; |
---|
116 | esac |
---|
117 | else |
---|
118 | # find system name and corresponding cc options |
---|
119 | CC=${CC-cc} |
---|
120 | if test -z "$uname"; then |
---|
121 | uname=`(uname -sr || echo unknown) 2>/dev/null` |
---|
122 | fi |
---|
123 | case "$uname" in |
---|
124 | HP-UX*) SFLAGS=${CFLAGS-"-O +z"} |
---|
125 | CFLAGS=${CFLAGS-"-O"} |
---|
126 | # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} |
---|
127 | LDSHARED=${LDSHARED-"ld -b"} |
---|
128 | case `(uname -m || echo unknown) 2>/dev/null` in |
---|
129 | ia64) |
---|
130 | shared_ext='.so' |
---|
131 | SHAREDLIB='libz.so' ;; |
---|
132 | *) |
---|
133 | shared_ext='.sl' |
---|
134 | SHAREDLIB='libz.sl' ;; |
---|
135 | esac ;; |
---|
136 | IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} |
---|
137 | CFLAGS=${CFLAGS-"-ansi -O2"} |
---|
138 | LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; |
---|
139 | OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"} |
---|
140 | CFLAGS=${CFLAGS-"-O -std1"} |
---|
141 | LDFLAGS="${LDFLAGS} -Wl,-rpath,." |
---|
142 | LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;; |
---|
143 | OSF1*) SFLAGS=${CFLAGS-"-O -std1"} |
---|
144 | CFLAGS=${CFLAGS-"-O -std1"} |
---|
145 | LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; |
---|
146 | QNX*) SFLAGS=${CFLAGS-"-4 -O"} |
---|
147 | CFLAGS=${CFLAGS-"-4 -O"} |
---|
148 | LDSHARED=${LDSHARED-"cc"} |
---|
149 | RANLIB=${RANLIB-"true"} |
---|
150 | AR_RC="cc -A" ;; |
---|
151 | SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} |
---|
152 | CFLAGS=${CFLAGS-"-O3"} |
---|
153 | LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;; |
---|
154 | SunOS\ 5*) LDSHARED=${LDSHARED-"cc -G"} |
---|
155 | case `(uname -m || echo unknown) 2>/dev/null` in |
---|
156 | i86*) |
---|
157 | SFLAGS=${CFLAGS-"-xpentium -fast -KPIC -R."} |
---|
158 | CFLAGS=${CFLAGS-"-xpentium -fast"} ;; |
---|
159 | *) |
---|
160 | SFLAGS=${CFLAGS-"-fast -xcg92 -KPIC -R."} |
---|
161 | CFLAGS=${CFLAGS-"-fast -xcg92"} ;; |
---|
162 | esac ;; |
---|
163 | SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} |
---|
164 | CFLAGS=${CFLAGS-"-O2"} |
---|
165 | LDSHARED=${LDSHARED-"ld"} ;; |
---|
166 | SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"} |
---|
167 | CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"} |
---|
168 | LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;; |
---|
169 | UNIX_System_V\ 4.2.0) |
---|
170 | SFLAGS=${CFLAGS-"-KPIC -O"} |
---|
171 | CFLAGS=${CFLAGS-"-O"} |
---|
172 | LDSHARED=${LDSHARED-"cc -G"} ;; |
---|
173 | UNIX_SV\ 4.2MP) |
---|
174 | SFLAGS=${CFLAGS-"-Kconform_pic -O"} |
---|
175 | CFLAGS=${CFLAGS-"-O"} |
---|
176 | LDSHARED=${LDSHARED-"cc -G"} ;; |
---|
177 | OpenUNIX\ 5) |
---|
178 | SFLAGS=${CFLAGS-"-KPIC -O"} |
---|
179 | CFLAGS=${CFLAGS-"-O"} |
---|
180 | LDSHARED=${LDSHARED-"cc -G"} ;; |
---|
181 | AIX*) # Courtesy of dbakker@arrayasolutions.com |
---|
182 | SFLAGS=${CFLAGS-"-O -qmaxmem=8192"} |
---|
183 | CFLAGS=${CFLAGS-"-O -qmaxmem=8192"} |
---|
184 | LDSHARED=${LDSHARED-"xlc -G"} ;; |
---|
185 | # send working options for other systems to zlib@gzip.org |
---|
186 | *) SFLAGS=${CFLAGS-"-O"} |
---|
187 | CFLAGS=${CFLAGS-"-O"} |
---|
188 | LDSHARED=${LDSHARED-"cc -shared"} ;; |
---|
189 | esac |
---|
190 | fi |
---|
191 | |
---|
192 | SHAREDLIB=${SHAREDLIB-"libz$shared_ext"} |
---|
193 | SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"} |
---|
194 | SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"} |
---|
195 | |
---|
196 | if test $shared -eq 1; then |
---|
197 | echo Checking for shared library support... |
---|
198 | # we must test in two steps (cc then ld), required at least on SunOS 4.x |
---|
199 | if test "`($CC -w -c $SFLAGS $test.c) 2>&1`" = "" && |
---|
200 | test "`($LDSHARED $SFLAGS -o $test$shared_ext $test.o) 2>&1`" = ""; then |
---|
201 | echo Building shared library $SHAREDLIBV with $CC. |
---|
202 | elif test -z "$old_cc" -a -z "$old_cflags"; then |
---|
203 | echo No shared library support. |
---|
204 | shared=0; |
---|
205 | else |
---|
206 | echo Tested $CC -w -c $SFLAGS $test.c |
---|
207 | $CC -w -c $SFLAGS $test.c |
---|
208 | echo Tested $LDSHARED $SFLAGS -o $test$shared_ext $test.o |
---|
209 | $LDSHARED $SFLAGS -o $test$shared_ext $test.o |
---|
210 | echo 'No shared library support; try without defining CC and CFLAGS' |
---|
211 | shared=0; |
---|
212 | fi |
---|
213 | fi |
---|
214 | if test $shared -eq 0; then |
---|
215 | LDSHARED="$CC" |
---|
216 | ALL="static" |
---|
217 | TEST="all teststatic" |
---|
218 | SHAREDLIB="" |
---|
219 | SHAREDLIBV="" |
---|
220 | SHAREDLIBM="" |
---|
221 | echo Building static library $STATICLIB version $VER with $CC. |
---|
222 | else |
---|
223 | ALL="static shared" |
---|
224 | TEST="all teststatic testshared" |
---|
225 | fi |
---|
226 | |
---|
227 | cat > $test.c <<EOF |
---|
228 | #include <sys/types.h> |
---|
229 | off64_t dummy = 0; |
---|
230 | EOF |
---|
231 | if test "`($CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c) 2>&1`" = ""; then |
---|
232 | CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1" |
---|
233 | SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1" |
---|
234 | ALL="${ALL} all64" |
---|
235 | TEST="${TEST} test64" |
---|
236 | echo "Checking for off64_t... Yes." |
---|
237 | echo "Checking for fseeko... Yes." |
---|
238 | else |
---|
239 | echo "Checking for off64_t... No." |
---|
240 | cat > $test.c <<EOF |
---|
241 | #include <stdio.h> |
---|
242 | int main(void) { |
---|
243 | fseeko(NULL, 0, 0); |
---|
244 | return 0; |
---|
245 | } |
---|
246 | EOF |
---|
247 | if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then |
---|
248 | echo "Checking for fseeko... Yes." |
---|
249 | else |
---|
250 | CFLAGS="${CFLAGS} -DNO_FSEEKO" |
---|
251 | SFLAGS="${SFLAGS} -DNO_FSEEKO" |
---|
252 | echo "Checking for fseeko... No." |
---|
253 | fi |
---|
254 | fi |
---|
255 | |
---|
256 | cp -p zconf.h.in zconf.h |
---|
257 | |
---|
258 | cat > $test.c <<EOF |
---|
259 | #include <unistd.h> |
---|
260 | int main() { return 0; } |
---|
261 | EOF |
---|
262 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then |
---|
263 | sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h |
---|
264 | mv zconf.temp.h zconf.h |
---|
265 | echo "Checking for unistd.h... Yes." |
---|
266 | else |
---|
267 | echo "Checking for unistd.h... No." |
---|
268 | fi |
---|
269 | |
---|
270 | if test $zprefix -eq 1; then |
---|
271 | sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h |
---|
272 | mv zconf.temp.h zconf.h |
---|
273 | echo "Using z_ prefix on all symbols." |
---|
274 | fi |
---|
275 | |
---|
276 | cat > $test.c <<EOF |
---|
277 | #include <stdio.h> |
---|
278 | #include <stdarg.h> |
---|
279 | #include "zconf.h" |
---|
280 | |
---|
281 | int main() |
---|
282 | { |
---|
283 | #ifndef STDC |
---|
284 | choke me |
---|
285 | #endif |
---|
286 | |
---|
287 | return 0; |
---|
288 | } |
---|
289 | EOF |
---|
290 | |
---|
291 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then |
---|
292 | echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." |
---|
293 | |
---|
294 | cat > $test.c <<EOF |
---|
295 | #include <stdio.h> |
---|
296 | #include <stdarg.h> |
---|
297 | |
---|
298 | int mytest(const char *fmt, ...) |
---|
299 | { |
---|
300 | char buf[20]; |
---|
301 | va_list ap; |
---|
302 | |
---|
303 | va_start(ap, fmt); |
---|
304 | vsnprintf(buf, sizeof(buf), fmt, ap); |
---|
305 | va_end(ap); |
---|
306 | return 0; |
---|
307 | } |
---|
308 | |
---|
309 | int main() |
---|
310 | { |
---|
311 | return (mytest("Hello%d\n", 1)); |
---|
312 | } |
---|
313 | EOF |
---|
314 | |
---|
315 | if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then |
---|
316 | echo "Checking for vsnprintf() in stdio.h... Yes." |
---|
317 | |
---|
318 | cat >$test.c <<EOF |
---|
319 | #include <stdio.h> |
---|
320 | #include <stdarg.h> |
---|
321 | |
---|
322 | int mytest(const char *fmt, ...) |
---|
323 | { |
---|
324 | int n; |
---|
325 | char buf[20]; |
---|
326 | va_list ap; |
---|
327 | |
---|
328 | va_start(ap, fmt); |
---|
329 | n = vsnprintf(buf, sizeof(buf), fmt, ap); |
---|
330 | va_end(ap); |
---|
331 | return n; |
---|
332 | } |
---|
333 | |
---|
334 | int main() |
---|
335 | { |
---|
336 | return (mytest("Hello%d\n", 1)); |
---|
337 | } |
---|
338 | EOF |
---|
339 | |
---|
340 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then |
---|
341 | echo "Checking for return value of vsnprintf()... Yes." |
---|
342 | else |
---|
343 | CFLAGS="$CFLAGS -DHAS_vsnprintf_void" |
---|
344 | SFLAGS="$SFLAGS -DHAS_vsnprintf_void" |
---|
345 | echo "Checking for return value of vsnprintf()... No." |
---|
346 | echo " WARNING: apparently vsnprintf() does not return a value. zlib" |
---|
347 | echo " can build but will be open to possible string-format security" |
---|
348 | echo " vulnerabilities." |
---|
349 | fi |
---|
350 | else |
---|
351 | CFLAGS="$CFLAGS -DNO_vsnprintf" |
---|
352 | SFLAGS="$SFLAGS -DNO_vsnprintf" |
---|
353 | echo "Checking for vsnprintf() in stdio.h... No." |
---|
354 | echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" |
---|
355 | echo " can build but will be open to possible buffer-overflow security" |
---|
356 | echo " vulnerabilities." |
---|
357 | |
---|
358 | cat >$test.c <<EOF |
---|
359 | #include <stdio.h> |
---|
360 | #include <stdarg.h> |
---|
361 | |
---|
362 | int mytest(const char *fmt, ...) |
---|
363 | { |
---|
364 | int n; |
---|
365 | char buf[20]; |
---|
366 | va_list ap; |
---|
367 | |
---|
368 | va_start(ap, fmt); |
---|
369 | n = vsprintf(buf, fmt, ap); |
---|
370 | va_end(ap); |
---|
371 | return n; |
---|
372 | } |
---|
373 | |
---|
374 | int main() |
---|
375 | { |
---|
376 | return (mytest("Hello%d\n", 1)); |
---|
377 | } |
---|
378 | EOF |
---|
379 | |
---|
380 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then |
---|
381 | echo "Checking for return value of vsprintf()... Yes." |
---|
382 | else |
---|
383 | CFLAGS="$CFLAGS -DHAS_vsprintf_void" |
---|
384 | SFLAGS="$SFLAGS -DHAS_vsprintf_void" |
---|
385 | echo "Checking for return value of vsprintf()... No." |
---|
386 | echo " WARNING: apparently vsprintf() does not return a value. zlib" |
---|
387 | echo " can build but will be open to possible string-format security" |
---|
388 | echo " vulnerabilities." |
---|
389 | fi |
---|
390 | fi |
---|
391 | else |
---|
392 | echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." |
---|
393 | |
---|
394 | cat >$test.c <<EOF |
---|
395 | #include <stdio.h> |
---|
396 | |
---|
397 | int mytest() |
---|
398 | { |
---|
399 | char buf[20]; |
---|
400 | |
---|
401 | snprintf(buf, sizeof(buf), "%s", "foo"); |
---|
402 | return 0; |
---|
403 | } |
---|
404 | |
---|
405 | int main() |
---|
406 | { |
---|
407 | return (mytest()); |
---|
408 | } |
---|
409 | EOF |
---|
410 | |
---|
411 | if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then |
---|
412 | echo "Checking for snprintf() in stdio.h... Yes." |
---|
413 | |
---|
414 | cat >$test.c <<EOF |
---|
415 | #include <stdio.h> |
---|
416 | |
---|
417 | int mytest() |
---|
418 | { |
---|
419 | char buf[20]; |
---|
420 | |
---|
421 | return snprintf(buf, sizeof(buf), "%s", "foo"); |
---|
422 | } |
---|
423 | |
---|
424 | int main() |
---|
425 | { |
---|
426 | return (mytest()); |
---|
427 | } |
---|
428 | EOF |
---|
429 | |
---|
430 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then |
---|
431 | echo "Checking for return value of snprintf()... Yes." |
---|
432 | else |
---|
433 | CFLAGS="$CFLAGS -DHAS_snprintf_void" |
---|
434 | SFLAGS="$SFLAGS -DHAS_snprintf_void" |
---|
435 | echo "Checking for return value of snprintf()... No." |
---|
436 | echo " WARNING: apparently snprintf() does not return a value. zlib" |
---|
437 | echo " can build but will be open to possible string-format security" |
---|
438 | echo " vulnerabilities." |
---|
439 | fi |
---|
440 | else |
---|
441 | CFLAGS="$CFLAGS -DNO_snprintf" |
---|
442 | SFLAGS="$SFLAGS -DNO_snprintf" |
---|
443 | echo "Checking for snprintf() in stdio.h... No." |
---|
444 | echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" |
---|
445 | echo " can build but will be open to possible buffer-overflow security" |
---|
446 | echo " vulnerabilities." |
---|
447 | |
---|
448 | cat >$test.c <<EOF |
---|
449 | #include <stdio.h> |
---|
450 | |
---|
451 | int mytest() |
---|
452 | { |
---|
453 | char buf[20]; |
---|
454 | |
---|
455 | return sprintf(buf, "%s", "foo"); |
---|
456 | } |
---|
457 | |
---|
458 | int main() |
---|
459 | { |
---|
460 | return (mytest()); |
---|
461 | } |
---|
462 | EOF |
---|
463 | |
---|
464 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then |
---|
465 | echo "Checking for return value of sprintf()... Yes." |
---|
466 | else |
---|
467 | CFLAGS="$CFLAGS -DHAS_sprintf_void" |
---|
468 | SFLAGS="$SFLAGS -DHAS_sprintf_void" |
---|
469 | echo "Checking for return value of sprintf()... No." |
---|
470 | echo " WARNING: apparently sprintf() does not return a value. zlib" |
---|
471 | echo " can build but will be open to possible string-format security" |
---|
472 | echo " vulnerabilities." |
---|
473 | fi |
---|
474 | fi |
---|
475 | fi |
---|
476 | |
---|
477 | cat >$test.c <<EOF |
---|
478 | #include <errno.h> |
---|
479 | int main() { return 0; } |
---|
480 | EOF |
---|
481 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then |
---|
482 | echo "Checking for errno.h... Yes." |
---|
483 | else |
---|
484 | echo "Checking for errno.h... No." |
---|
485 | CFLAGS="$CFLAGS -DNO_ERRNO_H" |
---|
486 | SFLAGS="$SFLAGS -DNO_ERRNO_H" |
---|
487 | fi |
---|
488 | |
---|
489 | CPP=${CPP-"$CC -E"} |
---|
490 | case $CFLAGS in |
---|
491 | *ASMV*) |
---|
492 | if test "`nm $test.o | grep _hello`" = ""; then |
---|
493 | CPP="$CPP -DNO_UNDERLINE" |
---|
494 | echo Checking for underline in external names... No. |
---|
495 | else |
---|
496 | echo Checking for underline in external names... Yes. |
---|
497 | fi ;; |
---|
498 | esac |
---|
499 | |
---|
500 | rm -f $test.[co] $test $test$shared_ext |
---|
501 | |
---|
502 | # udpate Makefile |
---|
503 | sed < Makefile.in " |
---|
504 | /^CC *=/s#=.*#=$CC# |
---|
505 | /^CFLAGS *=/s#=.*#=$CFLAGS# |
---|
506 | /^SFLAGS *=/s#=.*#=$SFLAGS# |
---|
507 | /^LDFLAGS *=/s#=.*#=$LDFLAGS# |
---|
508 | /^LDSHARED *=/s#=.*#=$LDSHARED# |
---|
509 | /^CPP *=/s#=.*#=$CPP# |
---|
510 | /^STATICLIB *=/s#=.*#=$STATICLIB# |
---|
511 | /^SHAREDLIB *=/s#=.*#=$SHAREDLIB# |
---|
512 | /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# |
---|
513 | /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# |
---|
514 | /^AR *=/s#=.*#=$AR_RC# |
---|
515 | /^RANLIB *=/s#=.*#=$RANLIB# |
---|
516 | /^EXE *=/s#=.*#=$EXE# |
---|
517 | /^prefix *=/s#=.*#=$prefix# |
---|
518 | /^exec_prefix *=/s#=.*#=$exec_prefix# |
---|
519 | /^libdir *=/s#=.*#=$libdir# |
---|
520 | /^includedir *=/s#=.*#=$includedir# |
---|
521 | /^mandir *=/s#=.*#=$mandir# |
---|
522 | /^all: */s#:.*#: $ALL# |
---|
523 | /^test: */s#:.*#: $TEST# |
---|
524 | " > Makefile |
---|
525 | |
---|
526 | sed < zlib.pc.in " |
---|
527 | /^CC *=/s#=.*#=$CC# |
---|
528 | /^CFLAGS *=/s#=.*#=$CFLAGS# |
---|
529 | /^CPP *=/s#=.*#=$CPP# |
---|
530 | /^LDSHARED *=/s#=.*#=$LDSHARED# |
---|
531 | /^STATICLIB *=/s#=.*#=$STATICLIB# |
---|
532 | /^SHAREDLIB *=/s#=.*#=$SHAREDLIB# |
---|
533 | /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# |
---|
534 | /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# |
---|
535 | /^AR *=/s#=.*#=$AR_RC# |
---|
536 | /^RANLIB *=/s#=.*#=$RANLIB# |
---|
537 | /^EXE *=/s#=.*#=$EXE# |
---|
538 | /^prefix *=/s#=.*#=$prefix# |
---|
539 | /^exec_prefix *=/s#=.*#=$exec_prefix# |
---|
540 | /^libdir *=/s#=.*#=$libdir# |
---|
541 | /^includedir *=/s#=.*#=$includedir# |
---|
542 | /^mandir *=/s#=.*#=$mandir# |
---|
543 | /^LDFLAGS *=/s#=.*#=$LDFLAGS# |
---|
544 | " | sed -e " |
---|
545 | s/\@VERSION\@/$VER/g; |
---|
546 | " > zlib.pc |
---|