Fossil SCM

fossil-scm / compat / zlib / configure
Blame History Raw 1116 lines
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
# start off configure.log
17
echo -------------------- >> configure.log
18
echo $0 $* >> configure.log
19
date >> configure.log
20
21
# get source directory
22
SRCDIR=`dirname $0`
23
if test $SRCDIR = "."; then
24
ZINC=""
25
ZINCOUT="-I."
26
SRCDIR=""
27
else
28
ZINC='-I. -include zconf.h'
29
ZINCOUT='-I. -I$(SRCDIR) -include zconf.h'
30
SRCDIR="$SRCDIR/"
31
fi
32
33
# set command prefix for cross-compilation
34
if [ -n "${CHOST}" ]; then
35
uname=${CHOST}
36
mname=${CHOST}
37
CROSS_PREFIX="${CHOST}-"
38
else
39
mname=`(uname -a || echo unknown) 2>/dev/null`
40
fi
41
42
# destination name for static library
43
STATICLIB=libz.a
44
45
# extract zlib version numbers from zlib.h
46
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
47
VER3=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\(\\.[0-9]\{1,\}\)\{1,2\}\).*/\1/p'`
48
VER1=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\)\\..*/\1/p'`
49
50
# establish commands for library building
51
if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
52
AR=${AR-"${CROSS_PREFIX}ar"}
53
test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
54
else
55
AR=${AR-"ar"}
56
test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
57
fi
58
ARFLAGS=${ARFLAGS-"rc"}
59
if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
60
RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
61
test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
62
else
63
RANLIB=${RANLIB-"ranlib"}
64
fi
65
if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
66
NM=${NM-"${CROSS_PREFIX}nm"}
67
test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
68
else
69
NM=${NM-"nm"}
70
fi
71
72
# set defaults before processing command line options
73
LDCONFIG=${LDCONFIG-"ldconfig"}
74
LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
75
ARCHS=
76
prefix=${prefix-/usr/local}
77
exec_prefix=${exec_prefix-'${prefix}'}
78
libdir=${libdir-'${exec_prefix}/lib'}
79
sharedlibdir=${sharedlibdir-'${libdir}'}
80
includedir=${includedir-'${prefix}/include'}
81
mandir=${mandir-'${prefix}/share/man'}
82
shared_ext='.so'
83
shared=1
84
solo=0
85
cover=0
86
zprefix=0
87
zconst=0
88
build64=0
89
gcc=0
90
clang=0
91
warn=0
92
debug=0
93
address=0
94
memory=0
95
undefined=0
96
insecure=0
97
unknown=0
98
enable_crcvx=1
99
old_cc="$CC"
100
old_cflags="$CFLAGS"
101
OBJC='$(OBJZ) $(OBJG)'
102
PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
103
104
# leave this script, optionally in a bad way
105
leave()
106
{
107
if test "$*" != "0"; then
108
echo "** $0 aborting." | tee -a configure.log
109
fi
110
rm -rf $test.[co] $test $test$shared_ext $test.gcno $test.dSYM ./--version
111
echo -------------------- >> configure.log
112
echo >> configure.log
113
echo >> configure.log
114
exit $1
115
}
116
117
# process command line options
118
while test $# -ge 1
119
do
120
case "$1" in
121
-h* | --help)
122
echo 'usage:' | tee -a configure.log
123
echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
124
echo ' [--insecure] [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
125
echo ' [--includedir=INCLUDEDIR] [--mandir=MANDIR]' | tee -a configure.log
126
echo ' [--archs="-arch i386 -arch x86_64"] [--disable-crcvx]' | tee -a configure.log
127
exit 0 ;;
128
-p*=* | --prefix=*) prefix=`echo $1 | sed 's/[^=]*=//'`; shift ;;
129
-e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/[^=]*=//'`; shift ;;
130
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/[^=]*=//'`; shift ;;
131
--sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/[^=]*=//'`; shift ;;
132
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/[^=]*=//'`;shift ;;
133
-m*=* | --mandir=*) mandir=`echo $1 | sed 's/[^=]*=//'`;shift ;;
134
-u*=* | --uname=*) uname=`echo $1 | sed 's/[^=]*=//'`;shift ;;
135
-p* | --prefix) prefix="$2"; shift; shift ;;
136
-e* | --eprefix) exec_prefix="$2"; shift; shift ;;
137
-l* | --libdir) libdir="$2"; shift; shift ;;
138
--sharedlibdir) sharedlibdir="$2"; shift; shift ;;
139
-i* | --includedir) includedir="$2"; shift; shift ;;
140
-m* | --mandir) mandir="$2"; shift; shift ;;
141
-u* | --uname) uname="$2"; shift; shift ;;
142
-s* | --shared | --enable-shared) shared=1; shift ;;
143
-t | --static | --disable-shared) shared=0; shift ;;
144
--solo) solo=1; shift ;;
145
--cover) cover=1; shift ;;
146
-z* | --zprefix) zprefix=1; shift ;;
147
-6* | --64) build64=1; shift ;;
148
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/[^=]*=//'`; shift ;;
149
-a* | --archs) ARCHS="$2"; shift; shift ;;
150
--sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
151
--localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
152
-c* | --const) zconst=1; shift ;;
153
-w* | --warn) warn=$((warn + 1)); shift ;;
154
-d* | --debug) debug=1; shift ;;
155
--sanitize) address=1; shift ;;
156
--address) address=1; shift ;;
157
--memory) memory=1; shift ;;
158
--undefined) undefined=1; shift ;;
159
--insecure) insecure=1; shift ;;
160
--disable-crcvx) enable_crcvx=0; shift ;;
161
*) unknown=1; echo "unknown option ignored: $1" | tee -a configure.log; shift;;
162
esac
163
done
164
if test $unknown -eq 1; then
165
echo "$0 --help for help" | tee -a configure.log
166
fi
167
168
# temporary file name
169
test=ztest$$
170
171
# put arguments in log, also put test file in log if used in arguments
172
show()
173
{
174
case "$*" in
175
*$test.c*)
176
echo === $test.c === >> configure.log
177
cat $test.c >> configure.log
178
echo === >> configure.log;;
179
esac
180
echo $* >> configure.log
181
}
182
183
# check for gcc vs. cc and set compile and link flags based on the system identified by uname
184
cat > $test.c <<EOF
185
extern int getchar();
186
int hello() {return getchar();}
187
EOF
188
189
if test -z "$CC"; then
190
echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
191
if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then
192
cc=${CROSS_PREFIX}gcc
193
else
194
cc=${CROSS_PREFIX}cc
195
fi
196
else
197
cc=${CC}
198
fi
199
200
case "$cc" in
201
*gcc*) gcc=1
202
GCOV="gcov" ;;
203
*clang*) gcc=1
204
clang=1 ;;
205
esac
206
case `$cc -v 2>&1` in
207
*gcc*) gcc=1
208
GCOV="gcov" ;;
209
*clang*) gcc=1
210
clang=1 ;;
211
esac
212
213
if test $cover -eq 1; then
214
if test "$clang" -eq 1; then
215
if test "$cc" = "clang"; then
216
if command -v llvm-cov >/dev/null 2>&1; then
217
GCOV="llvm-cov"
218
LLVM_GCOV_FLAG="gcov"
219
GCOV="llvm-cov"
220
LLVM_GCOV_FLAG="gcov"
221
echo "Using ${GCOV} for coverage"
222
else
223
cover=0
224
GCOV=""
225
LLVM_GCOV_FLAG=""
226
echo "Deactivating cover as no suitable gcov can be found"
227
fi
228
else
229
clangV=`echo "$cc" | sed -e 's/^.*-//'`
230
if command -v llvm-cov-${clangV} >/dev/null 2>&1; then
231
GCOV="llvm-cov-${clangV}"
232
LLVM_GCOV_FLAG="gcov"
233
echo "Using ${GCOV} for coverage"
234
else
235
cover=0
236
GCOV=""
237
LLVM_GCOV_FLAG=""
238
echo "Deactivating cover as no suitable gcov can be found"
239
fi
240
fi
241
fi
242
fi
243
244
show $cc -c $test.c
245
if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
246
echo ... using gcc >> configure.log
247
CC="$cc"
248
CFLAGS="${CFLAGS--O3} -fPIC"
249
SFLAGS="${CFLAGS--O3}"
250
if test "$ARCHS"; then
251
CFLAGS="${CFLAGS} ${ARCHS}"
252
SFLAGS="${SFLAGS} ${ARCHS}"
253
LDFLAGS="${LDFLAGS} ${ARCHS}"
254
fi
255
if test $build64 -eq 1; then
256
CFLAGS="${CFLAGS} -m64"
257
SFLAGS="${SFLAGS} -m64"
258
fi
259
if test "$warn" -ge 1; then
260
CFLAGS="${CFLAGS} -Wall -Wextra"
261
if test "$warn" -ge 2; then
262
CFLAGS="${CFLAGS} -Wconversion -Wshadow -Wundef"
263
fi
264
fi
265
if test "$zconst" -eq 1; then
266
if test "$warn" -ge 1; then
267
CFLAGS="${CFLAGS} -Wcast-qual"
268
fi
269
CFLAGS="${CFLAGS} -DZLIB_CONST"
270
fi
271
if test $address -eq 1; then
272
CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer"
273
fi
274
if test $memory -eq 1; then
275
CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer"
276
fi
277
if test $undefined -eq 1; then
278
CFLAGS="${CFLAGS} -g -fsanitize=undefined -fno-omit-frame-pointer"
279
fi
280
if test $insecure -eq 1; then
281
CFLAGS="${CFLAGS} -DZLIB_INSECURE"
282
SFLAGS="${SFLAGS} -DZLIB_INSECURE"
283
fi
284
if test $debug -eq 1; then
285
CFLAGS="${CFLAGS} -DZLIB_DEBUG"
286
SFLAGS="${SFLAGS} -DZLIB_DEBUG"
287
fi
288
if test -z "$uname"; then
289
uname=`(uname -s || echo unknown) 2>/dev/null`
290
fi
291
case "$uname" in
292
Linux* | linux* | *-linux* | GNU | GNU/* | solaris* | Haiku)
293
case "$mname" in
294
*sparc*)
295
LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
296
esac
297
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
298
*BSD | *bsd* | DragonFly)
299
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
300
LDCONFIG="ldconfig -m" ;;
301
CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*)
302
EXE='.exe' ;;
303
MINGW* | mingw* | *-mingw*)
304
rm -f $test.[co] $test $test$shared_ext
305
echo "If this doesn't work for you, try win32/Makefile.gcc." | tee -a configure.log
306
LDSHARED=${LDSHARED-"$cc -shared"}
307
LDSHAREDLIBC=""
308
EXE='.exe' ;;
309
QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
310
# ([email protected])
311
LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
312
HP-UX*)
313
LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
314
case `(uname -m || echo unknown) 2>/dev/null` in
315
ia64)
316
shared_ext='.so'
317
SHAREDLIB='libz.so' ;;
318
*)
319
shared_ext='.sl'
320
SHAREDLIB='libz.sl' ;;
321
esac ;;
322
AIX*)
323
LDSHARED=${LDSHARED-"$cc -shared"}
324
LDFLAGS="${LDFLAGS} -Wl,-brtl"
325
SHAREDEXP=libz.exp
326
SHAREDEXPFLAG=-Wl,-bE:libz.exp ;;
327
Darwin* | darwin* | *-darwin*)
328
shared_ext='.dylib'
329
SHAREDLIB=libz$shared_ext
330
SHAREDLIBV=libz.$VER$shared_ext
331
SHAREDLIBM=libz.$VER1$shared_ext
332
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
333
if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then
334
AR="${CROSS_PREFIX}libtool"
335
elif libtool -V 2>&1 | grep Apple > /dev/null; then
336
AR="libtool"
337
else
338
AR="/usr/bin/libtool"
339
fi
340
ARFLAGS="-o" ;;
341
*)
342
LDSHARED=${LDSHARED-"$cc -shared"} ;;
343
esac
344
else
345
# find system name and corresponding cc options
346
CC=${CC-cc}
347
gcc=0
348
echo ... using $CC >> configure.log
349
if test -z "$uname"; then
350
uname=`(uname -sr || echo unknown) 2>/dev/null`
351
fi
352
case "$uname" in
353
HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
354
CFLAGS=${CFLAGS-"-O"}
355
# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
356
LDSHARED=${LDSHARED-"ld -b"}
357
case `(uname -m || echo unknown) 2>/dev/null` in
358
ia64)
359
shared_ext='.so'
360
SHAREDLIB='libz.so' ;;
361
*)
362
shared_ext='.sl'
363
SHAREDLIB='libz.sl' ;;
364
esac ;;
365
IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
366
CFLAGS=${CFLAGS-"-ansi -O2"}
367
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
368
OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
369
CFLAGS=${CFLAGS-"-O -std1"}
370
LDFLAGS="${LDFLAGS} -Wl,-rpath,."
371
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
372
OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
373
CFLAGS=${CFLAGS-"-O -std1"}
374
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
375
QNX*) SFLAGS=${CFLAGS-"-4 -O"}
376
CFLAGS=${CFLAGS-"-4 -O"}
377
LDSHARED=${LDSHARED-"cc"}
378
RANLIB=${RANLIB-"true"}
379
AR="cc"
380
ARFLAGS="-A" ;;
381
SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
382
CFLAGS=${CFLAGS-"-O3"}
383
LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
384
SunOS\ 5* | solaris*)
385
LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
386
SFLAGS=${CFLAGS-"-fast -KPIC"}
387
CFLAGS=${CFLAGS-"-fast"}
388
if test $build64 -eq 1; then
389
# old versions of SunPRO/Workshop/Studio don't support -m64,
390
# but newer ones do. Check for it.
391
flag64=`$CC -flags | egrep -- '^-m64'`
392
if test x"$flag64" != x"" ; then
393
CFLAGS="${CFLAGS} -m64"
394
SFLAGS="${SFLAGS} -m64"
395
else
396
case `(uname -m || echo unknown) 2>/dev/null` in
397
i86*)
398
SFLAGS="$SFLAGS -xarch=amd64"
399
CFLAGS="$CFLAGS -xarch=amd64" ;;
400
*)
401
SFLAGS="$SFLAGS -xarch=v9"
402
CFLAGS="$CFLAGS -xarch=v9" ;;
403
esac
404
fi
405
fi
406
if test -n "$ZINC"; then
407
ZINC='-I- -I. -I$(SRCDIR)'
408
ZINCOUT='-I- -I. -I$(SRCDIR)'
409
fi
410
;;
411
SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
412
CFLAGS=${CFLAGS-"-O2"}
413
LDSHARED=${LDSHARED-"ld"} ;;
414
SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
415
CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
416
LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
417
UNIX_System_V\ 4.2.0)
418
SFLAGS=${CFLAGS-"-KPIC -O"}
419
CFLAGS=${CFLAGS-"-O"}
420
LDSHARED=${LDSHARED-"cc -G"} ;;
421
UNIX_SV\ 4.2MP)
422
SFLAGS=${CFLAGS-"-Kconform_pic -O"}
423
CFLAGS=${CFLAGS-"-O"}
424
LDSHARED=${LDSHARED-"cc -G"} ;;
425
OpenUNIX\ 5)
426
SFLAGS=${CFLAGS-"-KPIC -O"}
427
CFLAGS=${CFLAGS-"-O"}
428
LDSHARED=${LDSHARED-"cc -G"} ;;
429
AIX*) # Courtesy of [email protected]
430
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
431
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
432
LDSHARED=${LDSHARED-"xlc -G"}
433
if test $build64 -eq 1; then
434
CFLAGS="${CFLAGS} -q64"
435
SFLAGS="${SFLAGS} -q64"
436
ARFLAGS="-X64 ${ARFLAGS}"
437
fi ;;
438
# send working options for other systems to [email protected]
439
*) SFLAGS=${CFLAGS-"-O"}
440
CFLAGS=${CFLAGS-"-O"}
441
LDSHARED=${LDSHARED-"cc -shared"} ;;
442
esac
443
fi
444
445
# destination names for shared library if not defined above
446
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
447
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
448
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
449
450
echo >> configure.log
451
452
# define functions for testing compiler and library characteristics and logging the results
453
454
cat > $test.c <<EOF
455
#error error
456
EOF
457
if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
458
try()
459
{
460
show $*
461
test "`( $* ) 2>&1 | tee -a configure.log`" = ""
462
}
463
echo - using any output from compiler to indicate an error >> configure.log
464
else
465
try()
466
{
467
show $*
468
got=`( $* ) 2>&1`
469
ret=$?
470
if test "$got" != ""; then
471
printf "%s\n" "$got" >> configure.log
472
fi
473
if test $ret -ne 0; then
474
echo "(exit code "$ret")" >> configure.log
475
fi
476
return $ret
477
}
478
fi
479
480
tryboth()
481
{
482
show $*
483
got=`( $* ) 2>&1`
484
ret=$?
485
if test "$got" != ""; then
486
printf "%s\n" "$got" >> configure.log
487
fi
488
if test $ret -ne 0; then
489
echo "(exit code "$ret")" >> configure.log
490
return $ret
491
fi
492
test "$got" = ""
493
}
494
495
cat > $test.c << EOF
496
int foo() { return 0; }
497
EOF
498
echo "Checking for compiler..." >> configure.log
499
if try $CC -c $test.c; then
500
:
501
else
502
echo "Missing or broken C compiler." | tee -a configure.log
503
leave 1
504
fi
505
echo "Checking for obsessive-compulsive compiler options..." >> configure.log
506
if try $CC -c $CFLAGS $test.c; then
507
:
508
else
509
echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
510
leave 1
511
fi
512
513
# turn off useless GCC 5 warning about PowerPC vector type alignments.
514
if test "$gcc" -eq 1; then
515
cat > $test.c << EOF
516
typedef int zvec __attribute__((vector_size(8)));
517
struct zstruct { char c; zvec v; };
518
int zfunc(struct zstruct *s) { return s->c; }
519
EOF
520
echo "Checking for gcc vector ABI notes..." >> configure.log
521
show $CC -c $CFLAGS $test.c
522
got=`( $CC -c $CFLAGS $test.c ) 2>&1`
523
if test "$got" != ""; then
524
printf "%s\n" "$got" >> configure.log
525
fi
526
case "$got" in
527
*"changed in GCC 5"*)
528
if tryboth $CC -c $CFLAGS -Wno-psabi $test.c; then
529
echo "... turning the notes off with -Wno-psabi" >> configure.log
530
CFLAGS="${CFLAGS} -Wno-psabi"
531
SFLAGS="${SFLAGS} -Wno-psabi"
532
fi ;;
533
esac
534
fi
535
536
echo >> configure.log
537
538
# see if shared library build supported
539
cat > $test.c <<EOF
540
extern int getchar();
541
int hello() {return getchar();}
542
EOF
543
if test $shared -eq 1; then
544
echo Checking for shared library support... | tee -a configure.log
545
# we must test in two steps (cc then ld), required at least on SunOS 4.x
546
# the second link test is for linkers like lld that by default reject a
547
# version script naming symbols that the test object doesn't define -- if
548
# that's needed, keep the option, since some builds (e.g. --solo) don't
549
# define all of the symbols in zlib.map
550
if try $CC -c $SFLAGS $test.c &&
551
{ try $LDSHARED $SFLAGS $LDFLAGS -o $test$shared_ext $test.o ||
552
{ try $LDSHARED $SFLAGS $LDFLAGS -Wl,--undefined-version \
553
-o $test$shared_ext $test.o &&
554
LDSHARED="$LDSHARED -Wl,--undefined-version"; }; }; then
555
echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
556
elif test -z "$old_cc" -a -z "$old_cflags"; then
557
echo No shared library support. | tee -a configure.log
558
shared=0;
559
else
560
echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
561
shared=0;
562
fi
563
fi
564
if test $shared -eq 0; then
565
LDSHARED="$CC"
566
ALL="static"
567
TEST="all teststatic"
568
SHAREDLIB=""
569
SHAREDLIBV=""
570
SHAREDLIBM=""
571
echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
572
else
573
ALL="static shared"
574
TEST="all teststatic testshared"
575
fi
576
577
echo >> configure.log
578
579
# check for size_t
580
cat > $test.c <<EOF
581
#include <stdio.h>
582
#include <stdlib.h>
583
size_t dummy = 0;
584
EOF
585
if try $CC -c $CFLAGS $test.c; then
586
echo "Checking for size_t... Yes." | tee -a configure.log
587
else
588
echo "Checking for size_t... No." | tee -a configure.log
589
# find a size_t integer type
590
# check for long long
591
cat > $test.c << EOF
592
long long dummy = 0;
593
EOF
594
if try $CC -c $CFLAGS $test.c; then
595
echo "Checking for long long... Yes." | tee -a configure.log
596
cat > $test.c <<EOF
597
#include <stdio.h>
598
int main(void) {
599
if (sizeof(void *) <= sizeof(int)) puts("int");
600
else if (sizeof(void *) <= sizeof(long)) puts("long");
601
else puts("z_longlong");
602
return 0;
603
}
604
EOF
605
else
606
echo "Checking for long long... No." | tee -a configure.log
607
cat > $test.c <<EOF
608
#include <stdio.h>
609
int main(void) {
610
if (sizeof(void *) <= sizeof(int)) puts("int");
611
else puts("long");
612
return 0;
613
}
614
EOF
615
fi
616
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
617
sizet=`./$test`
618
echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
619
CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
620
SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
621
else
622
echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
623
fi
624
fi
625
626
echo >> configure.log
627
628
# check for large file support, and if none, check for fseeko()
629
cat > $test.c <<EOF
630
#include <sys/types.h>
631
off64_t dummy = 0;
632
EOF
633
if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
634
CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
635
SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
636
ALL="${ALL} all64"
637
TEST="${TEST} test64"
638
echo "Checking for off64_t... Yes." | tee -a configure.log
639
echo "Checking for fseeko... Yes." | tee -a configure.log
640
else
641
echo "Checking for off64_t... No." | tee -a configure.log
642
echo >> configure.log
643
cat > $test.c <<EOF
644
#include <stdio.h>
645
int main(void) {
646
fseeko(NULL, 0, 0);
647
return 0;
648
}
649
EOF
650
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
651
echo "Checking for fseeko... Yes." | tee -a configure.log
652
else
653
CFLAGS="${CFLAGS} -DNO_FSEEKO"
654
SFLAGS="${SFLAGS} -DNO_FSEEKO"
655
echo "Checking for fseeko... No." | tee -a configure.log
656
fi
657
fi
658
659
echo >> configure.log
660
661
# check for strerror() for use by gz* functions
662
cat > $test.c <<EOF
663
#include <string.h>
664
#include <errno.h>
665
int main() { return strlen(strerror(errno)); }
666
EOF
667
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
668
echo "Checking for strerror... Yes." | tee -a configure.log
669
else
670
CFLAGS="${CFLAGS} -DNO_STRERROR"
671
SFLAGS="${SFLAGS} -DNO_STRERROR"
672
echo "Checking for strerror... No." | tee -a configure.log
673
fi
674
675
# copy clean zconf.h for subsequent edits
676
cp -p ${SRCDIR}zconf.h.in zconf.h
677
678
echo >> configure.log
679
680
# check for unistd.h and save result in zconf.h
681
cat > $test.c <<EOF
682
#include <unistd.h>
683
int main() { return 0; }
684
EOF
685
if try $CC -c $CFLAGS $test.c; then
686
sed < zconf.h "/^#if HAVE_UNISTD_H-0.* may be/s/ HAVE_UNISTD_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
687
mv zconf.temp.h zconf.h
688
echo "Checking for unistd.h... Yes." | tee -a configure.log
689
else
690
echo "Checking for unistd.h... No." | tee -a configure.log
691
fi
692
693
echo >> configure.log
694
695
# check for stdarg.h and save result in zconf.h
696
cat > $test.c <<EOF
697
#include <stdarg.h>
698
int main() { return 0; }
699
EOF
700
if try $CC -c $CFLAGS $test.c; then
701
sed < zconf.h "/^#if HAVE_STDARG_H-0.* may be/s/ HAVE_STDARG_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
702
mv zconf.temp.h zconf.h
703
echo "Checking for stdarg.h... Yes." | tee -a configure.log
704
else
705
echo "Checking for stdarg.h... No." | tee -a configure.log
706
fi
707
708
# if the z_ prefix was requested, save that in zconf.h
709
if test $zprefix -eq 1; then
710
sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
711
mv zconf.temp.h zconf.h
712
echo >> configure.log
713
echo "Using z_ prefix on all symbols." | tee -a configure.log
714
fi
715
716
# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
717
if test $solo -eq 1; then
718
sed '/#define ZCONF_H/a\
719
#define Z_SOLO
720
721
' < zconf.h > zconf.temp.h
722
mv zconf.temp.h zconf.h
723
OBJC='$(OBJZ)'
724
PIC_OBJC='$(PIC_OBJZ)'
725
fi
726
727
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
728
if test $cover -eq 1; then
729
if test -n "$GCC_CLASSIC"; then
730
CC=$GCC_CLASSIC
731
fi
732
fi
733
734
echo >> configure.log
735
736
# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
737
# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
738
# return value. The most secure result is vsnprintf() with a return value. snprintf() with a
739
# return value is secure as well, but then gzprintf() will be limited to 20 arguments.
740
cat > $test.c <<EOF
741
#include <stdio.h>
742
#include <stdarg.h>
743
#include "zconf.h"
744
int main()
745
{
746
#ifndef STDC
747
choke me
748
#endif
749
return 0;
750
}
751
EOF
752
if try $CC -c $CFLAGS $test.c; then
753
echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
754
755
echo >> configure.log
756
cat > $test.c <<EOF
757
#include <stdio.h>
758
#include <stdarg.h>
759
int mytest(const char *fmt, ...)
760
{
761
char buf[20];
762
va_list ap;
763
va_start(ap, fmt);
764
vsnprintf(buf, sizeof(buf), fmt, ap);
765
va_end(ap);
766
return 0;
767
}
768
int main()
769
{
770
return (mytest("Hello%d\n", 1));
771
}
772
EOF
773
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
774
echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
775
776
echo >> configure.log
777
cat >$test.c <<EOF
778
#include <stdio.h>
779
#include <stdarg.h>
780
int mytest(const char *fmt, ...)
781
{
782
int n;
783
char buf[20];
784
va_list ap;
785
va_start(ap, fmt);
786
n = vsnprintf(buf, sizeof(buf), fmt, ap);
787
va_end(ap);
788
return n;
789
}
790
int main()
791
{
792
return (mytest("Hello%d\n", 1));
793
}
794
EOF
795
796
if try $CC -c $CFLAGS $test.c; then
797
echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
798
else
799
CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
800
SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
801
echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
802
echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
803
echo " can build but will be open to possible string-format security" | tee -a configure.log
804
echo " vulnerabilities." | tee -a configure.log
805
fi
806
else
807
CFLAGS="$CFLAGS -DNO_vsnprintf"
808
SFLAGS="$SFLAGS -DNO_vsnprintf"
809
echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
810
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
811
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
812
echo " vulnerabilities." | tee -a configure.log
813
if test $insecure -ne 1; then
814
echo " The --insecure option must be provided to ./configure in order to" | tee -a configure.log
815
echo " compile using the insecure vsprintf() function." | tee -a configure.log
816
fi
817
echo >> configure.log
818
cat >$test.c <<EOF
819
#include <stdio.h>
820
#include <stdarg.h>
821
int mytest(const char *fmt, ...)
822
{
823
int n;
824
char buf[20];
825
va_list ap;
826
va_start(ap, fmt);
827
n = vsprintf(buf, fmt, ap);
828
va_end(ap);
829
return n;
830
}
831
int main()
832
{
833
return (mytest("Hello%d\n", 1));
834
}
835
EOF
836
837
if try $CC -c $CFLAGS $test.c; then
838
echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
839
else
840
CFLAGS="$CFLAGS -DHAS_vsprintf_void"
841
SFLAGS="$SFLAGS -DHAS_vsprintf_void"
842
echo "Checking for return value of vsprintf()... No." | tee -a configure.log
843
echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
844
echo " can build but will be open to possible string-format security" | tee -a configure.log
845
echo " vulnerabilities." | tee -a configure.log
846
fi
847
fi
848
else
849
echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
850
851
echo >> configure.log
852
cat >$test.c <<EOF
853
#include <stdio.h>
854
int mytest()
855
{
856
char buf[20];
857
snprintf(buf, sizeof(buf), "%s", "foo");
858
return 0;
859
}
860
int main()
861
{
862
return (mytest());
863
}
864
EOF
865
866
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
867
echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
868
869
echo >> configure.log
870
cat >$test.c <<EOF
871
#include <stdio.h>
872
int mytest()
873
{
874
char buf[20];
875
return snprintf(buf, sizeof(buf), "%s", "foo");
876
}
877
int main()
878
{
879
return (mytest());
880
}
881
EOF
882
883
if try $CC -c $CFLAGS $test.c; then
884
echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
885
else
886
CFLAGS="$CFLAGS -DHAS_snprintf_void"
887
SFLAGS="$SFLAGS -DHAS_snprintf_void"
888
echo "Checking for return value of snprintf()... No." | tee -a configure.log
889
echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
890
echo " can build but will be open to possible string-format security" | tee -a configure.log
891
echo " vulnerabilities." | tee -a configure.log
892
fi
893
else
894
CFLAGS="$CFLAGS -DNO_snprintf"
895
SFLAGS="$SFLAGS -DNO_snprintf"
896
echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
897
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
898
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
899
echo " vulnerabilities." | tee -a configure.log
900
if test $insecure -ne 1; then
901
echo " The --insecure option must be provided to ./configure in order to" | tee -a configure.log
902
echo " compile using the insecure sprintf() function." | tee -a configure.log
903
fi
904
echo >> configure.log
905
cat >$test.c <<EOF
906
#include <stdio.h>
907
int mytest()
908
{
909
char buf[20];
910
return sprintf(buf, "%s", "foo");
911
}
912
int main()
913
{
914
return (mytest());
915
}
916
EOF
917
918
if try $CC -c $CFLAGS $test.c; then
919
echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
920
else
921
CFLAGS="$CFLAGS -DHAS_sprintf_void"
922
SFLAGS="$SFLAGS -DHAS_sprintf_void"
923
echo "Checking for return value of sprintf()... No." | tee -a configure.log
924
echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
925
echo " can build but will be open to possible string-format security" | tee -a configure.log
926
echo " vulnerabilities." | tee -a configure.log
927
fi
928
fi
929
fi
930
931
# see if we can hide zlib internal symbols that are linked between separate source files
932
if test "$gcc" -eq 1; then
933
echo >> configure.log
934
cat > $test.c <<EOF
935
#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
936
int ZLIB_INTERNAL foo;
937
int main()
938
{
939
return 0;
940
}
941
EOF
942
if tryboth $CC -c $CFLAGS $test.c; then
943
CFLAGS="$CFLAGS -DHAVE_HIDDEN"
944
SFLAGS="$SFLAGS -DHAVE_HIDDEN"
945
echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
946
else
947
echo "Checking for attribute(visibility) support... No." | tee -a configure.log
948
fi
949
fi
950
951
# check for ibm s390x build
952
HAVE_S390X=0
953
cat > $test.c << EOF
954
#ifndef __s390x__
955
#error
956
#endif
957
EOF
958
if try $CC -c $CFLAGS $test.c; then
959
echo "Checking for s390x build ... Yes." | tee -a configure.log
960
HAVE_S390X=1
961
else
962
echo "Checking for s390x build ... No." | tee -a configure.log
963
fi
964
965
# check for ibm s390x vx vector extensions
966
HAVE_S390X_VX=0
967
if test $HAVE_S390X -eq 1 && test $enable_crcvx -eq 1 ; then
968
# preset the compiler specific flags
969
if test $clang -eq 1; then
970
VGFMAFLAG=-fzvector
971
else
972
VGFMAFLAG=-mzarch
973
fi
974
975
cat > $test.c <<EOF
976
#ifndef __s390x__
977
#error
978
#endif
979
#include <vecintrin.h>
980
int main(void) {
981
unsigned long long a __attribute__((vector_size(16))) = { 0 };
982
unsigned long long b __attribute__((vector_size(16))) = { 0 };
983
unsigned char c __attribute__((vector_size(16))) = { 0 };
984
c = vec_gfmsum_accum_128(a, b, c);
985
return c[0];
986
}
987
EOF
988
989
# cflags already contains a valid march
990
if try $CC -c $CFLAGS $VGFMAFLAG $test.c; then
991
echo "Checking for s390x vx vector extension ... Yes." | tee -a configure.log
992
HAVE_S390X_VX=1
993
# or set march for our compile units
994
elif try $CC -c $CFLAGS $VGFMAFLAG -march=z13 $test.c; then
995
echo "Checking for s390x vx vector extension (march=z13) ... Yes." | tee -a configure.log
996
HAVE_S390X_VX=1
997
VGFMAFLAG="$VGFMAFLAG -march=z13"
998
# else we are not on s390x
999
else
1000
echo "Checking for s390x vx vector extension ... No." | tee -a configure.log
1001
fi
1002
1003
# prepare compiling for s390x
1004
if test $HAVE_S390X_VX -eq 1; then
1005
CFLAGS="$CFLAGS -DHAVE_S390X_VX"
1006
SFLAGS="$SFLAGS -DHAVE_S390X_VX"
1007
OBJC="$OBJC crc32_vx.o"
1008
PIC_OBJC="$PIC_OBJC crc32_vx.lo"
1009
else
1010
# target has no vx extension
1011
VGFMAFLAG=""
1012
fi
1013
fi
1014
1015
# show the results in the log
1016
echo >> configure.log
1017
echo ALL = $ALL >> configure.log
1018
echo AR = $AR >> configure.log
1019
echo ARFLAGS = $ARFLAGS >> configure.log
1020
echo CC = $CC >> configure.log
1021
echo CFLAGS = $CFLAGS >> configure.log
1022
echo CPP = $CPP >> configure.log
1023
echo EXE = $EXE >> configure.log
1024
echo LDCONFIG = $LDCONFIG >> configure.log
1025
echo LDFLAGS = $LDFLAGS >> configure.log
1026
echo LDSHARED = $LDSHARED >> configure.log
1027
echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
1028
echo OBJC = $OBJC >> configure.log
1029
echo PIC_OBJC = $PIC_OBJC >> configure.log
1030
echo RANLIB = $RANLIB >> configure.log
1031
echo SFLAGS = $SFLAGS >> configure.log
1032
echo SHAREDLIB = $SHAREDLIB >> configure.log
1033
echo SHAREDLIBM = $SHAREDLIBM >> configure.log
1034
echo SHAREDLIBV = $SHAREDLIBV >> configure.log
1035
echo STATICLIB = $STATICLIB >> configure.log
1036
echo TEST = $TEST >> configure.log
1037
echo VER = $VER >> configure.log
1038
echo SRCDIR = $SRCDIR >> configure.log
1039
echo exec_prefix = $exec_prefix >> configure.log
1040
echo includedir = $includedir >> configure.log
1041
echo libdir = $libdir >> configure.log
1042
echo mandir = $mandir >> configure.log
1043
echo prefix = $prefix >> configure.log
1044
echo sharedlibdir = $sharedlibdir >> configure.log
1045
echo uname = $uname >> configure.log
1046
echo HAVE_S390X = $HAVE_S390X >> configure.log
1047
echo HAVE_S390X_VX = $HAVE_S390X_VX >> configure.log
1048
echo VGFMAFLAG = $VGFMAFLAG >> configure.log
1049
1050
# update Makefile with the configure results
1051
sed < ${SRCDIR}Makefile.in "
1052
/^CC *=/s#=.*#=$CC#
1053
/^GCOV *=/s#=.*#=$GCOV#
1054
/^LLVM_GCOV_FLAG *=/s#=.*#=$LLVM_GCOV_FLAG#
1055
/^CFLAGS *=/s#=.*#=$CFLAGS#
1056
/^SFLAGS *=/s#=.*#=$SFLAGS#
1057
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
1058
/^LDSHARED *=/s#=.*#=$LDSHARED#
1059
/^CPP *=/s#=.*#=$CPP#
1060
/^VGFMAFLAG *=/s#=.*#=$VGFMAFLAG#
1061
/^STATICLIB *=/s#=.*#=$STATICLIB#
1062
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
1063
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
1064
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
1065
/^AR *=/s#=.*#=$AR#
1066
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
1067
/^RANLIB *=/s#=.*#=$RANLIB#
1068
/^LDCONFIG *=/s#=.*#=$LDCONFIG#
1069
/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
1070
/^SHAREDEXP *=/s#=.*#=$SHAREDEXP#
1071
/^SHAREDEXPFLAG *=/s#=.*#=$SHAREDEXPFLAG#
1072
/^EXE *=/s#=.*#=$EXE#
1073
/^SRCDIR *=/s#=.*#=$SRCDIR#
1074
/^ZINC *=/s#=.*#=$ZINC#
1075
/^ZINCOUT *=/s#=.*#=$ZINCOUT#
1076
/^prefix *=/s#=.*#=$prefix#
1077
/^exec_prefix *=/s#=.*#=$exec_prefix#
1078
/^libdir *=/s#=.*#=$libdir#
1079
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
1080
/^includedir *=/s#=.*#=$includedir#
1081
/^mandir *=/s#=.*#=$mandir#
1082
/^OBJC *=/s#=.*#= $OBJC#
1083
/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
1084
/^all: */s#:.*#: $ALL#
1085
/^test: */s#:.*#: $TEST#
1086
" > Makefile
1087
1088
# create zlib.pc with the configure results
1089
sed < ${SRCDIR}zlib.pc.in "
1090
/^CC *=/s#=.*#=$CC#
1091
/^CFLAGS *=/s#=.*#=$CFLAGS#
1092
/^CPP *=/s#=.*#=$CPP#
1093
/^VGFMAFLAG *=/s#=.*#=$VGFMAFLAG#
1094
/^LDSHARED *=/s#=.*#=$LDSHARED#
1095
/^STATICLIB *=/s#=.*#=$STATICLIB#
1096
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
1097
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
1098
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
1099
/^AR *=/s#=.*#=$AR#
1100
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
1101
/^RANLIB *=/s#=.*#=$RANLIB#
1102
/^EXE *=/s#=.*#=$EXE#
1103
/^prefix *=/s#=.*#=$prefix#
1104
/^exec_prefix *=/s#=.*#=$exec_prefix#
1105
/^libdir *=/s#=.*#=$libdir#
1106
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
1107
/^includedir *=/s#=.*#=$includedir#
1108
/^mandir *=/s#=.*#=$mandir#
1109
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
1110
" | sed -e "
1111
s/\@VERSION\@/$VER/g;
1112
" > zlib.pc
1113
1114
# done
1115
leave 0
1116

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button