A massively spiffy yet delicately unobtrusive compression library. (grpc依赖)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

643 lines
18 KiB

13 years ago
#!/bin/sh
13 years ago
# configure script for zlib.
13 years ago
#
13 years ago
# Normally configure builds both a static and a shared library.
# If you want to build just a static library, use: ./configure --static
13 years ago
#
13 years ago
# 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)
13 years ago
# 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.
13 years ago
if [ -n "${CHOST}" ]; then
13 years ago
uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
13 years ago
CROSS_PREFIX="${CHOST}-"
fi
13 years ago
STATICLIB=libz.a
13 years ago
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
13 years ago
VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
13 years ago
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
13 years ago
if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
13 years ago
AR=${AR-"${CROSS_PREFIX}ar"}
13 years ago
test -n "${CROSS_PREFIX}" && echo Using ${AR}
13 years ago
else
AR=${AR-"ar"}
13 years ago
test -n "${CROSS_PREFIX}" && echo Using ${AR}
13 years ago
fi
ARFLAGS=${ARFLAGS-"rc"}
13 years ago
if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
13 years ago
RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
13 years ago
test -n "${CROSS_PREFIX}" && echo Using ${RANLIB}
13 years ago
else
RANLIB=${RANLIB-"ranlib"}
fi
13 years ago
if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
13 years ago
NM=${NM-"${CROSS_PREFIX}nm"}
13 years ago
test -n "${CROSS_PREFIX}" && echo Using ${NM}
13 years ago
else
NM=${NM-"nm"}
fi
13 years ago
LDCONFIG=${LDCONFIG-"ldconfig"}
13 years ago
LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
13 years ago
ARCHS=
13 years ago
prefix=${prefix-/usr/local}
13 years ago
exec_prefix=${exec_prefix-'${prefix}'}
libdir=${libdir-'${exec_prefix}/lib'}
13 years ago
sharedlibdir=${sharedlibdir-'${libdir}'}
13 years ago
includedir=${includedir-'${prefix}/include'}
13 years ago
mandir=${mandir-'${prefix}/share/man'}
13 years ago
shared_ext='.so'
13 years ago
shared=1
solo=0
cover=0
13 years ago
zprefix=0
13 years ago
build64=0
13 years ago
gcc=0
13 years ago
old_cc="$CC"
old_cflags="$CFLAGS"
OBJC='$(OBJZ) $(OBJG)'
PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
13 years ago
13 years ago
while test $# -ge 1
do
13 years ago
case "$1" in
13 years ago
-h* | --help)
13 years ago
echo 'usage:'
13 years ago
echo ' configure [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]'
13 years ago
echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]'
13 years ago
echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]'
13 years ago
exit 0 ;;
13 years ago
-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 ;;
13 years ago
--sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
13 years ago
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
-u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
13 years ago
-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 ;;
--solo) solo=1; shift ;;
--cover) cover=1; shift ;;
13 years ago
-z* | --zprefix) zprefix=1; shift ;;
13 years ago
-6* | --64) build64=1; shift ;;
13 years ago
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
13 years ago
--sysconfdir=*) echo "ignored option: --sysconfdir"; shift ;;
--localstatedir=*) echo "ignored option: --localstatedir"; shift ;;
*) echo "unknown option: $1"; echo "$0 --help for help"; exit 1 ;;
13 years ago
esac
done
13 years ago
test=ztest$$
cat > $test.c <<EOF
13 years ago
extern int getchar();
int hello() {return getchar();}
13 years ago
EOF
13 years ago
13 years ago
test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc...
13 years ago
cc=${CC-${CROSS_PREFIX}gcc}
13 years ago
cflags=${CFLAGS-"-O3"}
13 years ago
# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
13 years ago
case "$cc" in
13 years ago
*gcc*) gcc=1 ;;
13 years ago
esac
13 years ago
case `$cc -v 2>&1` in
*gcc*) gcc=1 ;;
esac
13 years ago
if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
CC="$cc"
13 years ago
CFLAGS="${CFLAGS--O3} ${ARCHS}"
13 years ago
SFLAGS="${CFLAGS--O3} -fPIC"
13 years ago
LDFLAGS="${LDFLAGS} ${ARCHS}"
13 years ago
if test $build64 -eq 1; then
CFLAGS="${CFLAGS} -m64"
SFLAGS="${SFLAGS} -m64"
fi
13 years ago
if test "${ZLIBGCCWARN}" = "YES"; then
CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
fi
13 years ago
if test -z "$uname"; then
13 years ago
uname=`(uname -s || echo unknown) 2>/dev/null`
fi
case "$uname" in
13 years ago
Linux* | linux* | GNU | GNU/* | *BSD | *bsd* | DragonFly | solaris*)
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
13 years ago
CYGWIN* | Cygwin* | cygwin* | OS/2*)
EXE='.exe' ;;
13 years ago
MINGW* | mingw*)
13 years ago
# temporary bypass
rm -f $test.[co] $test $test$shared_ext
echo "Please use win32/Makefile.gcc instead."
exit 1
13 years ago
LDSHARED=${LDSHARED-"$cc -shared"}
13 years ago
LDSHAREDLIBC=""
EXE='.exe' ;;
13 years ago
QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
# (alain.bonnefoy@icbt.com)
13 years ago
LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
13 years ago
HP-UX*)
LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
case `(uname -m || echo unknown) 2>/dev/null` in
ia64)
shared_ext='.so'
13 years ago
SHAREDLIB='libz.so' ;;
13 years ago
*)
13 years ago
shared_ext='.sl'
13 years ago
SHAREDLIB='libz.sl' ;;
esac ;;
13 years ago
Darwin* | darwin*)
shared_ext='.dylib'
13 years ago
SHAREDLIB=libz$shared_ext
SHAREDLIBV=libz.$VER$shared_ext
SHAREDLIBM=libz.$VER1$shared_ext
13 years ago
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
AR="libtool"
ARFLAGS="-o" ;;
13 years ago
*) LDSHARED=${LDSHARED-"$cc -shared"} ;;
13 years ago
esac
13 years ago
else
# find system name and corresponding cc options
CC=${CC-cc}
13 years ago
gcc=0
13 years ago
if test -z "$uname"; then
13 years ago
uname=`(uname -sr || echo unknown) 2>/dev/null`
fi
case "$uname" in
13 years ago
HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
13 years ago
CFLAGS=${CFLAGS-"-O"}
# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
LDSHARED=${LDSHARED-"ld -b"}
13 years ago
case `(uname -m || echo unknown) 2>/dev/null` in
ia64)
shared_ext='.so'
13 years ago
SHAREDLIB='libz.so' ;;
13 years ago
*)
13 years ago
shared_ext='.sl'
13 years ago
SHAREDLIB='libz.sl' ;;
esac ;;
13 years ago
IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
13 years ago
CFLAGS=${CFLAGS-"-ansi -O2"}
13 years ago
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
13 years ago
OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
13 years ago
CFLAGS=${CFLAGS-"-O -std1"}
13 years ago
LDFLAGS="${LDFLAGS} -Wl,-rpath,."
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
13 years ago
OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
13 years ago
CFLAGS=${CFLAGS-"-O -std1"}
13 years ago
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
13 years ago
QNX*) SFLAGS=${CFLAGS-"-4 -O"}
CFLAGS=${CFLAGS-"-4 -O"}
13 years ago
LDSHARED=${LDSHARED-"cc"}
13 years ago
RANLIB=${RANLIB-"true"}
AR="cc"
ARFLAGS="-A" ;;
13 years ago
SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
13 years ago
CFLAGS=${CFLAGS-"-O3"}
13 years ago
LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
13 years ago
SunOS\ 5* | solaris*)
LDSHARED=${LDSHARED-"cc -G"}
13 years ago
case `(uname -m || echo unknown) 2>/dev/null` in
i86*)
SFLAGS=${CFLAGS-"-xpentium -fast -KPIC -R."}
13 years ago
CFLAGS=${CFLAGS-"-xpentium -fast"} ;;
13 years ago
*)
SFLAGS=${CFLAGS-"-fast -xcg92 -KPIC -R."}
13 years ago
CFLAGS=${CFLAGS-"-fast -xcg92"} ;;
esac ;;
13 years ago
SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
13 years ago
CFLAGS=${CFLAGS-"-O2"}
13 years ago
LDSHARED=${LDSHARED-"ld"} ;;
13 years ago
SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
13 years ago
LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
13 years ago
UNIX_System_V\ 4.2.0)
SFLAGS=${CFLAGS-"-KPIC -O"}
CFLAGS=${CFLAGS-"-O"}
13 years ago
LDSHARED=${LDSHARED-"cc -G"} ;;
13 years ago
UNIX_SV\ 4.2MP)
13 years ago
SFLAGS=${CFLAGS-"-Kconform_pic -O"}
CFLAGS=${CFLAGS-"-O"}
13 years ago
LDSHARED=${LDSHARED-"cc -G"} ;;
13 years ago
OpenUNIX\ 5)
SFLAGS=${CFLAGS-"-KPIC -O"}
CFLAGS=${CFLAGS-"-O"}
13 years ago
LDSHARED=${LDSHARED-"cc -G"} ;;
13 years ago
AIX*) # Courtesy of dbakker@arrayasolutions.com
13 years ago
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
13 years ago
LDSHARED=${LDSHARED-"xlc -G"} ;;
13 years ago
# send working options for other systems to zlib@gzip.org
13 years ago
*) SFLAGS=${CFLAGS-"-O"}
13 years ago
CFLAGS=${CFLAGS-"-O"}
13 years ago
LDSHARED=${LDSHARED-"cc -shared"} ;;
13 years ago
esac
fi
13 years ago
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
13 years ago
if test $shared -eq 1; then
echo Checking for shared library support...
# we must test in two steps (cc then ld), required at least on SunOS 4.x
13 years ago
if test "`($CC -w -c $SFLAGS $test.c) 2>&1`" = "" &&
13 years ago
test "`($LDSHARED $SFLAGS -o $test$shared_ext $test.o) 2>&1`" = ""; then
13 years ago
echo Building shared library $SHAREDLIBV with $CC.
13 years ago
elif test -z "$old_cc" -a -z "$old_cflags"; then
13 years ago
echo No shared library support.
13 years ago
shared=0;
13 years ago
else
13 years ago
echo Tested $CC -w -c $SFLAGS $test.c
$CC -w -c $SFLAGS $test.c
13 years ago
echo Tested $LDSHARED $SFLAGS -o $test$shared_ext $test.o
$LDSHARED $SFLAGS -o $test$shared_ext $test.o
13 years ago
echo 'No shared library support; try without defining CC and CFLAGS'
13 years ago
shared=0;
13 years ago
fi
fi
if test $shared -eq 0; then
13 years ago
LDSHARED="$CC"
13 years ago
ALL="static"
TEST="all teststatic"
13 years ago
SHAREDLIB=""
SHAREDLIBV=""
SHAREDLIBM=""
13 years ago
echo Building static library $STATICLIB version $VER with $CC.
13 years ago
else
13 years ago
ALL="static shared"
TEST="all teststatic testshared"
13 years ago
fi
cat > $test.c <<EOF
#include <sys/types.h>
off64_t dummy = 0;
EOF
13 years ago
if test "`($CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c) 2>&1`" = ""; then
CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
13 years ago
ALL="${ALL} all64"
TEST="${TEST} test64"
13 years ago
echo "Checking for off64_t... Yes."
13 years ago
echo "Checking for fseeko... Yes."
13 years ago
else
13 years ago
echo "Checking for off64_t... No."
13 years ago
cat > $test.c <<EOF
#include <stdio.h>
int main(void) {
fseeko(NULL, 0, 0);
return 0;
}
EOF
if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
echo "Checking for fseeko... Yes."
else
CFLAGS="${CFLAGS} -DNO_FSEEKO"
SFLAGS="${SFLAGS} -DNO_FSEEKO"
echo "Checking for fseeko... No."
fi
13 years ago
fi
13 years ago
13 years ago
cp -p zconf.h.in zconf.h
13 years ago
13 years ago
cat > $test.c <<EOF
#include <unistd.h>
int main() { return 0; }
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
13 years ago
sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
13 years ago
mv zconf.temp.h zconf.h
13 years ago
echo "Checking for unistd.h... Yes."
else
echo "Checking for unistd.h... No."
13 years ago
fi
13 years ago
cat > $test.c <<EOF
#include <stdarg.h>
int main() { return 0; }
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; 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."
else
echo "Checking for stdarg.h... No."
fi
13 years ago
if test $zprefix -eq 1; then
13 years ago
sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
13 years ago
mv zconf.temp.h zconf.h
echo "Using z_ prefix on all symbols."
fi
if test $solo -eq 1; then
sed '/#define ZCONF_H/a\
#define Z_SOLO
' < zconf.h > zconf.temp.h
mv zconf.temp.h zconf.h
OBJC='$(OBJZ)'
PIC_OBJC='$(PIC_OBJZ)'
fi
if test $cover -eq 1; then
CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
fi
13 years ago
cat > $test.c <<EOF
13 years ago
#include <stdio.h>
13 years ago
#include <stdarg.h>
#include "zconf.h"
13 years ago
13 years ago
int main()
13 years ago
{
#ifndef STDC
choke me
#endif
return 0;
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
13 years ago
echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()."
13 years ago
cat > $test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
13 years ago
int mytest(const char *fmt, ...)
13 years ago
{
char buf[20];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
return 0;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
EOF
13 years ago
if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
13 years ago
echo "Checking for vsnprintf() in stdio.h... Yes."
cat >$test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
13 years ago
int mytest(const char *fmt, ...)
13 years ago
{
13 years ago
int n;
13 years ago
char buf[20];
va_list ap;
va_start(ap, fmt);
13 years ago
n = vsnprintf(buf, sizeof(buf), fmt, ap);
13 years ago
va_end(ap);
13 years ago
return n;
13 years ago
}
int main()
{
return (mytest("Hello%d\n", 1));
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of vsnprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
13 years ago
SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
13 years ago
echo "Checking for return value of vsnprintf()... No."
echo " WARNING: apparently vsnprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
else
CFLAGS="$CFLAGS -DNO_vsnprintf"
13 years ago
SFLAGS="$SFLAGS -DNO_vsnprintf"
13 years ago
echo "Checking for vsnprintf() in stdio.h... No."
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
echo " can build but will be open to possible buffer-overflow security"
echo " vulnerabilities."
cat >$test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
13 years ago
int mytest(const char *fmt, ...)
13 years ago
{
13 years ago
int n;
13 years ago
char buf[20];
va_list ap;
va_start(ap, fmt);
13 years ago
n = vsprintf(buf, fmt, ap);
13 years ago
va_end(ap);
13 years ago
return n;
13 years ago
}
13 years ago
int main()
13 years ago
{
return (mytest("Hello%d\n", 1));
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of vsprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_vsprintf_void"
13 years ago
SFLAGS="$SFLAGS -DHAS_vsprintf_void"
13 years ago
echo "Checking for return value of vsprintf()... No."
echo " WARNING: apparently vsprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
fi
else
13 years ago
echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()."
13 years ago
cat >$test.c <<EOF
#include <stdio.h>
13 years ago
int mytest()
13 years ago
{
char buf[20];
snprintf(buf, sizeof(buf), "%s", "foo");
return 0;
}
13 years ago
int main()
13 years ago
{
return (mytest());
}
EOF
13 years ago
if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
13 years ago
echo "Checking for snprintf() in stdio.h... Yes."
cat >$test.c <<EOF
#include <stdio.h>
13 years ago
int mytest()
13 years ago
{
char buf[20];
13 years ago
return snprintf(buf, sizeof(buf), "%s", "foo");
13 years ago
}
13 years ago
int main()
13 years ago
{
return (mytest());
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of snprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_snprintf_void"
13 years ago
SFLAGS="$SFLAGS -DHAS_snprintf_void"
13 years ago
echo "Checking for return value of snprintf()... No."
echo " WARNING: apparently snprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
else
CFLAGS="$CFLAGS -DNO_snprintf"
13 years ago
SFLAGS="$SFLAGS -DNO_snprintf"
13 years ago
echo "Checking for snprintf() in stdio.h... No."
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib"
echo " can build but will be open to possible buffer-overflow security"
echo " vulnerabilities."
cat >$test.c <<EOF
#include <stdio.h>
13 years ago
int mytest()
13 years ago
{
char buf[20];
13 years ago
return sprintf(buf, "%s", "foo");
13 years ago
}
13 years ago
int main()
13 years ago
{
return (mytest());
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of sprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_sprintf_void"
13 years ago
SFLAGS="$SFLAGS -DHAS_sprintf_void"
13 years ago
echo "Checking for return value of sprintf()... No."
echo " WARNING: apparently sprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
fi
fi
13 years ago
if test "$gcc" -eq 1; then
cat > $test.c <<EOF
#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33)
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
#else
# define ZLIB_INTERNAL
#endif
int ZLIB_INTERNAL foo;
13 years ago
int main()
{
return 0;
}
EOF
13 years ago
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for attribute(visibility) support... Yes."
else
CFLAGS="$CFLAGS -DNO_VIZ"
SFLAGS="$SFLAGS -DNO_VIZ"
echo "Checking for attribute(visibility) support... No."
fi
13 years ago
fi
13 years ago
CPP=${CPP-"$CC -E"}
case $CFLAGS in
*ASMV*)
13 years ago
if test "`$NM $test.o | grep _hello`" = ""; then
13 years ago
CPP="$CPP -DNO_UNDERLINE"
echo Checking for underline in external names... No.
else
echo Checking for underline in external names... Yes.
13 years ago
fi ;;
13 years ago
esac
rm -f $test.[co] $test $test$shared_ext $test.gcno
13 years ago
13 years ago
# udpate Makefile
sed < Makefile.in "
13 years ago
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
13 years ago
/^SFLAGS *=/s#=.*#=$SFLAGS#
13 years ago
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
13 years ago
/^LDSHARED *=/s#=.*#=$LDSHARED#
13 years ago
/^CPP *=/s#=.*#=$CPP#
13 years ago
/^STATICLIB *=/s#=.*#=$STATICLIB#
13 years ago
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
/^AR *=/s#=.*#=$AR#
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
13 years ago
/^RANLIB *=/s#=.*#=$RANLIB#
13 years ago
/^LDCONFIG *=/s#=.*#=$LDCONFIG#
/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
13 years ago
/^EXE *=/s#=.*#=$EXE#
13 years ago
/^prefix *=/s#=.*#=$prefix#
/^exec_prefix *=/s#=.*#=$exec_prefix#
/^libdir *=/s#=.*#=$libdir#
13 years ago
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
13 years ago
/^includedir *=/s#=.*#=$includedir#
/^mandir *=/s#=.*#=$mandir#
/^OBJC *=/s#=.*#= $OBJC#
/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
13 years ago
/^all: */s#:.*#: $ALL#
/^test: */s#:.*#: $TEST#
13 years ago
" > Makefile
13 years ago
sed < zlib.pc.in "
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^CPP *=/s#=.*#=$CPP#
/^LDSHARED *=/s#=.*#=$LDSHARED#
13 years ago
/^STATICLIB *=/s#=.*#=$STATICLIB#
13 years ago
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
/^AR *=/s#=.*#=$AR#
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
13 years ago
/^RANLIB *=/s#=.*#=$RANLIB#
/^EXE *=/s#=.*#=$EXE#
/^prefix *=/s#=.*#=$prefix#
/^exec_prefix *=/s#=.*#=$exec_prefix#
/^libdir *=/s#=.*#=$libdir#
13 years ago
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
13 years ago
/^includedir *=/s#=.*#=$includedir#
/^mandir *=/s#=.*#=$mandir#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
" | sed -e "
s/\@VERSION\@/$VER/g;
" > zlib.pc