mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 19:12:03 +00:00
924 lines
28 KiB
Bash
Executable File
924 lines
28 KiB
Bash
Executable File
#!/bin/sh
|
|
# configure script for zlib.
|
|
#
|
|
# Normally configure builds both a static and a shared library.
|
|
# If you want to build just a static library, use: ./configure --static
|
|
#
|
|
# To impose specific compiler or flags or install directory, use for example:
|
|
# prefix=$HOME CC=cc CFLAGS="-O4" ./configure
|
|
# or for csh/tcsh users:
|
|
# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
|
|
|
|
# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
|
|
# If you have problems, try without defining CC and CFLAGS before reporting
|
|
# an error.
|
|
|
|
# start off configure.log
|
|
echo -------------------- >> configure.log
|
|
echo $0 $* >> configure.log
|
|
date >> configure.log
|
|
|
|
SRCDIR=$(cd $(dirname $0); pwd)
|
|
BUILDDIR=$(pwd)
|
|
|
|
# set command prefix for cross-compilation
|
|
if [ -n "${CHOST}" ]; then
|
|
uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
|
|
CROSS_PREFIX="${CHOST}-"
|
|
ARCH="`echo "${CHOST}" | sed -e 's/-.*//'`"
|
|
else
|
|
ARCH="`uname -m`"
|
|
fi
|
|
|
|
case "${ARCH}" in
|
|
x86_64)
|
|
case "${CFLAGS}" in
|
|
*-m32*)
|
|
ARCH=i686
|
|
;;
|
|
esac
|
|
;;
|
|
i386 | i486 | i586 | i686)
|
|
case "${CFLAGS}" in
|
|
*-m64*)
|
|
ARCH=x86_64
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
# destination name for static library
|
|
STATICLIB=libz.a
|
|
|
|
# destination name for windows import library
|
|
IMPORTLIB=
|
|
|
|
# extract zlib version numbers from zlib.h
|
|
VER=`sed -n -e '/ZLIB_VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}/zlib.h`
|
|
VER3=`sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}/zlib.h`
|
|
VER2=`sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}/zlib.h`
|
|
VER1=`sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}/zlib.h`
|
|
|
|
# establish commands for library building
|
|
if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
|
|
AR=${AR-"${CROSS_PREFIX}ar"}
|
|
test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
|
|
else
|
|
AR=${AR-"ar"}
|
|
test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
|
|
fi
|
|
ARFLAGS=${ARFLAGS-"rc"}
|
|
if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
|
|
RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
|
|
test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
|
|
else
|
|
RANLIB=${RANLIB-"ranlib"}
|
|
fi
|
|
if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
|
|
NM=${NM-"${CROSS_PREFIX}nm"}
|
|
test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
|
|
else
|
|
NM=${NM-"nm"}
|
|
fi
|
|
|
|
# set defaults before processing command line options
|
|
LDCONFIG=${LDCONFIG-"ldconfig"}
|
|
LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
|
|
DEFFILE=
|
|
RC=
|
|
RCFLAGS=
|
|
RCOBJS=
|
|
STRIP=
|
|
ARCHS=
|
|
prefix=${prefix-/usr/local}
|
|
exec_prefix=${exec_prefix-'${prefix}'}
|
|
bindir=${bindir-'${exec_prefix}/bin'}
|
|
libdir=${libdir-'${exec_prefix}/lib'}
|
|
sharedlibdir=${sharedlibdir-'${libdir}'}
|
|
includedir=${includedir-'${prefix}/include'}
|
|
mandir=${mandir-'${prefix}/share/man'}
|
|
shared_ext='.so'
|
|
shared=1
|
|
gzfileops=0
|
|
compat=0
|
|
cover=0
|
|
build32=0
|
|
build64=0
|
|
without_optimizations=0
|
|
without_new_strategies=0
|
|
gcc=0
|
|
old_cc="$CC"
|
|
old_cflags="$CFLAGS"
|
|
OBJC='$(OBJZ)'
|
|
PIC_OBJC='$(PIC_OBJZ)'
|
|
INSTALLTARGETS="install-shared install-static"
|
|
UNINSTALLTARGETS="uninstall-shared uninstall-static"
|
|
|
|
TEST="teststatic"
|
|
|
|
# leave this script, optionally in a bad way
|
|
leave()
|
|
{
|
|
if test "$*" != "0"; then
|
|
echo "** $0 aborting." | tee -a configure.log
|
|
fi
|
|
rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
|
|
echo -------------------- >> configure.log
|
|
echo >> configure.log
|
|
echo >> configure.log
|
|
exit $1
|
|
}
|
|
|
|
# process command line options
|
|
while test $# -ge 1
|
|
do
|
|
case "$1" in
|
|
-h* | --help)
|
|
echo 'usage:' | tee -a configure.log
|
|
echo ' configure [--zlib-compat] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
|
|
echo ' [--static] [--32] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
|
|
echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
|
|
exit 0 ;;
|
|
-p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
|
|
-e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
|
|
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
|
|
--sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
|
|
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
|
|
-u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
|
|
-p* | --prefix) prefix="$2"; shift; shift ;;
|
|
-e* | --eprefix) exec_prefix="$2"; shift; shift ;;
|
|
-l* | --libdir) libdir="$2"; shift; shift ;;
|
|
-i* | --includedir) includedir="$2"; shift; shift ;;
|
|
-s* | --shared | --enable-shared) shared=1; shift ;;
|
|
-t | --static) shared=0; shift ;;
|
|
--zlib-compat) compat=1; shift ;;
|
|
--cover) cover=1; shift ;;
|
|
-3* | --32) build32=1; shift ;;
|
|
-6* | --64) build64=1; shift ;;
|
|
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
|
|
--sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
|
|
--localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
|
|
-noopt | --without-optimizations) without_optimizations=1; shift;;
|
|
-oldstrat | --without-new-strategies) without_new_strategies=1; shift;;
|
|
*)
|
|
echo "unknown option: $1" | tee -a configure.log
|
|
echo "$0 --help for help" | tee -a configure.log
|
|
leave 1;;
|
|
esac
|
|
done
|
|
|
|
# temporary file name
|
|
test=ztest$$
|
|
|
|
# put arguments in log, also put test file in log if used in arguments
|
|
show()
|
|
{
|
|
case "$*" in
|
|
*$test.c*)
|
|
echo === $test.c === >> configure.log
|
|
cat $test.c >> configure.log
|
|
echo === >> configure.log;;
|
|
esac
|
|
echo $* >> configure.log
|
|
}
|
|
|
|
# check for gcc vs. cc and set compile and link flags based on the system identified by uname
|
|
cat > $test.c <<EOF
|
|
extern int getchar();
|
|
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"}
|
|
case "$cc" in
|
|
*gcc*) gcc=1 ;;
|
|
*clang*) gcc=1 ;;
|
|
esac
|
|
case `$cc -v 2>&1` in
|
|
*gcc*) gcc=1 ;;
|
|
esac
|
|
|
|
show $cc -c $test.c
|
|
if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
|
|
echo ... using gcc >> configure.log
|
|
CC="$cc"
|
|
# Re-check arch if gcc is a cross-compiler
|
|
GCC_ARCH=`$CC -dumpmachine | sed 's/-.*//g'`
|
|
case $GCC_ARCH in
|
|
i386 | i486 | i586 | i686)
|
|
# Honor user choice if gcc is multilib and 64-bit is requested
|
|
if test $build64 -eq 1; then
|
|
ARCH=x86_64
|
|
else
|
|
ARCH=$GCC_ARCH
|
|
fi ;;
|
|
# Honor user choice if gcc is multilib and 32-bit is requested
|
|
x86_64)
|
|
if test $build32 -ne 1; then
|
|
ARCH=$GCC_ARCH
|
|
fi ;;
|
|
esac
|
|
CFLAGS="${CFLAGS--O3} ${ARCHS} -Wall"
|
|
SFLAGS="${CFLAGS--O3} -fPIC"
|
|
LDFLAGS="${LDFLAGS} ${ARCHS}"
|
|
if test $build64 -eq 1; then
|
|
CFLAGS="${CFLAGS} -m64"
|
|
SFLAGS="${SFLAGS} -m64"
|
|
fi
|
|
if test "${ZLIBGCCWARN}" = "YES"; then
|
|
CFLAGS="${CFLAGS} -Wextra -pedantic"
|
|
fi
|
|
if test -z "$uname"; then
|
|
uname=`(uname -s || echo unknown) 2>/dev/null`
|
|
fi
|
|
case "$uname" in
|
|
Linux* | linux* | GNU | GNU/* | solaris*)
|
|
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*)
|
|
ARFLAGS="rcs"
|
|
CFLAGS="${CFLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
|
|
SFLAGS="${CFLAGS}"
|
|
shared_ext='.dll'
|
|
sharedlibdir='${bindir}'
|
|
SHAREDLIB=cygz$shared_ext
|
|
SHAREDLIBM=''
|
|
SHAREDLIBV=''
|
|
SHAREDTARGET=$SHAREDLIB
|
|
IMPORTLIB='libz.dll.a'
|
|
LDSHARED=${LDSHARED-"$cc -shared -Wl,--out-implib,${IMPORTLIB},--version-script,${SRCDIR}/zlib.map"}
|
|
LDSHAREDLIBC=""
|
|
DEFFILE='win32/zlib.def'
|
|
RC='windres'
|
|
RCFLAGS='--define GCC_WINDRES'
|
|
RCOBJS='zlibrc.o'
|
|
STRIP='strip'
|
|
EXE='.exe' ;;
|
|
MSYS* | msys*)
|
|
ARFLAGS="rcs"
|
|
SFLAGS="${CFLAGS}"
|
|
shared_ext='.dll'
|
|
sharedlibdir='${bindir}'
|
|
SHAREDLIB=msys-z$shared_ext
|
|
SHAREDLIBM=''
|
|
SHAREDLIBV=''
|
|
SHAREDTARGET=$SHAREDLIB
|
|
IMPORTLIB='libz.dll.a'
|
|
LDSHARED=${LDSHARED-"$cc -shared -Wl,--out-implib,${IMPORTLIB}"}
|
|
LDSHAREDLIBC=""
|
|
DEFFILE='win32/zlib.def'
|
|
RC='windres'
|
|
RCFLAGS='--define GCC_WINDRES'
|
|
RCOBJS='zlibrc.o'
|
|
STRIP='strip'
|
|
EXE='.exe' ;;
|
|
MINGW* | mingw*)
|
|
ARFLAGS="rcs"
|
|
CFLAGS="${CFLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1"
|
|
SFLAGS="${CFLAGS}"
|
|
shared_ext='.dll'
|
|
sharedlibdir='${bindir}'
|
|
SHAREDLIB=libz-$VER1$shared_ext
|
|
SHAREDLIBM=''
|
|
SHAREDLIBV=''
|
|
SHAREDTARGET=$SHAREDLIB
|
|
IMPORTLIB='libz.dll.a'
|
|
LDSHARED=${LDSHARED-"$cc -shared -Wl,--out-implib=${IMPORTLIB} -Wl,--version-script=${SRCDIR}/zlib.map"}
|
|
LDSHAREDLIBC=""
|
|
DEFFILE='win32/zlib.def'
|
|
RC='windres'
|
|
RCFLAGS='--define GCC_WINDRES'
|
|
if [ "$CC" == "mingw32-gcc" ]; then
|
|
case $ARCH in
|
|
i386 | i486 | i586 | i686) RCFLAGS="${RCFLAGS} -F pe-i386";;
|
|
esac;
|
|
fi
|
|
RCOBJS='zlibrc.o'
|
|
STRIP='strip'
|
|
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"} ;;
|
|
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
|
|
SHAREDTARGET=$SHAREDLIBV
|
|
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
|
|
CC=${CC-cc}
|
|
gcc=0
|
|
echo ... using $CC >> configure.log
|
|
if test -z "$uname"; then
|
|
uname=`(uname -sr || echo unknown) 2>/dev/null`
|
|
fi
|
|
case "$uname" in
|
|
HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
|
|
CFLAGS=${CFLAGS-"-O"}
|
|
# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
|
|
LDSHARED=${LDSHARED-"ld -b"}
|
|
case `(uname -m || echo unknown) 2>/dev/null` in
|
|
ia64)
|
|
shared_ext='.so'
|
|
SHAREDLIB='libz.so' ;;
|
|
*)
|
|
shared_ext='.sl'
|
|
SHAREDLIB='libz.sl' ;;
|
|
esac ;;
|
|
AIX*) # Courtesy of dbakker@arrayasolutions.com
|
|
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
|
|
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
|
|
LDSHARED=${LDSHARED-"xlc -G"} ;;
|
|
# send working options for other systems to zlib@gzip.org
|
|
*) SFLAGS=${CFLAGS-"-O"}
|
|
CFLAGS=${CFLAGS-"-O"}
|
|
LDSHARED=${LDSHARED-"cc -shared"} ;;
|
|
esac
|
|
fi
|
|
|
|
# destination names for shared library if not defined above
|
|
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
|
|
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
|
|
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
|
|
SHAREDTARGET=${SHAREDTARGET-"libz$shared_ext.$VER"}
|
|
|
|
echo >> configure.log
|
|
|
|
# define functions for testing compiler and library characteristics and logging the results
|
|
|
|
cat > $test.c <<EOF
|
|
#error error
|
|
EOF
|
|
if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
|
|
try()
|
|
{
|
|
show $*
|
|
test "`( $* ) 2>&1 | tee -a configure.log`" = ""
|
|
}
|
|
echo - using any output from compiler to indicate an error >> configure.log
|
|
else
|
|
try()
|
|
{
|
|
show $*
|
|
( $* ) >> configure.log 2>&1
|
|
ret=$?
|
|
if test $ret -ne 0; then
|
|
echo "(exit code "$ret")" >> configure.log
|
|
fi
|
|
return $ret
|
|
}
|
|
fi
|
|
|
|
tryboth()
|
|
{
|
|
show $*
|
|
got=`( $* ) 2>&1`
|
|
ret=$?
|
|
printf %s "$got" >> configure.log
|
|
if test $ret -ne 0; then
|
|
return $ret
|
|
fi
|
|
test "$got" = ""
|
|
}
|
|
|
|
cat > $test.c << EOF
|
|
int foo() { return 0; }
|
|
EOF
|
|
echo "Checking for obsessive-compulsive compiler options..." >> configure.log
|
|
if try $CC -c $CFLAGS $test.c; then
|
|
:
|
|
else
|
|
echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
|
|
leave 1
|
|
fi
|
|
|
|
echo >> configure.log
|
|
|
|
# see if shared library build supported
|
|
cat > $test.c <<EOF
|
|
extern int getchar();
|
|
int hello() {return getchar();}
|
|
EOF
|
|
if test $shared -eq 1; then
|
|
echo Checking for shared library support... | tee -a configure.log
|
|
# we must test in two steps (cc then ld), required at least on SunOS 4.x
|
|
if try $CC -w -c $SFLAGS $test.c &&
|
|
try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
|
|
echo Building shared library $SHAREDTARGET with $CC. | tee -a configure.log
|
|
elif test -z "$old_cc" -a -z "$old_cflags"; then
|
|
echo No shared library support. | tee -a configure.log
|
|
shared=0;
|
|
else
|
|
echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
|
|
shared=0;
|
|
fi
|
|
fi
|
|
if test $shared -eq 0; then
|
|
LDSHARED="$CC"
|
|
ALL="static"
|
|
SHAREDLIB=""
|
|
SHAREDLIBV=""
|
|
SHAREDLIBM=""
|
|
SHAREDTARGET=""
|
|
INSTALLTARGETS=install-static
|
|
UNINSTALLTARGETS=uninstall-static
|
|
echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
|
|
else
|
|
ALL="static shared"
|
|
TEST="${TEST} testshared"
|
|
fi
|
|
|
|
echo >> configure.log
|
|
|
|
# check for large file support, and if none, check for fseeko()
|
|
cat > $test.c <<EOF
|
|
#include <sys/types.h>
|
|
#ifdef __MSYS__
|
|
# define off64_t _off64_t
|
|
#endif
|
|
off64_t dummy = 0;
|
|
EOF
|
|
if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
|
|
CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
|
|
SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
|
|
ALL="${ALL} all64"
|
|
TEST="${TEST} test64"
|
|
echo "Checking for off64_t... Yes." | tee -a configure.log
|
|
echo "Checking for fseeko... Yes." | tee -a configure.log
|
|
else
|
|
echo "Checking for off64_t... No." | tee -a configure.log
|
|
echo >> configure.log
|
|
cat > $test.c <<EOF
|
|
#include <stdio.h>
|
|
int main(void) {
|
|
fseeko(NULL, 0, 0);
|
|
return 0;
|
|
}
|
|
EOF
|
|
if try $CC $CFLAGS -o $test $test.c; then
|
|
echo "Checking for fseeko... Yes." | tee -a configure.log
|
|
else
|
|
CFLAGS="${CFLAGS} -DNO_FSEEKO"
|
|
SFLAGS="${SFLAGS} -DNO_FSEEKO"
|
|
echo "Checking for fseeko... No." | tee -a configure.log
|
|
fi
|
|
fi
|
|
|
|
echo >> configure.log
|
|
|
|
# check for strerror() for use by gz* functions
|
|
cat > $test.c <<EOF
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
int main() { return strlen(strerror(errno)); }
|
|
EOF
|
|
if try $CC $CFLAGS -o $test $test.c; then
|
|
echo "Checking for strerror... Yes." | tee -a configure.log
|
|
else
|
|
CFLAGS="${CFLAGS} -DNO_STRERROR"
|
|
SFLAGS="${SFLAGS} -DNO_STRERROR"
|
|
echo "Checking for strerror... No." | tee -a configure.log
|
|
fi
|
|
|
|
# We need to remove zconf.h from source directory if building outside of it
|
|
if [ "$SRCDIR" != "$BUILDDIR" ]; then rm -f $SRCDIR/zconf.h; fi
|
|
|
|
# copy clean zconf.h for subsequent edits
|
|
cp -p $SRCDIR/zconf.h.in zconf.h
|
|
|
|
echo >> configure.log
|
|
|
|
# check for unistd.h and save result in zconf.h
|
|
cat > $test.c <<EOF
|
|
#include <unistd.h>
|
|
int main() { return 0; }
|
|
EOF
|
|
if try $CC -c $CFLAGS $test.c; then
|
|
sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
|
|
mv zconf.temp.h zconf.h
|
|
echo "Checking for unistd.h... Yes." | tee -a configure.log
|
|
else
|
|
echo "Checking for unistd.h... No." | tee -a configure.log
|
|
fi
|
|
|
|
echo >> configure.log
|
|
|
|
# check for stdarg.h and save result in zconf.h
|
|
cat > $test.c <<EOF
|
|
#include <stdarg.h>
|
|
int main() { return 0; }
|
|
EOF
|
|
if try $CC -c $CFLAGS $test.c; then
|
|
sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
|
|
mv zconf.temp.h zconf.h
|
|
echo "Checking for stdarg.h... Yes." | tee -a configure.log
|
|
else
|
|
echo "Checking for stdarg.h... No." | tee -a configure.log
|
|
fi
|
|
|
|
# if --zlib-compat was requested
|
|
if test $compat -eq 1; then
|
|
CFLAGS="${CFLAGS} -DZLIB_COMPAT -DWITH_GZFILEOP"
|
|
SFLAGS="${SFLAGS} -DZLIB_COMPAT -DWITH_GZFILEOP"
|
|
OBJC="${OBJC} \$(OBJG)"
|
|
PIC_OBJC="${PIC_OBJC} \$(PIC_OBJG)"
|
|
case "$uname" in
|
|
CYGWIN* | Cygwin* | cygwin* | MSYS* | msys* | MINGW* | mingw*)
|
|
DEFFILE="win32/zlibcompat.def" ;;
|
|
esac
|
|
fi
|
|
|
|
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
|
|
if test $cover -eq 1; then
|
|
CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
|
|
if test -n "$GCC_CLASSIC"; then
|
|
CC=$GCC_CLASSIC
|
|
fi
|
|
fi
|
|
|
|
echo >> configure.log
|
|
|
|
# Check for ANSI C compliant compiler
|
|
cat > $test.c <<EOF
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include "zconf.h"
|
|
int main()
|
|
{
|
|
#ifdef STDC
|
|
return 0;
|
|
#endif
|
|
return 1;
|
|
}
|
|
EOF
|
|
if try $CC -c $CFLAGS $test.c; then
|
|
echo "Checking for ANSI C compliant compiler... Yes." | tee -a configure.log
|
|
:
|
|
else
|
|
echo "Checking for ANSI C compliant compiler... No." | tee -a configure.log
|
|
echo "Error: ANSI C compatible compiler needed, cannot continue." | tee -a configure.log
|
|
leave 1
|
|
fi
|
|
|
|
# see if we can hide zlib internal symbols that are linked between separate source files using hidden
|
|
if test "$gcc" -eq 1; then
|
|
echo >> configure.log
|
|
cat > $test.c <<EOF
|
|
#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
|
int ZLIB_INTERNAL foo;
|
|
int main()
|
|
{
|
|
return 0;
|
|
}
|
|
EOF
|
|
if tryboth $CC -c $CFLAGS $test.c; then
|
|
CFLAGS="$CFLAGS -DHAVE_HIDDEN"
|
|
SFLAGS="$SFLAGS -DHAVE_HIDDEN"
|
|
echo >> configure.log
|
|
echo "Checking for attribute(visibility(hidden)) support... Yes." | tee -a configure.log
|
|
else
|
|
echo >> configure.log
|
|
echo "Checking for attribute(visibility(hidden)) support... No." | tee -a configure.log
|
|
fi
|
|
fi
|
|
|
|
# see if we can hide zlib internal symbols that are linked between separate source files using internal
|
|
if test "$gcc" -eq 1; then
|
|
echo >> configure.log
|
|
cat > $test.c <<EOF
|
|
#define ZLIB_INTERNAL __attribute__((visibility ("internal")))
|
|
int ZLIB_INTERNAL foo;
|
|
int main()
|
|
{
|
|
return 0;
|
|
}
|
|
EOF
|
|
if tryboth $CC -c $CFLAGS $test.c; then
|
|
CFLAGS="$CFLAGS -DHAVE_INTERNAL"
|
|
SFLAGS="$SFLAGS -DHAVE_INTERNAL"
|
|
echo >> configure.log
|
|
echo "Checking for attribute(visibility(internal)) support... Yes." | tee -a configure.log
|
|
else
|
|
echo >> configure.log
|
|
echo "Checking for attribute(visibility(internal)) support... No." | tee -a configure.log
|
|
fi
|
|
fi
|
|
|
|
# Check for __builtin_ctzl() support in compiler
|
|
cat > $test.c << EOF
|
|
int main(void)
|
|
{
|
|
unsigned int zero = 0;
|
|
long test = __builtin_ctzl(zero);
|
|
(void)test;
|
|
return 0;
|
|
}
|
|
EOF
|
|
if try ${CC} ${CFLAGS} $test.c; then
|
|
echo "Checking for __builtin_ctzl ... Yes." | tee -a configure.log
|
|
CFLAGS="$CFLAGS -DHAVE_BUILTIN_CTZL"
|
|
SFLAGS="$SFLAGS -DHAVE_BUILTIN_CTZL"
|
|
else
|
|
echo "Checking for __builtin_ctzl ... No." | tee -a configure.log
|
|
fi
|
|
|
|
# Check for SSE2 intrinsics
|
|
cat > $test.c << EOF
|
|
#include <immintrin.h>
|
|
int main(void)
|
|
{
|
|
__m128i zero = _mm_setzero_si128();
|
|
(void)zero;
|
|
return 0;
|
|
}
|
|
EOF
|
|
if try ${CC} ${CFLAGS} -msse2 $test.c; then
|
|
echo "Checking for SSE2 intrinsics ... Yes." | tee -a configure.log
|
|
HAVE_SSE2_INTRIN=1
|
|
else
|
|
echo "Checking for SSE2 intrinsics ... No." | tee -a configure.log
|
|
HAVE_SSE2_INTRIN=0
|
|
fi
|
|
|
|
# Check for PCLMULQDQ intrinsics
|
|
cat > $test.c << EOF
|
|
#include <immintrin.h>
|
|
#include <wmmintrin.h>
|
|
int main(void)
|
|
{
|
|
__m128i a = _mm_setzero_si128();
|
|
__m128i b = _mm_setzero_si128();
|
|
__m128i c = _mm_clmulepi64_si128(a, b, 0x10);
|
|
(void)c;
|
|
return 0;
|
|
}
|
|
EOF
|
|
if try ${CC} ${CFLAGS} -mpclmul $test.c; then
|
|
echo "Checking for PCLMULQDQ intrinsics ... Yes." | tee -a configure.log
|
|
HAVE_PCLMULQDQ_INTRIN=1
|
|
else
|
|
echo "Checking for PCLMULQDQ intrinsics ... No." | tee -a configure.log
|
|
HAVE_PCLMULQDQ_INTRIN=0
|
|
fi
|
|
|
|
# Enable deflate_medium at level 4-6
|
|
if test $without_new_strategies -eq 0; then
|
|
CFLAGS="${CFLAGS} -DMEDIUM_STRATEGY"
|
|
SFLAGS="${SFLAGS} -DMEDIUM_STRATEGY"
|
|
fi
|
|
|
|
ARCHDIR='arch/generic'
|
|
ARCH_STATIC_OBJS=''
|
|
ARCH_SHARED_OBJS=''
|
|
|
|
# Set ARCH specific FLAGS
|
|
case "${ARCH}" in
|
|
|
|
# x86 and x86_64 specific optimizations
|
|
i386 | i486 | i586 | i686 | x86_64)
|
|
ARCHDIR=arch/x86
|
|
|
|
case "${ARCH}" in
|
|
x86_64)
|
|
CFLAGS="${CFLAGS} -DX86_64 -DX86_NOCHECK_SSE2"
|
|
SFLAGS="${SFLAGS} -DX86_64 -DX86_NOCHECK_SSE2"
|
|
;;
|
|
i386 | i486 | i586 | i686)
|
|
CFLAGS="${CFLAGS} -DX86"
|
|
SFLAGS="${SFLAGS} -DX86"
|
|
;;
|
|
esac
|
|
|
|
CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNROLL_LESS -DX86_CPUID"
|
|
SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNROLL_LESS -DX86_CPUID"
|
|
|
|
# Enable arch-specific optimizations?
|
|
if test $without_optimizations -eq 0; then
|
|
ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} x86.o"
|
|
ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} x86.lo"
|
|
|
|
if test ${HAVE_SSE2_INTRIN} -eq 1; then
|
|
CFLAGS="${CFLAGS} -DX86_SSE2_FILL_WINDOW"
|
|
SFLAGS="${SFLAGS} -DX86_SSE2_FILL_WINDOW"
|
|
ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} fill_window_sse.o"
|
|
ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} fill_window_sse.lo"
|
|
fi
|
|
|
|
CFLAGS="${CFLAGS} -DX86_SSE4_2_CRC_HASH"
|
|
SFLAGS="${SFLAGS} -DX86_SSE4_2_CRC_HASH"
|
|
ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} insert_string_sse.o"
|
|
ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} insert_string_sse.lo"
|
|
|
|
if test ${HAVE_PCLMULQDQ_INTRIN} -eq 1; then
|
|
CFLAGS="${CFLAGS} -DX86_PCLMULQDQ_CRC"
|
|
SFLAGS="${SFLAGS} -DX86_PCLMULQDQ_CRC"
|
|
ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc_folding.o"
|
|
ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc_folding.lo"
|
|
fi
|
|
|
|
# Enable deflate_quick at level 1?
|
|
# requires SSE2: code uses fill_window_sse
|
|
if test ${HAVE_SSE2_INTRIN} -eq 1 && test $without_new_strategies -eq 0; then
|
|
CFLAGS="${CFLAGS} -DX86_QUICK_STRATEGY"
|
|
SFLAGS="${SFLAGS} -DX86_QUICK_STRATEGY"
|
|
|
|
ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} deflate_quick.o"
|
|
ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} deflate_quick.lo"
|
|
fi
|
|
fi
|
|
;;
|
|
|
|
# ARM specific optimizations
|
|
armv3l | armv4b | armv4l | armv4tl | armv5tel | armv5tejl | armv6l | armv6hl | armv7l | armv7hl | armv7hnl)
|
|
ARCHDIR=arch/arm
|
|
|
|
case "${ARCH}" in
|
|
armv6l | armv6hl)
|
|
# Tests done on Raspberry pi (armv6hl) indicate that UNALIGNED_OK and UNROLL_LESS both
|
|
# provide performance improvements, totaling about 1.5% for the two.
|
|
CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNROLL_LESS"
|
|
SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNROLL_LESS"
|
|
;;
|
|
esac
|
|
|
|
;;
|
|
esac
|
|
|
|
echo "ARCH: ${ARCH}"
|
|
echo "Using arch directory: ${ARCHDIR}"
|
|
|
|
# show the results in the log
|
|
echo >> configure.log
|
|
echo ALL = $ALL >> configure.log
|
|
echo AR = $AR >> configure.log
|
|
echo ARFLAGS = $ARFLAGS >> configure.log
|
|
echo CC = $CC >> configure.log
|
|
echo CFLAGS = $CFLAGS >> configure.log
|
|
echo EXE = $EXE >> configure.log
|
|
echo LDCONFIG = $LDCONFIG >> configure.log
|
|
echo LDFLAGS = $LDFLAGS >> configure.log
|
|
echo LDSHARED = $LDSHARED >> configure.log
|
|
echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
|
|
echo DEFFILE = $DEFFILE >> configure.log
|
|
echo RC = $RC >> configure.log
|
|
echo RCFLAGS = $RCFLAGS >> configure.log
|
|
echo RCOBJS = $RCOBJS >> configure.log
|
|
echo STRIP = $STRIP >> configure.log
|
|
echo OBJC = $OBJC >> configure.log
|
|
echo PIC_OBJC = $PIC_OBJC >> configure.log
|
|
echo RANLIB = $RANLIB >> configure.log
|
|
echo SFLAGS = $SFLAGS >> configure.log
|
|
echo SHAREDLIB = $SHAREDLIB >> configure.log
|
|
echo SHAREDLIBM = $SHAREDLIBM >> configure.log
|
|
echo SHAREDLIBV = $SHAREDLIBV >> configure.log
|
|
echo SHAREDTARGET = $SHAREDTARGET >> configure.log
|
|
echo IMPORTLIB = $IMPORTLIB >> configure.log
|
|
echo INSTALLTARGETS = $INSTALLTARGETS >> configure.log
|
|
echo UNINSTALLTARGETS = $UNINSTALLTARGETS >> configure.log
|
|
echo SRCDIR = $SRCDIR >> configure.log
|
|
echo BUILDDIR = $BUILDDIR >> configure.log
|
|
echo STATICLIB = $STATICLIB >> configure.log
|
|
echo TEST = $TEST >> configure.log
|
|
echo VER = $VER >> configure.log
|
|
echo exec_prefix = $exec_prefix >> configure.log
|
|
echo includedir = $includedir >> configure.log
|
|
echo bindir = $bindir >> configure.log
|
|
echo libdir = $libdir >> configure.log
|
|
echo mandir = $mandir >> configure.log
|
|
echo prefix = $prefix >> configure.log
|
|
echo sharedlibdir = $sharedlibdir >> configure.log
|
|
echo uname = $uname >> configure.log
|
|
echo ARCHDIR = ${ARCHDIR} >> configure.log
|
|
echo ARCH_STATIC_OBJS = ${ARCH_STATIC_OBJS} >> configure.log
|
|
echo ARCH_SHARED_OBJS = ${ARCH_SHARED_OBJS} >> configure.log
|
|
|
|
# update Makefile with the configure results
|
|
|
|
INCLUDES="-I$SRCDIR"
|
|
if [ "$SRCDIR" != "$BUILDDIR" ]; then INCLUDES="-I$BUILDDIR ${INCLUDES}"; fi
|
|
|
|
sed < $SRCDIR/Makefile.in "
|
|
/^CC *=/s#=.*#=$CC#
|
|
/^CFLAGS *=/s#=.*#=$CFLAGS#
|
|
/^SFLAGS *=/s#=.*#=$SFLAGS#
|
|
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
|
|
/^LDSHARED *=/s#=.*#=$LDSHARED#
|
|
/^STATICLIB *=/s#=.*#=$STATICLIB#
|
|
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
|
|
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
|
|
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
|
|
/^SHAREDTARGET *=/s#=.*#=$SHAREDTARGET#
|
|
/^IMPORTLIB *=/s#=.*#=$IMPORTLIB#
|
|
/^AR *=/s#=.*#=$AR#
|
|
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
|
|
/^RANLIB *=/s#=.*#=$RANLIB#
|
|
/^LDCONFIG *=/s#=.*#=$LDCONFIG#
|
|
/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
|
|
/^DEFFILE *=/s#=.*#=$DEFFILE#
|
|
/^RC *=/s#=.*#=$RC#
|
|
/^RCFLAGS *=/s#=.*#=$RCFLAGS#
|
|
/^RCOBJS *=/s#=.*#=$RCOBJS#
|
|
/^STRIP *=/s#=.*#=$STRIP#
|
|
/^EXE *=/s#=.*#=$EXE#
|
|
/^prefix *=/s#=.*#= $prefix#
|
|
/^exec_prefix *=/s#=.*#= $exec_prefix#
|
|
/^bindir *=/s#=.*#= $bindir#
|
|
/^libdir *=/s#=.*#= $libdir#
|
|
/^sharedlibdir *=/s#=.*#= $sharedlibdir#
|
|
/^includedir *=/s#=.*#= $includedir#
|
|
/^mandir *=/s#=.*#= $mandir#
|
|
/^SRCDIR *=/s#=.*#=$SRCDIR#
|
|
/^INCLUDES *=/s#=.*#=$INCLUDES#
|
|
/^OBJC *=/s#=.*#= $OBJC#
|
|
/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
|
|
/^all: */s#:.*#: $ALL#
|
|
/^install-libs: */s#:.*#: $INSTALLTARGETS#
|
|
/^uninstall-libs: */s#:.*#: $UNINSTALLTARGETS#
|
|
/^ARCHDIR *=/s#=.*#=$ARCHDIR#
|
|
/^ARCH_STATIC_OBJS *=/s#=.*#=$ARCH_STATIC_OBJS#
|
|
/^ARCH_SHARED_OBJS *=/s#=.*#=$ARCH_SHARED_OBJS#
|
|
" > Makefile
|
|
|
|
# Generate Makefile in arch dir
|
|
mkdir -p $ARCHDIR
|
|
|
|
ARCHINCLUDES="-I$SRCDIR/$ARCHDIR -I$SRCDIR"
|
|
if [ "$SRCDIR" != "$BUILDDIR" ]; then ARCHINCLUDES="-I$BUILDDIR ${ARCHINCLUDES}"; fi
|
|
|
|
sed < $SRCDIR/$ARCHDIR/Makefile.in "
|
|
/^CC *=/s#=.*#=$CC#
|
|
/^CFLAGS *=/s#=.*#=$CFLAGS#
|
|
/^SFLAGS *=/s#=.*#=$SFLAGS#
|
|
/^INCLUDES *=/s#=.*#=$ARCHINCLUDES#
|
|
/^SRCDIR *=/s#=.*#=$SRCDIR/$ARCHDIR#
|
|
/^SRCTOP *=/s#=.*#=$SRCDIR#
|
|
" > $ARCHDIR/Makefile
|
|
|
|
# Generate Makefile in test dir
|
|
mkdir -p test
|
|
TESTINCLUDES="-I$SRCDIR"
|
|
if [ "$SRCDIR" != "$BUILDDIR" ]; then TESTINCLUDES="${TESTINCLUDES} -I$BUILDDIR"; fi
|
|
if test $compat -eq 1; then COMPATTESTS="compattests"; fi
|
|
sed < $SRCDIR/test/Makefile.in "
|
|
/^CC *=/s#=.*#=$CC#
|
|
/^CFLAGS *=/s#=.*#=$CFLAGS#
|
|
/^EXE *=/s#=.*#=$EXE#
|
|
/^oldtests: */s#:.*#: $TEST#
|
|
/^INCLUDES *=/s#=.*#=$TESTINCLUDES#
|
|
/^SRCDIR *=/s#=.*#=$SRCDIR/test#
|
|
/^SRCTOP *=/s#=.*#=$SRCDIR#
|
|
/^COMPATTESTS *=/s#=.*#=$COMPATTESTS#
|
|
" > test/Makefile
|
|
|
|
# create zlib.pc with the configure results
|
|
sed < $SRCDIR/zlib.pc.in "
|
|
/^CC *=/s#=.*#=$CC#
|
|
/^CFLAGS *=/s#=.*#=$CFLAGS#
|
|
/^LDSHARED *=/s#=.*#=$LDSHARED#
|
|
/^STATICLIB *=/s#=.*#=$STATICLIB#
|
|
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
|
|
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
|
|
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
|
|
/^IMPORTLIB *=/s#=.*#=$IMPORTLIB#
|
|
/^AR *=/s#=.*#=$AR#
|
|
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
|
|
/^RANLIB *=/s#=.*#=$RANLIB#
|
|
/^EXE *=/s#=.*#=$EXE#
|
|
/^prefix *=/s#=.*#=$prefix#
|
|
/^exec_prefix *=/s#=.*#=$exec_prefix#
|
|
/^bindir *=/s#=.*#=$bindir#
|
|
/^libdir *=/s#=.*#=$libdir#
|
|
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
|
|
/^includedir *=/s#=.*#=$includedir#
|
|
/^mandir *=/s#=.*#=$mandir#
|
|
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
|
|
" | sed -e "
|
|
s/\@VERSION\@/$VER/g;
|
|
" > zlib.pc
|
|
|
|
# done
|
|
leave 0
|