external toolchain: fix sysroot location if the toolchain was moved
authorYann E. MORIN <yann.morin.1998@anciens.enib.fr>
Wed, 24 Mar 2010 22:42:42 +0000 (23:42 +0100)
committerPeter Korsgaard <jacmet@sunsite.dk>
Wed, 31 Mar 2010 08:50:40 +0000 (10:50 +0200)
Sysrooted toolchain can be relocated. In this case, the sysroot is no
longer located at the place it was configured at.

Signed-off-by: Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
Acked-By: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
toolchain/external-toolchain/ext-tool.mk

index 1f5aa19322d0a90db916bfb859353a8a389cfa3e..80bdae63b5cb2fd1f90058da403fd519c3aacf27 100644 (file)
@@ -205,7 +205,14 @@ ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
 EXTERNAL_LIBS+=libstdc++.so
 endif
 
-SYSROOT_DIR=$(shell LANG=C $(TARGET_CC) -v 2>&1 | grep ^Configured | tr " " "\n" | grep -- "--with-sysroot" | cut -f2 -d=)
+# This dance is needed because the toolchain may have been relocated, so the
+# configured paths may no longer match; fortunately, the sysroot moves along
+# the toolchain, so is always at the same place relative to the toolchain's
+# current location.
+CFG_PREFIX_DIR=$(shell LANG=C $(TARGET_CC) -v 2>&1 | grep ^Configured | tr " " "\n" | grep -- "--prefix=" | cut -f2 -d=)
+CFG_SYSROOT_DIR=$(shell LANG=C $(TARGET_CC) -v 2>&1 | grep ^Configured | tr " " "\n" | grep -- "--with-sysroot=" | cut -f2 -d=)
+REL_SYSROOT_DIR=$(shell echo "$(CFG_SYSROOT_DIR)" |sed -r -e 's:^$(CFG_PREFIX_DIR)::;')
+SYSROOT_DIR=$(TOOLCHAIN_EXTERNAL_PATH)/$(REL_SYSROOT_DIR)
 
 $(STAMP_DIR)/ext-toolchain-installed:
        @echo "Checking external toolchain settings"