From e9e704d59addf51796744e075d86fc43dc9eb2b5 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 6 Feb 2013 18:41:44 +0100 Subject: [PATCH] configure: use gcc --print-sysroot to behave correctly in cross builds. --- NEWS | 3 +++ configure | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 47658720..43659d40 100644 --- a/NEWS +++ b/NEWS @@ -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. diff --git a/configure b/configure index ffc294ca..c11dbf5c 100755 --- a/configure +++ b/configure @@ -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