summaryrefslogtreecommitdiff
path: root/toolchain/helpers.mk
diff options
context:
space:
mode:
Diffstat (limited to 'toolchain/helpers.mk')
-rw-r--r--toolchain/helpers.mk55
1 files changed, 43 insertions, 12 deletions
diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 65cc9982d..bb1ea9040 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -7,22 +7,44 @@
# directory to the target directory. Also optionaly strips the
# library.
#
-# Most toolchains have their libraries either in /lib or /usr/lib
-# relative to their ARCH_SYSROOT_DIR. Buildroot toolchains, however,
-# have basic libraries in /lib, and libstdc++/libgcc_s in
-# /usr/<target-name>/lib(64).
+# Most toolchains (CodeSourcery ones) have their libraries either in
+# /lib or /usr/lib relative to their ARCH_SYSROOT_DIR, so we search
+# libraries in:
+#
+# $${ARCH_LIB_DIR}
+# usr/$${ARCH_LIB_DIR}
+#
+# Buildroot toolchains, however, have basic libraries in /lib, and
+# libstdc++/libgcc_s in /usr/<target-name>/lib(64), so we also need to
+# search libraries in:
+#
+# usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/$${ARCH_LIB_DIR}
+#
+# Finally, Linaro toolchains have the libraries in lib/<target-name>/,
+# so we need to search libraries in:
+#
+# $${ARCH_LIB_DIR}/$(TOOLCHAIN_EXTERNAL_PREFIX)
+#
+# Thanks to ARCH_LIB_DIR we also take into account toolchains that
+# have the libraries in lib64 and usr/lib64.
+#
+# Please be very careful to check the major toolchain sources:
+# Buildroot, Crosstool-NG, CodeSourcery and Linaro before doing any
+# modification on the below logic.
#
# $1: arch specific sysroot directory
-# $2: library name
-# $3: destination directory of the libary, relative to $(TARGET_DIR)
+# $2: library directory ('lib' or 'lib64') from which libraries must be copied
+# $3: library name
+# $4: destination directory of the libary, relative to $(TARGET_DIR)
#
copy_toolchain_lib_root = \
ARCH_SYSROOT_DIR="$(strip $1)"; \
- LIB="$(strip $2)"; \
- DESTDIR="$(strip $3)" ; \
+ ARCH_LIB_DIR="$(strip $2)" ; \
+ LIB="$(strip $3)"; \
+ DESTDIR="$(strip $4)" ; \
\
LIBS=`(cd $${ARCH_SYSROOT_DIR}; \
- find -L lib* usr/lib* usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/lib* \
+ find -L $${ARCH_LIB_DIR} usr/$${ARCH_LIB_DIR} usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/$${ARCH_LIB_DIR} $${ARCH_LIB_DIR}/$(TOOLCHAIN_EXTERNAL_PREFIX) \
-maxdepth 1 -name "$${LIB}.*" 2>/dev/null \
)` ; \
for FILE in $${LIBS} ; do \
@@ -84,12 +106,14 @@ copy_toolchain_lib_root = \
# $1: main sysroot directory of the toolchain
# $2: arch specific sysroot directory of the toolchain
# $3: arch specific subdirectory in the sysroot
+# $4: directory of libraries ('lib' or 'lib64')
#
copy_toolchain_sysroot = \
SYSROOT_DIR="$(strip $1)"; \
ARCH_SYSROOT_DIR="$(strip $2)"; \
ARCH_SUBDIR="$(strip $3)"; \
- for i in etc lib sbin usr ; do \
+ ARCH_LIB_DIR="$(strip $4)" ; \
+ for i in etc $${ARCH_LIB_DIR} sbin usr ; do \
if [ -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
rsync -au --chmod=Du+w --exclude 'usr/lib/locale' $${ARCH_SYSROOT_DIR}/$$i $(STAGING_DIR)/ ; \
fi ; \
@@ -98,7 +122,14 @@ copy_toolchain_sysroot = \
if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
fi ; \
- ln -s . $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
+ mkdir -p `dirname $(STAGING_DIR)/$${ARCH_SUBDIR}` ; \
+ relpath="./" ; \
+ nbslashs=`echo -n $${ARCH_SUBDIR} | sed 's%[^/]%%g' | wc -c` ; \
+ for slash in `seq 1 $${nbslashs}` ; do \
+ relpath=$${relpath}"../" ; \
+ done ; \
+ ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
+ echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \
fi ; \
find $(STAGING_DIR) -type d | xargs chmod 755
@@ -184,7 +215,7 @@ check_uclibc_feature = \
#
check_uclibc = \
SYSROOT_DIR="$(strip $1)"; \
- if ! test -f $${SYSROOT_DIR}/lib/ld*-uClibc.so.* ; then \
+ if ! test -f $${SYSROOT_DIR}/usr/include/bits/uClibc_config.h ; then \
echo "Incorrect selection of the C library"; \
exit -1; \
fi; \