configure: misc tweaks to be more cross compiler friendly.

This commit is contained in:
Juan RP 2013-03-03 08:12:09 +01:00
parent c50cbf03c7
commit a517124eae

20
configure vendored
View File

@ -181,21 +181,12 @@ echo "CFLAGS = -O2 -pthread" >>$CONFIG_MK
if [ -n "$CFLAGS" ]; then
echo "CFLAGS += $CFLAGS" >>$CONFIG_MK
fi
# Find out if we are cross compiling and use sysroot's value from gcc.
_SYSROOT="$($CC --print-sysroot)"
if [ -n "${_SYSROOT}" -a "${_SYSROOT}" != "" ]; then
_INCDIR="${_SYSROOT}/include"
_LIBDIR="${_SYSROOT}/lib"
else
_INCDIR="$EPREFIX/include"
_LIBDIR="$LIBDIR"
fi
echo "LDFLAGS = -L\$(TOPDIR)/lib -L${_LIBDIR}" >>$CONFIG_MK
echo "LDFLAGS = -L\$(TOPDIR)/lib" >>$CONFIG_MK
if [ -n "$LDFLAGS" ]; then
echo "LDFLAGS += $LDFLAGS" >>$CONFIG_MK
fi
echo "CPPFLAGS = -I. -I\$(TOPDIR) -I\$(TOPDIR)/include -I${_INCDIR}" >>$CONFIG_MK
echo "CPPFLAGS = -I. -I\$(TOPDIR) -I\$(TOPDIR)/include" >>$CONFIG_MK
echo "CPPFLAGS += -DHAVE_CONFIG_H" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_SYSCONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_VERSION=\\\"${VERSION}\\\"" >>$CONFIG_MK
@ -223,9 +214,7 @@ linux)
esac
# Add CPPFLAGS/CFLAGS/LDFLAGS to CC for testing features
XCC="$CC `$SED -n -e 's/CPPLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
XCC="$XCC `$SED -n -e 's/CFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
XCC="$XCC `$SED -n -e 's/LDFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
XCC="$CC $CFLAGS $CPPFLAGS $LDFLAGS"
# Make sure to disable --as-needed for CC tests.
XCC="$XCC -Wl,--no-as-needed"
@ -327,14 +316,13 @@ fi
func=vasprintf
printf "Checking for $func() ... "
cat <<EOF >_$func.c
#define _GNU_SOURCE
#include <stdio.h>
int main(void) {
vasprintf(NULL, NULL, NULL);
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
if $XCC -D_GNU_SOURCE _$func.c -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_VASPRINTF" >> $CONFIG_MK
else