# set command prefix for cross-compilation
if [ -n "${CHOST}" ]; then
- uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
+ uname=${CHOST}
+ mname=${CHOST}
CROSS_PREFIX="${CHOST}-"
+else
+ mname=`(uname -a || echo unknown) 2>/dev/null`
fi
# destination name for static library
gcc=0
warn=0
debug=0
+sanitize=0
old_cc="$CC"
old_cflags="$CFLAGS"
OBJC='$(OBJZ) $(OBJG)'
-c* | --const) zconst=1; shift ;;
-w* | --warn) warn=1; shift ;;
-d* | --debug) debug=1; shift ;;
+ --sanitize) sanitize=1; shift ;;
*)
echo "unknown option: $1" | tee -a configure.log
echo "$0 --help for help" | tee -a configure.log
int hello() {return getchar();}
EOF
-test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
-cc=${CC-${CROSS_PREFIX}gcc}
-cflags=${CFLAGS-"-O3"}
-# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
+if test -z "$CC"; then
+ echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
+ if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then
+ cc=${CROSS_PREFIX}gcc
+ else
+ cc=${CROSS_PREFIX}cc
+ fi
+else
+ cc=${CC}
+fi
+
case "$cc" in
*gcc*) gcc=1 ;;
*clang*) gcc=1 ;;
fi
if test "$warn" -eq 1; then
if test "$zconst" -eq 1; then
- CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST"
+ CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST"
else
- CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
+ CFLAGS="${CFLAGS} -Wall -Wextra"
fi
fi
+ if test $sanitize -eq 1; then
+ CFLAGS="${CFLAGS} -g -fsanitize=address"
+ fi
if test $debug -eq 1; then
CFLAGS="${CFLAGS} -DZLIB_DEBUG"
SFLAGS="${SFLAGS} -DZLIB_DEBUG"
uname=`(uname -s || echo unknown) 2>/dev/null`
fi
case "$uname" in
- Linux* | linux* | GNU | GNU/* | solaris*)
+ Linux* | linux* | *-linux* | GNU | GNU/* | solaris*)
+ case "$mname" in
+ *sparc*)
+ LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
+ esac
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
*BSD | *bsd* | DragonFly)
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
LDCONFIG="ldconfig -m" ;;
- CYGWIN* | Cygwin* | cygwin* | OS/2*)
+ CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*)
EXE='.exe' ;;
- MINGW* | mingw*)
-# temporary bypass
+ MINGW* | mingw* | *-mingw*)
rm -f $test.[co] $test $test$shared_ext
- echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
- leave 1
+ echo "If this doesn't work for you, try win32/Makefile.gcc." | tee -a configure.log
LDSHARED=${LDSHARED-"$cc -shared"}
LDSHAREDLIBC=""
EXE='.exe' ;;
- QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
- # (alain.bonnefoy@icbt.com)
- LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
+ QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
+ # (alain.bonnefoy@icbt.com)
+ LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
HP-UX*)
- LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
- case `(uname -m || echo unknown) 2>/dev/null` in
- ia64)
- shared_ext='.so'
- SHAREDLIB='libz.so' ;;
- *)
- shared_ext='.sl'
- SHAREDLIB='libz.sl' ;;
- esac ;;
- Darwin* | darwin*)
- shared_ext='.dylib'
- SHAREDLIB=libz$shared_ext
- SHAREDLIBV=libz.$VER$shared_ext
- SHAREDLIBM=libz.$VER1$shared_ext
- LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
- if libtool -V 2>&1 | grep Apple > /dev/null; then
- AR="libtool"
- else
- AR="/usr/bin/libtool"
- fi
- ARFLAGS="-o" ;;
- *) LDSHARED=${LDSHARED-"$cc -shared"} ;;
+ LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
+ case `(uname -m || echo unknown) 2>/dev/null` in
+ ia64)
+ shared_ext='.so'
+ SHAREDLIB='libz.so' ;;
+ *)
+ shared_ext='.sl'
+ SHAREDLIB='libz.sl' ;;
+ esac ;;
+ AIX*)
+ LDFLAGS="${LDFLAGS} -Wl,-brtl" ;;
+ Darwin* | darwin* | *-darwin*)
+ shared_ext='.dylib'
+ SHAREDLIB=libz$shared_ext
+ SHAREDLIBV=libz.$VER$shared_ext
+ SHAREDLIBM=libz.$VER1$shared_ext
+ LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
+ if libtool -V 2>&1 | grep Apple > /dev/null; then
+ AR="libtool"
+ else
+ AR="/usr/bin/libtool"
+ fi
+ ARFLAGS="-o" ;;
+ *)
+ LDSHARED=${LDSHARED-"$cc -shared"} ;;
esac
else
# find system name and corresponding cc options
try()
{
show $*
- ( $* ) >> configure.log 2>&1
+ got=`( $* ) 2>&1`
ret=$?
+ if test "$got" != ""; then
+ printf "%s\n" "$got" >> configure.log
+ fi
if test $ret -ne 0; then
echo "(exit code "$ret")" >> configure.log
fi
show $*
got=`( $* ) 2>&1`
ret=$?
- printf %s "$got" >> configure.log
+ if test "$got" != ""; then
+ printf "%s\n" "$got" >> configure.log
+ fi
if test $ret -ne 0; then
+ echo "(exit code "$ret")" >> configure.log
return $ret
fi
test "$got" = ""
TEST="all teststatic testshared"
fi
-# check for underscores in external names for use by assembler code
-CPP=${CPP-"$CC -E"}
-case $CFLAGS in
- *ASMV*)
- echo >> configure.log
- show "$NM $test.o | grep _hello"
- if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
- CPP="$CPP -DNO_UNDERLINE"
- echo Checking for underline in external names... No. | tee -a configure.log
- else
- echo Checking for underline in external names... Yes. | tee -a configure.log
- fi ;;
-esac
-
echo >> configure.log
# check for size_t
EOF
if try $CC -c $CFLAGS $test.c; then
echo "Checking for size_t... Yes." | tee -a configure.log
- need_sizet=0
else
echo "Checking for size_t... No." | tee -a configure.log
- need_sizet=1
-fi
-
-echo >> configure.log
-
-# find the size_t integer type, if needed
-if test $need_sizet -eq 1; then
- cat > $test.c <<EOF
+ # find a size_t integer type
+ # check for long long
+ cat > $test.c << EOF
long long dummy = 0;
EOF
if try $CC -c $CFLAGS $test.c; then
if try $CC $CFLAGS -o $test $test.c; then
sizet=`./$test`
echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
+ CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
+ SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
else
- echo "Failed to find a pointer-size integer type." | tee -a configure.log
- leave 1
+ echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
fi
fi
-if test $need_sizet -eq 1; then
- CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
- SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
-fi
-
echo >> configure.log
# check for large file support, and if none, check for fseeko()
echo STATICLIB = $STATICLIB >> configure.log
echo TEST = $TEST >> configure.log
echo VER = $VER >> configure.log
-echo Z_U4 = $Z_U4 >> configure.log
echo SRCDIR = $SRCDIR >> configure.log
echo exec_prefix = $exec_prefix >> configure.log
echo includedir = $includedir >> configure.log