summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Korsgaard <jacmet@sunsite.dk>2010-04-21 10:40:30 +0200
committerPeter Korsgaard <jacmet@sunsite.dk>2010-04-21 10:40:30 +0200
commitfd3194a1c639c0b563a136ec9695c5212a71c1b9 (patch)
treeca8b3625dc2cad45f1b520a099769b75ccd4bff0
parent78de2495586409d134b1be8c2ba21de5546adc10 (diff)
parent55098e50488eeb163af8f63445bd3e7c52850410 (diff)
Merge branch 'codesourcery-toolchain-support' of git://git.busybox.net/~tpetazzoni/git/buildroot
-rw-r--r--package/Makefile.in22
-rw-r--r--package/busybox/busybox-1.13.x.config1
-rw-r--r--package/busybox/busybox.mk8
-rw-r--r--toolchain/external-toolchain/ext-tool.mk109
4 files changed, 106 insertions, 34 deletions
diff --git a/package/Makefile.in b/package/Makefile.in
index 983caf38e..3dfc712da 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -34,16 +34,7 @@ ifeq ($(BR2_DEBUG_3),y)
TARGET_DEBUGGING=-g3
endif
-
-#########################################################################
-ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
-TARGET_CFLAGS=$(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) \
- -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
-TARGET_LDFLAGS+=-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib
-ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
-TARGET_CFLAGS+= $(BR2_SYSROOT) $(BR2_ISYSROOT)
-TARGET_LDFLAGS+= $(BR2_SYSROOT)
-endif
+TARGET_CFLAGS=$(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
CC_TARGET_TUNE_:=$(call qstrip,$(BR2_GCC_TARGET_TUNE))
CC_TARGET_ARCH_:=$(call qstrip,$(BR2_GCC_TARGET_ARCH))
@@ -86,11 +77,20 @@ ifeq ($(BR2_LARGEFILE),y)
TARGET_CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
endif
+
+#########################################################################
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
+TARGET_CFLAGS+=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
+TARGET_LDFLAGS+=-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib
TARGET_CXXFLAGS=$(TARGET_CFLAGS)
+ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
+TARGET_CFLAGS+= $(BR2_SYSROOT) $(BR2_ISYSROOT)
+TARGET_LDFLAGS+= $(BR2_SYSROOT)
+endif
#########################################################################
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL),y)
-TARGET_CFLAGS=$(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) --sysroot $(STAGING_DIR)/
+TARGET_CFLAGS+=--sysroot $(STAGING_DIR)/
TARGET_CXXFLAGS=$(TARGET_CFLAGS)
TARGET_LDFLAGS=--sysroot $(STAGING_DIR)/
endif
diff --git a/package/busybox/busybox-1.13.x.config b/package/busybox/busybox-1.13.x.config
index ee591627b..059a0b3a3 100644
--- a/package/busybox/busybox-1.13.x.config
+++ b/package/busybox/busybox-1.13.x.config
@@ -47,6 +47,7 @@ CONFIG_FEATURE_SYSLOG=y
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
# CONFIG_LFS is not set
CONFIG_CROSS_COMPILER_PREFIX=""
+CONFIG_EXTRA_CFLAGS=""
#
# Debugging Options
diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index c93f33a01..05a6d941c 100644
--- a/package/busybox/busybox.mk
+++ b/package/busybox/busybox.mk
@@ -45,6 +45,8 @@ $(BUSYBOX_DIR)/.config: $(BUSYBOX_DIR)/.unpacked $(BUSYBOX_CONFIG_FILE)
cp -f $(BUSYBOX_CONFIG_FILE) $(BUSYBOX_DIR)/.config
$(SED) s,^CONFIG_PREFIX=.*,CONFIG_PREFIX=\"$(TARGET_DIR)\", \
$(BUSYBOX_DIR)/.config
+ $(SED) 's,^CONFIG_EXTRA_CFLAGS=.*,CONFIG_EXTRA_CFLAGS=\"$(BUSYBOX_CFLAGS)\",' \
+ $(BUSYBOX_DIR)/.config
# id applet breaks on >=1.13.0 with old uclibc unless the bb pwd routines are used
ifeq ($(BR2_BUSYBOX_VERSION_1_13_X)$(BR2_BUSYBOX_VERSION_1_14_X)$(BR2_UCLIBC_VERSION_0_9_28_3)$(BR2_UCLIBC_VERSION_0_9_29),yy)
if grep -q 'CONFIG_ID=y' $(BUSYBOX_DIR)/.config; \
@@ -105,15 +107,13 @@ endif
$(BUSYBOX_DIR)/busybox: $(BUSYBOX_DIR)/.config
$(MAKE) CC=$(TARGET_CC) CROSS_COMPILE="$(TARGET_CROSS)" \
CROSS="$(TARGET_CROSS)" PREFIX="$(TARGET_DIR)" \
- ARCH=$(KERNEL_ARCH) \
- EXTRA_CFLAGS="$(BUSYBOX_CFLAGS)" -C $(BUSYBOX_DIR)
+ ARCH=$(KERNEL_ARCH) -C $(BUSYBOX_DIR)
$(TARGET_DIR)/bin/busybox: $(BUSYBOX_DIR)/busybox
ifeq ($(BR2_PACKAGE_BUSYBOX_FULLINSTALL),y)
$(MAKE) CC=$(TARGET_CC) CROSS_COMPILE="$(TARGET_CROSS)" \
CROSS="$(TARGET_CROSS)" PREFIX="$(TARGET_DIR)" \
- ARCH=$(KERNEL_ARCH) \
- EXTRA_CFLAGS="$(BUSYBOX_CFLAGS)" -C $(BUSYBOX_DIR) install
+ ARCH=$(KERNEL_ARCH) -C $(BUSYBOX_DIR) install
else
install -D -m 0755 $(BUSYBOX_DIR)/busybox $(TARGET_DIR)/bin/busybox
endif
diff --git a/toolchain/external-toolchain/ext-tool.mk b/toolchain/external-toolchain/ext-tool.mk
index 449328131..2c2562cde 100644
--- a/toolchain/external-toolchain/ext-tool.mk
+++ b/toolchain/external-toolchain/ext-tool.mk
@@ -1,7 +1,13 @@
+
#
# This file implements the support for external toolchains, i.e
# toolchains that have not been produced by Buildroot itself and that
-# are already available on the system on which Buildroot runs.
+# are already available on the system on which Buildroot runs. So far,
+# we have tested this with:
+#
+# * Toolchains generated by Crosstool-NG
+# * Toolchains generated by Buildroot
+# * ARM toolchains made available by Codesourcery
#
# The basic principle is the following
#
@@ -34,38 +40,39 @@
# directory to the target directory. Also optionaly strips the
# library.
#
-# $1: sysroot directory
+# $1: arch specific sysroot directory
# $2: library name
# $3: destination directory
# $4: strip (y|n), default is to strip
#
copy_toolchain_lib_root = \
- SYSROOT_DIR="$(strip $1)"; \
+ ARCH_SYSROOT_DIR="$(strip $1)"; \
LIB="$(strip $2)"; \
- DST="$(strip $3)"; \
STRIP="$(strip $4)"; \
\
- LIB_DIR="$${SYSROOT_DIR}/lib" ; \
- for FILE in `find $${LIB_DIR} -maxdepth 1 -name "$${LIB}.*"`; do \
+ LIBS=`(cd $${ARCH_SYSROOT_DIR}; find . -path "./lib/$${LIB}.*" -o -path "./usr/lib/$${LIB}.*")` ; \
+ for FILE in $${LIBS} ; do \
LIB=`basename $${FILE}`; \
+ LIBDIR=`dirname $${FILE}` ; \
while test \! -z "$${LIB}"; do \
- rm -fr $(TARGET_DIR)$${DST}/$${LIB}; \
- mkdir -p $(TARGET_DIR)$${DST}; \
- if test -h $${LIB_DIR}/$${LIB}; then \
- cp -d $${LIB_DIR}/$${LIB} $(TARGET_DIR)$${DST}/; \
- elif test -f $${LIB_DIR}/$${LIB}; then \
- $(INSTALL) -D -m0755 $${LIB_DIR}/$${LIB} $(TARGET_DIR)$${DST}/$${LIB}; \
+ FULLPATH="$${ARCH_SYSROOT_DIR}/$${LIBDIR}/$${LIB}" ; \
+ rm -fr $(TARGET_DIR)/$${LIBDIR}/$${LIB}; \
+ mkdir -p $(TARGET_DIR)/$${LIBDIR}; \
+ if test -h $${FULLPATH} ; then \
+ cp -d $${FULLPATH} $(TARGET_DIR)/$${LIBDIR}/; \
+ elif test -f $${FULLPATH}; then \
+ $(INSTALL) -D -m0755 $${FULLPATH} $(TARGET_DIR)/$${LIBDIR}/$${LIB}; \
case "$${STRIP}" in \
(0 | n | no) \
;; \
(*) \
- $(TARGET_CROSS)strip "$(TARGET_DIR)$${DST}/$${LIB}"; \
+ $(TARGET_CROSS)strip "$(TARGET_DIR)/$${LIBDIR}/$${LIB}"; \
;; \
esac; \
else \
exit -1; \
fi; \
- LIB="`readlink $${LIB_DIR}/$${LIB}`"; \
+ LIB="`readlink $${FULLPATH}`"; \
done; \
done; \
\
@@ -73,13 +80,54 @@ copy_toolchain_lib_root = \
#
# Copy the full external toolchain sysroot directory to the staging
-# dir
+# dir. The operation of this function is rendered a little bit
+# complicated by the support for multilib toolchains.
#
-# $1: sysroot directory
+# We start by copying etc, lib, sbin and usr from the sysroot of the
+# selected architecture variant (as pointed by ARCH_SYSROOT_DIR). This
+# allows to import into the staging directory the C library and
+# companion libraries for the correct architecture variant. We
+# explictly only copy etc, lib, sbin and usr since other directories
+# might exist for other architecture variants (on Codesourcery
+# toolchain, the sysroot for the default architecture variant contains
+# the armv4t and thumb2 subdirectories, which are the sysroot for the
+# corresponding architecture variants), and we don't want to import
+# them.
+#
+# Then, if the selected architecture variant is not the default one
+# (i.e, if SYSROOT_DIR != ARCH_SYSROOT_DIR), then we :
+#
+# * Import the header files from the default architecture
+# variant. Header files are typically shared between the sysroots
+# for the different architecture variants. If we use the
+# non-default one, header files were not copied by the previous
+# step, so we copy them here from the sysroot of the default
+# architecture variant.
+#
+# * Create a symbolic link that matches the name of the subdirectory
+# for the architecture variant in the original sysroot. This is
+# required as the compiler will by default look in
+# sysroot_dir/arch_variant/ for libraries and headers, when the
+# non-default architecture variant is used. Without this, the
+# compiler fails to find libraries and headers.
+#
+# $1: main sysroot directory of the toolchain
+# $2: arch specific sysroot directory of the toolchain
+# $3: arch specific subdirectory in the sysroot
#
copy_toolchain_sysroot = \
SYSROOT_DIR="$(strip $1)"; \
- cp -a $${SYSROOT_DIR}/* $(STAGING_DIR)/ ; \
+ ARCH_SYSROOT_DIR="$(strip $2)"; \
+ ARCH_SUBDIR="$(strip $3)"; \
+ for i in etc lib sbin usr ; do \
+ cp -a $${ARCH_SYSROOT_DIR}/$$i $(STAGING_DIR)/ ; \
+ done ; \
+ if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \
+ if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
+ cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
+ fi ; \
+ ln -s . $(STAGING_DIR)/$(ARCH_SUBDIR) ; \
+ fi ; \
find $(STAGING_DIR) -type d | xargs chmod 755
#
@@ -205,7 +253,30 @@ ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
EXTERNAL_LIBS+=libstdc++.so
endif
+# SYSROOT_DIR selection. We first try the -print-sysroot option,
+# available in gcc 4.4.x and in some Codesourcery toolchains. If this
+# option is not available, we fallback to the value of --with-sysroot
+# as visible in CROSS-gcc -v. We don't pass the -march= option to gcc
+# as we want the "main" sysroot, which contains all variants of the C
+# library in the case of multilib toolchains.
+SYSROOT_DIR=$(shell $(TARGET_CC) -print-sysroot 2>/dev/null)
+ifeq ($(SYSROOT_DIR),)
SYSROOT_DIR=$(shell readlink -f $$(LANG=C $(TARGET_CC) -print-file-name=libc.a |sed -r -e 's:usr/lib/libc\.a::;'))
+endif
+
+# Now, find if the toolchain specifies a sub-directory for the
+# specific architecture variant we're interested in. This is the case
+# with multilib toolchain, when the selected architecture variant is
+# not the default one. To do so, we ask the compiler by passing the
+# appropriate -march= flags. ARCH_SUBDIR will contain the
+# subdirectory, in the main SYSROOT_DIR, that corresponds to the
+# selected architecture variant. ARCH_SYSROOT_DIR will contain the
+# full path to this location.
+ifneq ($(CC_TARGET_ARCH_),)
+TARGET_CC_ARCH_CFLAGS+=-march=$(CC_TARGET_ARCH_)
+endif
+ARCH_SUBDIR=$(shell $(TARGET_CC) $(TARGET_CC_ARCH_CFLAGS) -print-multi-directory)
+ARCH_SYSROOT_DIR=$(SYSROOT_DIR)/$(ARCH_SUBDIR)
$(STAMP_DIR)/ext-toolchain-installed:
@echo "Checking external toolchain settings"
@@ -225,8 +296,8 @@ endif
mkdir -p $(TARGET_DIR)/lib
@echo "Copy external toolchain libraries to target..."
$(Q)for libs in $(EXTERNAL_LIBS); do \
- $(call copy_toolchain_lib_root,$(SYSROOT_DIR),$$libs,/lib,$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
+ $(call copy_toolchain_lib_root,$(ARCH_SYSROOT_DIR),$$libs,$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
done
@echo "Copy external toolchain sysroot to staging..."
- $(Q)$(call copy_toolchain_sysroot,$(SYSROOT_DIR))
+ $(Q)$(call copy_toolchain_sysroot,$(SYSROOT_DIR),$(ARCH_SYSROOT_DIR),$(ARCH_SUBDIR))
@touch $@