configure: use gcc --print-sysroot to behave correctly in cross builds.

This commit is contained in:
Juan RP 2013-02-06 18:41:44 +01:00
parent d8769c4873
commit e9e704d59a
2 changed files with 16 additions and 2 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.21 (???):
* configure: don't link to libs in PREFIX/lib blindly; figure out
sysroot dir with gcc compiler and use this for headers/libs.
* libxbps: workaround a bug (found by pancake) when updating a package
that is being replaced by a virtual package.

15
configure vendored
View File

@ -175,16 +175,27 @@ if [ -z "$CC" ]; then
else
echo "Using compiler $CC"
fi
echo "CC = $CC" >>$CONFIG_MK
echo "CFLAGS = -O2 -pthread" >>$CONFIG_MK
if [ -n "$CFLAGS" ]; then
echo "CFLAGS += $CFLAGS" >>$CONFIG_MK
fi
echo "LDFLAGS = -L\$(TOPDIR)/lib -L\$(LIBDIR)" >>$CONFIG_MK
# 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="$PREFIX/include"
_LIBDIR="$LIBDIR"
fi
echo "LDFLAGS = -L\$(TOPDIR)/lib -L${_LIBDIR}" >>$CONFIG_MK
if [ -n "$LDFLAGS" ]; then
echo "LDFLAGS += $LDFLAGS" >>$CONFIG_MK
fi
echo "CPPFLAGS = -I. -I\$(TOPDIR) -I\$(TOPDIR)/include" >>$CONFIG_MK
echo "CPPFLAGS = -I. -I\$(TOPDIR) -I\$(TOPDIR)/include -I${_INCDIR}" >>$CONFIG_MK
echo "CPPFLAGS += -DHAVE_CONFIG_H" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_SYSCONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_VERSION=\\\"${VERSION}\\\"" >>$CONFIG_MK