|
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)' |
|
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
|
Darwin* | darwin* | *-darwin*) |
|
326
|
shared_ext='.dylib' |
|
327
|
SHAREDLIB=libz$shared_ext |
|
328
|
SHAREDLIBV=libz.$VER$shared_ext |
|
329
|
SHAREDLIBM=libz.$VER1$shared_ext |
|
330
|
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} |
|
331
|
if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then |
|
332
|
AR="${CROSS_PREFIX}libtool" |
|
333
|
elif libtool -V 2>&1 | grep Apple > /dev/null; then |
|
334
|
AR="libtool" |
|
335
|
else |
|
336
|
AR="/usr/bin/libtool" |
|
337
|
fi |
|
338
|
ARFLAGS="-o" ;; |
|
339
|
*) |
|
340
|
LDSHARED=${LDSHARED-"$cc -shared"} ;; |
|
341
|
esac |
|
342
|
else |
|
343
|
# find system name and corresponding cc options |
|
344
|
CC=${CC-cc} |
|
345
|
gcc=0 |
|
346
|
echo ... using $CC >> configure.log |
|
347
|
if test -z "$uname"; then |
|
348
|
uname=`(uname -sr || echo unknown) 2>/dev/null` |
|
349
|
fi |
|
350
|
case "$uname" in |
|
351
|
HP-UX*) SFLAGS=${CFLAGS-"-O +z"} |
|
352
|
CFLAGS=${CFLAGS-"-O"} |
|
353
|
# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} |
|
354
|
LDSHARED=${LDSHARED-"ld -b"} |
|
355
|
case `(uname -m || echo unknown) 2>/dev/null` in |
|
356
|
ia64) |
|
357
|
shared_ext='.so' |
|
358
|
SHAREDLIB='libz.so' ;; |
|
359
|
*) |
|
360
|
shared_ext='.sl' |
|
361
|
SHAREDLIB='libz.sl' ;; |
|
362
|
esac ;; |
|
363
|
IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} |
|
364
|
CFLAGS=${CFLAGS-"-ansi -O2"} |
|
365
|
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; |
|
366
|
OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"} |
|
367
|
CFLAGS=${CFLAGS-"-O -std1"} |
|
368
|
LDFLAGS="${LDFLAGS} -Wl,-rpath,." |
|
369
|
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;; |
|
370
|
OSF1*) SFLAGS=${CFLAGS-"-O -std1"} |
|
371
|
CFLAGS=${CFLAGS-"-O -std1"} |
|
372
|
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; |
|
373
|
QNX*) SFLAGS=${CFLAGS-"-4 -O"} |
|
374
|
CFLAGS=${CFLAGS-"-4 -O"} |
|
375
|
LDSHARED=${LDSHARED-"cc"} |
|
376
|
RANLIB=${RANLIB-"true"} |
|
377
|
AR="cc" |
|
378
|
ARFLAGS="-A" ;; |
|
379
|
SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} |
|
380
|
CFLAGS=${CFLAGS-"-O3"} |
|
381
|
LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;; |
|
382
|
SunOS\ 5* | solaris*) |
|
383
|
LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"} |
|
384
|
SFLAGS=${CFLAGS-"-fast -KPIC"} |
|
385
|
CFLAGS=${CFLAGS-"-fast"} |
|
386
|
if test $build64 -eq 1; then |
|
387
|
# old versions of SunPRO/Workshop/Studio don't support -m64, |
|
388
|
# but newer ones do. Check for it. |
|
389
|
flag64=`$CC -flags | egrep -- '^-m64'` |
|
390
|
if test x"$flag64" != x"" ; then |
|
391
|
CFLAGS="${CFLAGS} -m64" |
|
392
|
SFLAGS="${SFLAGS} -m64" |
|
393
|
else |
|
394
|
case `(uname -m || echo unknown) 2>/dev/null` in |
|
395
|
i86*) |
|
396
|
SFLAGS="$SFLAGS -xarch=amd64" |
|
397
|
CFLAGS="$CFLAGS -xarch=amd64" ;; |
|
398
|
*) |
|
399
|
SFLAGS="$SFLAGS -xarch=v9" |
|
400
|
CFLAGS="$CFLAGS -xarch=v9" ;; |
|
401
|
esac |
|
402
|
fi |
|
403
|
fi |
|
404
|
if test -n "$ZINC"; then |
|
405
|
ZINC='-I- -I. -I$(SRCDIR)' |
|
406
|
fi |
|
407
|
;; |
|
408
|
SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} |
|
409
|
CFLAGS=${CFLAGS-"-O2"} |
|
410
|
LDSHARED=${LDSHARED-"ld"} ;; |
|
411
|
SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"} |
|
412
|
CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"} |
|
413
|
LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;; |
|
414
|
UNIX_System_V\ 4.2.0) |
|
415
|
SFLAGS=${CFLAGS-"-KPIC -O"} |
|
416
|
CFLAGS=${CFLAGS-"-O"} |
|
417
|
LDSHARED=${LDSHARED-"cc -G"} ;; |
|
418
|
UNIX_SV\ 4.2MP) |
|
419
|
SFLAGS=${CFLAGS-"-Kconform_pic -O"} |
|
420
|
CFLAGS=${CFLAGS-"-O"} |
|
421
|
LDSHARED=${LDSHARED-"cc -G"} ;; |
|
422
|
OpenUNIX\ 5) |
|
423
|
SFLAGS=${CFLAGS-"-KPIC -O"} |
|
424
|
CFLAGS=${CFLAGS-"-O"} |
|
425
|
LDSHARED=${LDSHARED-"cc -G"} ;; |
|
426
|
AIX*) # Courtesy of [email protected] |
|
427
|
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"} |
|
428
|
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"} |
|
429
|
LDSHARED=${LDSHARED-"xlc -G"} |
|
430
|
if test $build64 -eq 1; then |
|
431
|
CFLAGS="${CFLAGS} -q64" |
|
432
|
SFLAGS="${SFLAGS} -q64" |
|
433
|
ARFLAGS="-X64 ${ARFLAGS}" |
|
434
|
fi ;; |
|
435
|
# send working options for other systems to [email protected] |
|
436
|
*) SFLAGS=${CFLAGS-"-O"} |
|
437
|
CFLAGS=${CFLAGS-"-O"} |
|
438
|
LDSHARED=${LDSHARED-"cc -shared"} ;; |
|
439
|
esac |
|
440
|
fi |
|
441
|
|
|
442
|
# destination names for shared library if not defined above |
|
443
|
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"} |
|
444
|
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"} |
|
445
|
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"} |
|
446
|
|
|
447
|
echo >> configure.log |
|
448
|
|
|
449
|
# define functions for testing compiler and library characteristics and logging the results |
|
450
|
|
|
451
|
cat > $test.c <<EOF |
|
452
|
#error error |
|
453
|
EOF |
|
454
|
if ($CC -c $CFLAGS $test.c) 2>/dev/null; then |
|
455
|
try() |
|
456
|
{ |
|
457
|
show $* |
|
458
|
test "`( $* ) 2>&1 | tee -a configure.log`" = "" |
|
459
|
} |
|
460
|
echo - using any output from compiler to indicate an error >> configure.log |
|
461
|
else |
|
462
|
try() |
|
463
|
{ |
|
464
|
show $* |
|
465
|
got=`( $* ) 2>&1` |
|
466
|
ret=$? |
|
467
|
if test "$got" != ""; then |
|
468
|
printf "%s\n" "$got" >> configure.log |
|
469
|
fi |
|
470
|
if test $ret -ne 0; then |
|
471
|
echo "(exit code "$ret")" >> configure.log |
|
472
|
fi |
|
473
|
return $ret |
|
474
|
} |
|
475
|
fi |
|
476
|
|
|
477
|
tryboth() |
|
478
|
{ |
|
479
|
show $* |
|
480
|
got=`( $* ) 2>&1` |
|
481
|
ret=$? |
|
482
|
if test "$got" != ""; then |
|
483
|
printf "%s\n" "$got" >> configure.log |
|
484
|
fi |
|
485
|
if test $ret -ne 0; then |
|
486
|
echo "(exit code "$ret")" >> configure.log |
|
487
|
return $ret |
|
488
|
fi |
|
489
|
test "$got" = "" |
|
490
|
} |
|
491
|
|
|
492
|
cat > $test.c << EOF |
|
493
|
int foo() { return 0; } |
|
494
|
EOF |
|
495
|
echo "Checking for compiler..." >> configure.log |
|
496
|
if try $CC -c $test.c; then |
|
497
|
: |
|
498
|
else |
|
499
|
echo "Missing or broken C compiler." | tee -a configure.log |
|
500
|
leave 1 |
|
501
|
fi |
|
502
|
echo "Checking for obsessive-compulsive compiler options..." >> configure.log |
|
503
|
if try $CC -c $CFLAGS $test.c; then |
|
504
|
: |
|
505
|
else |
|
506
|
echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log |
|
507
|
leave 1 |
|
508
|
fi |
|
509
|
|
|
510
|
echo >> configure.log |
|
511
|
|
|
512
|
# see if shared library build supported |
|
513
|
cat > $test.c <<EOF |
|
514
|
extern int getchar(); |
|
515
|
int hello() {return getchar();} |
|
516
|
EOF |
|
517
|
if test $shared -eq 1; then |
|
518
|
echo Checking for shared library support... | tee -a configure.log |
|
519
|
# we must test in two steps (cc then ld), required at least on SunOS 4.x |
|
520
|
if try $CC -c $SFLAGS $test.c && |
|
521
|
try $LDSHARED $SFLAGS $LDFLAGS -o $test$shared_ext $test.o; then |
|
522
|
echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log |
|
523
|
elif test -z "$old_cc" -a -z "$old_cflags"; then |
|
524
|
echo No shared library support. | tee -a configure.log |
|
525
|
shared=0; |
|
526
|
else |
|
527
|
echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log |
|
528
|
shared=0; |
|
529
|
fi |
|
530
|
fi |
|
531
|
if test $shared -eq 0; then |
|
532
|
LDSHARED="$CC" |
|
533
|
ALL="static" |
|
534
|
TEST="all teststatic" |
|
535
|
SHAREDLIB="" |
|
536
|
SHAREDLIBV="" |
|
537
|
SHAREDLIBM="" |
|
538
|
echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log |
|
539
|
else |
|
540
|
ALL="static shared" |
|
541
|
TEST="all teststatic testshared" |
|
542
|
fi |
|
543
|
|
|
544
|
echo >> configure.log |
|
545
|
|
|
546
|
# check for size_t |
|
547
|
cat > $test.c <<EOF |
|
548
|
#include <stdio.h> |
|
549
|
#include <stdlib.h> |
|
550
|
size_t dummy = 0; |
|
551
|
EOF |
|
552
|
if try $CC -c $CFLAGS $test.c; then |
|
553
|
echo "Checking for size_t... Yes." | tee -a configure.log |
|
554
|
else |
|
555
|
echo "Checking for size_t... No." | tee -a configure.log |
|
556
|
# find a size_t integer type |
|
557
|
# check for long long |
|
558
|
cat > $test.c << EOF |
|
559
|
long long dummy = 0; |
|
560
|
EOF |
|
561
|
if try $CC -c $CFLAGS $test.c; then |
|
562
|
echo "Checking for long long... Yes." | tee -a configure.log |
|
563
|
cat > $test.c <<EOF |
|
564
|
#include <stdio.h> |
|
565
|
int main(void) { |
|
566
|
if (sizeof(void *) <= sizeof(int)) puts("int"); |
|
567
|
else if (sizeof(void *) <= sizeof(long)) puts("long"); |
|
568
|
else puts("z_longlong"); |
|
569
|
return 0; |
|
570
|
} |
|
571
|
EOF |
|
572
|
else |
|
573
|
echo "Checking for long long... No." | tee -a configure.log |
|
574
|
cat > $test.c <<EOF |
|
575
|
#include <stdio.h> |
|
576
|
int main(void) { |
|
577
|
if (sizeof(void *) <= sizeof(int)) puts("int"); |
|
578
|
else puts("long"); |
|
579
|
return 0; |
|
580
|
} |
|
581
|
EOF |
|
582
|
fi |
|
583
|
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then |
|
584
|
sizet=`./$test` |
|
585
|
echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log |
|
586
|
CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}" |
|
587
|
SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}" |
|
588
|
else |
|
589
|
echo "Checking for a pointer-size integer type... not found." | tee -a configure.log |
|
590
|
fi |
|
591
|
fi |
|
592
|
|
|
593
|
echo >> configure.log |
|
594
|
|
|
595
|
# check for large file support, and if none, check for fseeko() |
|
596
|
cat > $test.c <<EOF |
|
597
|
#include <sys/types.h> |
|
598
|
off64_t dummy = 0; |
|
599
|
EOF |
|
600
|
if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then |
|
601
|
CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1" |
|
602
|
SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1" |
|
603
|
ALL="${ALL} all64" |
|
604
|
TEST="${TEST} test64" |
|
605
|
echo "Checking for off64_t... Yes." | tee -a configure.log |
|
606
|
echo "Checking for fseeko... Yes." | tee -a configure.log |
|
607
|
else |
|
608
|
echo "Checking for off64_t... No." | tee -a configure.log |
|
609
|
echo >> configure.log |
|
610
|
cat > $test.c <<EOF |
|
611
|
#include <stdio.h> |
|
612
|
int main(void) { |
|
613
|
fseeko(NULL, 0, 0); |
|
614
|
return 0; |
|
615
|
} |
|
616
|
EOF |
|
617
|
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then |
|
618
|
echo "Checking for fseeko... Yes." | tee -a configure.log |
|
619
|
else |
|
620
|
CFLAGS="${CFLAGS} -DNO_FSEEKO" |
|
621
|
SFLAGS="${SFLAGS} -DNO_FSEEKO" |
|
622
|
echo "Checking for fseeko... No." | tee -a configure.log |
|
623
|
fi |
|
624
|
fi |
|
625
|
|
|
626
|
echo >> configure.log |
|
627
|
|
|
628
|
# check for strerror() for use by gz* functions |
|
629
|
cat > $test.c <<EOF |
|
630
|
#include <string.h> |
|
631
|
#include <errno.h> |
|
632
|
int main() { return strlen(strerror(errno)); } |
|
633
|
EOF |
|
634
|
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then |
|
635
|
echo "Checking for strerror... Yes." | tee -a configure.log |
|
636
|
else |
|
637
|
CFLAGS="${CFLAGS} -DNO_STRERROR" |
|
638
|
SFLAGS="${SFLAGS} -DNO_STRERROR" |
|
639
|
echo "Checking for strerror... No." | tee -a configure.log |
|
640
|
fi |
|
641
|
|
|
642
|
# copy clean zconf.h for subsequent edits |
|
643
|
cp -p ${SRCDIR}zconf.h.in zconf.h |
|
644
|
|
|
645
|
echo >> configure.log |
|
646
|
|
|
647
|
# check for unistd.h and save result in zconf.h |
|
648
|
cat > $test.c <<EOF |
|
649
|
#include <unistd.h> |
|
650
|
int main() { return 0; } |
|
651
|
EOF |
|
652
|
if try $CC -c $CFLAGS $test.c; then |
|
653
|
sed < zconf.h "/^#if HAVE_UNISTD_H-0.* may be/s/ HAVE_UNISTD_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h |
|
654
|
mv zconf.temp.h zconf.h |
|
655
|
echo "Checking for unistd.h... Yes." | tee -a configure.log |
|
656
|
else |
|
657
|
echo "Checking for unistd.h... No." | tee -a configure.log |
|
658
|
fi |
|
659
|
|
|
660
|
echo >> configure.log |
|
661
|
|
|
662
|
# check for stdarg.h and save result in zconf.h |
|
663
|
cat > $test.c <<EOF |
|
664
|
#include <stdarg.h> |
|
665
|
int main() { return 0; } |
|
666
|
EOF |
|
667
|
if try $CC -c $CFLAGS $test.c; then |
|
668
|
sed < zconf.h "/^#if HAVE_STDARG_H-0.* may be/s/ HAVE_STDARG_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h |
|
669
|
mv zconf.temp.h zconf.h |
|
670
|
echo "Checking for stdarg.h... Yes." | tee -a configure.log |
|
671
|
else |
|
672
|
echo "Checking for stdarg.h... No." | tee -a configure.log |
|
673
|
fi |
|
674
|
|
|
675
|
# if the z_ prefix was requested, save that in zconf.h |
|
676
|
if test $zprefix -eq 1; then |
|
677
|
sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h |
|
678
|
mv zconf.temp.h zconf.h |
|
679
|
echo >> configure.log |
|
680
|
echo "Using z_ prefix on all symbols." | tee -a configure.log |
|
681
|
fi |
|
682
|
|
|
683
|
# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists |
|
684
|
if test $solo -eq 1; then |
|
685
|
sed '/#define ZCONF_H/a\ |
|
686
|
#define Z_SOLO |
|
687
|
|
|
688
|
' < zconf.h > zconf.temp.h |
|
689
|
mv zconf.temp.h zconf.h |
|
690
|
OBJC='$(OBJZ)' |
|
691
|
PIC_OBJC='$(PIC_OBJZ)' |
|
692
|
fi |
|
693
|
|
|
694
|
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X |
|
695
|
if test $cover -eq 1; then |
|
696
|
if test -n "$GCC_CLASSIC"; then |
|
697
|
CC=$GCC_CLASSIC |
|
698
|
fi |
|
699
|
fi |
|
700
|
|
|
701
|
echo >> configure.log |
|
702
|
|
|
703
|
# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions |
|
704
|
# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a |
|
705
|
# return value. The most secure result is vsnprintf() with a return value. snprintf() with a |
|
706
|
# return value is secure as well, but then gzprintf() will be limited to 20 arguments. |
|
707
|
cat > $test.c <<EOF |
|
708
|
#include <stdio.h> |
|
709
|
#include <stdarg.h> |
|
710
|
#include "zconf.h" |
|
711
|
int main() |
|
712
|
{ |
|
713
|
#ifndef STDC |
|
714
|
choke me |
|
715
|
#endif |
|
716
|
return 0; |
|
717
|
} |
|
718
|
EOF |
|
719
|
if try $CC -c $CFLAGS $test.c; then |
|
720
|
echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log |
|
721
|
|
|
722
|
echo >> configure.log |
|
723
|
cat > $test.c <<EOF |
|
724
|
#include <stdio.h> |
|
725
|
#include <stdarg.h> |
|
726
|
int mytest(const char *fmt, ...) |
|
727
|
{ |
|
728
|
char buf[20]; |
|
729
|
va_list ap; |
|
730
|
va_start(ap, fmt); |
|
731
|
vsnprintf(buf, sizeof(buf), fmt, ap); |
|
732
|
va_end(ap); |
|
733
|
return 0; |
|
734
|
} |
|
735
|
int main() |
|
736
|
{ |
|
737
|
return (mytest("Hello%d\n", 1)); |
|
738
|
} |
|
739
|
EOF |
|
740
|
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then |
|
741
|
echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log |
|
742
|
|
|
743
|
echo >> configure.log |
|
744
|
cat >$test.c <<EOF |
|
745
|
#include <stdio.h> |
|
746
|
#include <stdarg.h> |
|
747
|
int mytest(const char *fmt, ...) |
|
748
|
{ |
|
749
|
int n; |
|
750
|
char buf[20]; |
|
751
|
va_list ap; |
|
752
|
va_start(ap, fmt); |
|
753
|
n = vsnprintf(buf, sizeof(buf), fmt, ap); |
|
754
|
va_end(ap); |
|
755
|
return n; |
|
756
|
} |
|
757
|
int main() |
|
758
|
{ |
|
759
|
return (mytest("Hello%d\n", 1)); |
|
760
|
} |
|
761
|
EOF |
|
762
|
|
|
763
|
if try $CC -c $CFLAGS $test.c; then |
|
764
|
echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log |
|
765
|
else |
|
766
|
CFLAGS="$CFLAGS -DHAS_vsnprintf_void" |
|
767
|
SFLAGS="$SFLAGS -DHAS_vsnprintf_void" |
|
768
|
echo "Checking for return value of vsnprintf()... No." | tee -a configure.log |
|
769
|
echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log |
|
770
|
echo " can build but will be open to possible string-format security" | tee -a configure.log |
|
771
|
echo " vulnerabilities." | tee -a configure.log |
|
772
|
fi |
|
773
|
else |
|
774
|
CFLAGS="$CFLAGS -DNO_vsnprintf" |
|
775
|
SFLAGS="$SFLAGS -DNO_vsnprintf" |
|
776
|
echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log |
|
777
|
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log |
|
778
|
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log |
|
779
|
echo " vulnerabilities." | tee -a configure.log |
|
780
|
if test $insecure -ne 1; then |
|
781
|
echo " The --insecure option must be provided to ./configure in order to" | tee -a configure.log |
|
782
|
echo " compile using the insecure vsprintf() function." | tee -a configure.log |
|
783
|
fi |
|
784
|
echo >> configure.log |
|
785
|
cat >$test.c <<EOF |
|
786
|
#include <stdio.h> |
|
787
|
#include <stdarg.h> |
|
788
|
int mytest(const char *fmt, ...) |
|
789
|
{ |
|
790
|
int n; |
|
791
|
char buf[20]; |
|
792
|
va_list ap; |
|
793
|
va_start(ap, fmt); |
|
794
|
n = vsprintf(buf, fmt, ap); |
|
795
|
va_end(ap); |
|
796
|
return n; |
|
797
|
} |
|
798
|
int main() |
|
799
|
{ |
|
800
|
return (mytest("Hello%d\n", 1)); |
|
801
|
} |
|
802
|
EOF |
|
803
|
|
|
804
|
if try $CC -c $CFLAGS $test.c; then |
|
805
|
echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log |
|
806
|
else |
|
807
|
CFLAGS="$CFLAGS -DHAS_vsprintf_void" |
|
808
|
SFLAGS="$SFLAGS -DHAS_vsprintf_void" |
|
809
|
echo "Checking for return value of vsprintf()... No." | tee -a configure.log |
|
810
|
echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log |
|
811
|
echo " can build but will be open to possible string-format security" | tee -a configure.log |
|
812
|
echo " vulnerabilities." | tee -a configure.log |
|
813
|
fi |
|
814
|
fi |
|
815
|
else |
|
816
|
echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log |
|
817
|
|
|
818
|
echo >> configure.log |
|
819
|
cat >$test.c <<EOF |
|
820
|
#include <stdio.h> |
|
821
|
int mytest() |
|
822
|
{ |
|
823
|
char buf[20]; |
|
824
|
snprintf(buf, sizeof(buf), "%s", "foo"); |
|
825
|
return 0; |
|
826
|
} |
|
827
|
int main() |
|
828
|
{ |
|
829
|
return (mytest()); |
|
830
|
} |
|
831
|
EOF |
|
832
|
|
|
833
|
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then |
|
834
|
echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log |
|
835
|
|
|
836
|
echo >> configure.log |
|
837
|
cat >$test.c <<EOF |
|
838
|
#include <stdio.h> |
|
839
|
int mytest() |
|
840
|
{ |
|
841
|
char buf[20]; |
|
842
|
return snprintf(buf, sizeof(buf), "%s", "foo"); |
|
843
|
} |
|
844
|
int main() |
|
845
|
{ |
|
846
|
return (mytest()); |
|
847
|
} |
|
848
|
EOF |
|
849
|
|
|
850
|
if try $CC -c $CFLAGS $test.c; then |
|
851
|
echo "Checking for return value of snprintf()... Yes." | tee -a configure.log |
|
852
|
else |
|
853
|
CFLAGS="$CFLAGS -DHAS_snprintf_void" |
|
854
|
SFLAGS="$SFLAGS -DHAS_snprintf_void" |
|
855
|
echo "Checking for return value of snprintf()... No." | tee -a configure.log |
|
856
|
echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log |
|
857
|
echo " can build but will be open to possible string-format security" | tee -a configure.log |
|
858
|
echo " vulnerabilities." | tee -a configure.log |
|
859
|
fi |
|
860
|
else |
|
861
|
CFLAGS="$CFLAGS -DNO_snprintf" |
|
862
|
SFLAGS="$SFLAGS -DNO_snprintf" |
|
863
|
echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log |
|
864
|
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log |
|
865
|
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log |
|
866
|
echo " vulnerabilities." | tee -a configure.log |
|
867
|
if test $insecure -ne 1; then |
|
868
|
echo " The --insecure option must be provided to ./configure in order to" | tee -a configure.log |
|
869
|
echo " compile using the insecure sprintf() function." | tee -a configure.log |
|
870
|
fi |
|
871
|
echo >> configure.log |
|
872
|
cat >$test.c <<EOF |
|
873
|
#include <stdio.h> |
|
874
|
int mytest() |
|
875
|
{ |
|
876
|
char buf[20]; |
|
877
|
return sprintf(buf, "%s", "foo"); |
|
878
|
} |
|
879
|
int main() |
|
880
|
{ |
|
881
|
return (mytest()); |
|
882
|
} |
|
883
|
EOF |
|
884
|
|
|
885
|
if try $CC -c $CFLAGS $test.c; then |
|
886
|
echo "Checking for return value of sprintf()... Yes." | tee -a configure.log |
|
887
|
else |
|
888
|
CFLAGS="$CFLAGS -DHAS_sprintf_void" |
|
889
|
SFLAGS="$SFLAGS -DHAS_sprintf_void" |
|
890
|
echo "Checking for return value of sprintf()... No." | tee -a configure.log |
|
891
|
echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log |
|
892
|
echo " can build but will be open to possible string-format security" | tee -a configure.log |
|
893
|
echo " vulnerabilities." | tee -a configure.log |
|
894
|
fi |
|
895
|
fi |
|
896
|
fi |
|
897
|
|
|
898
|
# see if we can hide zlib internal symbols that are linked between separate source files |
|
899
|
if test "$gcc" -eq 1; then |
|
900
|
echo >> configure.log |
|
901
|
cat > $test.c <<EOF |
|
902
|
#define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) |
|
903
|
int ZLIB_INTERNAL foo; |
|
904
|
int main() |
|
905
|
{ |
|
906
|
return 0; |
|
907
|
} |
|
908
|
EOF |
|
909
|
if tryboth $CC -c $CFLAGS $test.c; then |
|
910
|
CFLAGS="$CFLAGS -DHAVE_HIDDEN" |
|
911
|
SFLAGS="$SFLAGS -DHAVE_HIDDEN" |
|
912
|
echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log |
|
913
|
else |
|
914
|
echo "Checking for attribute(visibility) support... No." | tee -a configure.log |
|
915
|
fi |
|
916
|
fi |
|
917
|
|
|
918
|
# check for ibm s390x build |
|
919
|
HAVE_S390X=0 |
|
920
|
cat > $test.c << EOF |
|
921
|
#ifndef __s390x__ |
|
922
|
#error |
|
923
|
#endif |
|
924
|
EOF |
|
925
|
if try $CC -c $CFLAGS $test.c; then |
|
926
|
echo "Checking for s390x build ... Yes." | tee -a configure.log |
|
927
|
HAVE_S390X=1 |
|
928
|
else |
|
929
|
echo "Checking for s390x build ... No." | tee -a configure.log |
|
930
|
fi |
|
931
|
|
|
932
|
# check for ibm s390x vx vector extensions |
|
933
|
HAVE_S390X_VX=0 |
|
934
|
if test $HAVE_S390X -eq 1 && test $enable_crcvx -eq 1 ; then |
|
935
|
# preset the compiler specific flags |
|
936
|
if test $clang -eq 1; then |
|
937
|
VGFMAFLAG=-fzvector |
|
938
|
else |
|
939
|
VGFMAFLAG=-mzarch |
|
940
|
fi |
|
941
|
|
|
942
|
cat > $test.c <<EOF |
|
943
|
#ifndef __s390x__ |
|
944
|
#error |
|
945
|
#endif |
|
946
|
#include <vecintrin.h> |
|
947
|
int main(void) { |
|
948
|
unsigned long long a __attribute__((vector_size(16))) = { 0 }; |
|
949
|
unsigned long long b __attribute__((vector_size(16))) = { 0 }; |
|
950
|
unsigned char c __attribute__((vector_size(16))) = { 0 }; |
|
951
|
c = vec_gfmsum_accum_128(a, b, c); |
|
952
|
return c[0]; |
|
953
|
} |
|
954
|
EOF |
|
955
|
|
|
956
|
# cflags already contains a valid march |
|
957
|
if try $CC -c $CFLAGS $VGFMAFLAG $test.c; then |
|
958
|
echo "Checking for s390x vx vector extension ... Yes." | tee -a configure.log |
|
959
|
HAVE_S390X_VX=1 |
|
960
|
# or set march for our compile units |
|
961
|
elif try $CC -c $CFLAGS $VGFMAFLAG -march=z13 $test.c; then |
|
962
|
echo "Checking for s390x vx vector extension (march=z13) ... Yes." | tee -a configure.log |
|
963
|
HAVE_S390X_VX=1 |
|
964
|
VGFMAFLAG="$VGFMAFLAG -march=z13" |
|
965
|
# else we are not on s390x |
|
966
|
else |
|
967
|
echo "Checking for s390x vx vector extension ... No." | tee -a configure.log |
|
968
|
fi |
|
969
|
|
|
970
|
# prepare compiling for s390x |
|
971
|
if test $HAVE_S390X_VX -eq 1; then |
|
972
|
CFLAGS="$CFLAGS -DHAVE_S390X_VX" |
|
973
|
SFLAGS="$SFLAGS -DHAVE_S390X_VX" |
|
974
|
OBJC="$OBJC crc32_vx.o" |
|
975
|
PIC_OBJC="$PIC_OBJC crc32_vx.lo" |
|
976
|
else |
|
977
|
# target has no vx extension |
|
978
|
VGFMAFLAG="" |
|
979
|
fi |
|
980
|
fi |
|
981
|
|
|
982
|
# show the results in the log |
|
983
|
echo >> configure.log |
|
984
|
echo ALL = $ALL >> configure.log |
|
985
|
echo AR = $AR >> configure.log |
|
986
|
echo ARFLAGS = $ARFLAGS >> configure.log |
|
987
|
echo CC = $CC >> configure.log |
|
988
|
echo CFLAGS = $CFLAGS >> configure.log |
|
989
|
echo CPP = $CPP >> configure.log |
|
990
|
echo EXE = $EXE >> configure.log |
|
991
|
echo LDCONFIG = $LDCONFIG >> configure.log |
|
992
|
echo LDFLAGS = $LDFLAGS >> configure.log |
|
993
|
echo LDSHARED = $LDSHARED >> configure.log |
|
994
|
echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log |
|
995
|
echo OBJC = $OBJC >> configure.log |
|
996
|
echo PIC_OBJC = $PIC_OBJC >> configure.log |
|
997
|
echo RANLIB = $RANLIB >> configure.log |
|
998
|
echo SFLAGS = $SFLAGS >> configure.log |
|
999
|
echo SHAREDLIB = $SHAREDLIB >> configure.log |
|
1000
|
echo SHAREDLIBM = $SHAREDLIBM >> configure.log |
|
1001
|
echo SHAREDLIBV = $SHAREDLIBV >> configure.log |
|
1002
|
echo STATICLIB = $STATICLIB >> configure.log |
|
1003
|
echo TEST = $TEST >> configure.log |
|
1004
|
echo VER = $VER >> configure.log |
|
1005
|
echo SRCDIR = $SRCDIR >> configure.log |
|
1006
|
echo exec_prefix = $exec_prefix >> configure.log |
|
1007
|
echo includedir = $includedir >> configure.log |
|
1008
|
echo libdir = $libdir >> configure.log |
|
1009
|
echo mandir = $mandir >> configure.log |
|
1010
|
echo prefix = $prefix >> configure.log |
|
1011
|
echo sharedlibdir = $sharedlibdir >> configure.log |
|
1012
|
echo uname = $uname >> configure.log |
|
1013
|
echo HAVE_S390X = $HAVE_S390X >> configure.log |
|
1014
|
echo HAVE_S390X_VX = $HAVE_S390X_VX >> configure.log |
|
1015
|
echo VGFMAFLAG = $VGFMAFLAG >> configure.log |
|
1016
|
|
|
1017
|
# update Makefile with the configure results |
|
1018
|
sed < ${SRCDIR}Makefile.in " |
|
1019
|
/^CC *=/s#=.*#=$CC# |
|
1020
|
/^GCOV *=/s#=.*#=$GCOV# |
|
1021
|
/^LLVM_GCOV_FLAG *=/s#=.*#=$LLVM_GCOV_FLAG# |
|
1022
|
/^CFLAGS *=/s#=.*#=$CFLAGS# |
|
1023
|
/^SFLAGS *=/s#=.*#=$SFLAGS# |
|
1024
|
/^LDFLAGS *=/s#=.*#=$LDFLAGS# |
|
1025
|
/^LDSHARED *=/s#=.*#=$LDSHARED# |
|
1026
|
/^CPP *=/s#=.*#=$CPP# |
|
1027
|
/^STATICLIB *=/s#=.*#=$STATICLIB# |
|
1028
|
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB# |
|
1029
|
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# |
|
1030
|
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# |
|
1031
|
/^AR *=/s#=.*#=$AR# |
|
1032
|
/^ARFLAGS *=/s#=.*#=$ARFLAGS# |
|
1033
|
/^RANLIB *=/s#=.*#=$RANLIB# |
|
1034
|
/^LDCONFIG *=/s#=.*#=$LDCONFIG# |
|
1035
|
/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC# |
|
1036
|
/^EXE *=/s#=.*#=$EXE# |
|
1037
|
/^SRCDIR *=/s#=.*#=$SRCDIR# |
|
1038
|
/^ZINC *=/s#=.*#=$ZINC# |
|
1039
|
/^ZINCOUT *=/s#=.*#=$ZINCOUT# |
|
1040
|
/^prefix *=/s#=.*#=$prefix# |
|
1041
|
/^exec_prefix *=/s#=.*#=$exec_prefix# |
|
1042
|
/^libdir *=/s#=.*#=$libdir# |
|
1043
|
/^sharedlibdir *=/s#=.*#=$sharedlibdir# |
|
1044
|
/^includedir *=/s#=.*#=$includedir# |
|
1045
|
/^mandir *=/s#=.*#=$mandir# |
|
1046
|
/^OBJC *=/s#=.*#= $OBJC# |
|
1047
|
/^PIC_OBJC *=/s#=.*#= $PIC_OBJC# |
|
1048
|
/^all: */s#:.*#: $ALL# |
|
1049
|
/^test: */s#:.*#: $TEST# |
|
1050
|
" > Makefile |
|
1051
|
|
|
1052
|
# create zlib.pc with the configure results |
|
1053
|
sed < ${SRCDIR}zlib.pc.in " |
|
1054
|
/^CC *=/s#=.*#=$CC# |
|
1055
|
/^CFLAGS *=/s#=.*#=$CFLAGS# |
|
1056
|
/^CPP *=/s#=.*#=$CPP# |
|
1057
|
/^LDSHARED *=/s#=.*#=$LDSHARED# |
|
1058
|
/^STATICLIB *=/s#=.*#=$STATICLIB# |
|
1059
|
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB# |
|
1060
|
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# |
|
1061
|
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# |
|
1062
|
/^AR *=/s#=.*#=$AR# |
|
1063
|
/^ARFLAGS *=/s#=.*#=$ARFLAGS# |
|
1064
|
/^RANLIB *=/s#=.*#=$RANLIB# |
|
1065
|
/^EXE *=/s#=.*#=$EXE# |
|
1066
|
/^prefix *=/s#=.*#=$prefix# |
|
1067
|
/^exec_prefix *=/s#=.*#=$exec_prefix# |
|
1068
|
/^libdir *=/s#=.*#=$libdir# |
|
1069
|
/^sharedlibdir *=/s#=.*#=$sharedlibdir# |
|
1070
|
/^includedir *=/s#=.*#=$includedir# |
|
1071
|
/^mandir *=/s#=.*#=$mandir# |
|
1072
|
/^LDFLAGS *=/s#=.*#=$LDFLAGS# |
|
1073
|
" | sed -e " |
|
1074
|
s/\@VERSION\@/$VER/g; |
|
1075
|
" > zlib.pc |
|
1076
|
|
|
1077
|
# done |
|
1078
|
leave 0 |
|
1079
|
|