# toolchain logic, and the glibc package, so care must be taken when
# changing this function.
#
-# 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}
-#
-# Linaro toolchains have most libraries in lib/<target-name>/, so we
-# need to search libraries in:
-#
-# $${ARCH_LIB_DIR}/$(TOOLCHAIN_EXTERNAL_PREFIX)
-#
-# And recent Linaro toolchains have the GCC support libraries
-# (libstdc++, libgcc_s, etc.) into a separate directory, outside of
-# the sysroot, that we called the "SUPPORT_LIB_DIR", into which we
-# need to search as well.
-#
-# 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: support libraries directory (can be empty)
-# $3: library directory ('lib' or 'lib64') from which libraries must be copied
-# $4: library name
-# $5: destination directory of the libary, relative to $(TARGET_DIR)
+# $1: library name
#
copy_toolchain_lib_root = \
- ARCH_SYSROOT_DIR="$(strip $1)"; \
- SUPPORT_LIB_DIR="$(strip $2)" ; \
- ARCH_LIB_DIR="$(strip $3)" ; \
- LIB="$(strip $4)"; \
- DESTDIR="$(strip $5)" ; \
+ LIB="$(strip $1)"; \
\
- for dir in \
- $${ARCH_SYSROOT_DIR}/$${ARCH_LIB_DIR}/$(TOOLCHAIN_EXTERNAL_PREFIX) \
- $${ARCH_SYSROOT_DIR}/usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/$${ARCH_LIB_DIR} \
- $${ARCH_SYSROOT_DIR}/$${ARCH_LIB_DIR} \
- $${ARCH_SYSROOT_DIR}/usr/$${ARCH_LIB_DIR} \
- $${SUPPORT_LIB_DIR} ; do \
- LIBPATHS=`find $${dir} -maxdepth 1 -name "$${LIB}" 2>/dev/null` ; \
- if test -n "$${LIBPATHS}" ; then \
- break ; \
- fi \
- done ; \
- mkdir -p $(TARGET_DIR)/$${DESTDIR}; \
+ LIBPATHS=`find -L $(STAGING_DIR) -name "$${LIB}" 2>/dev/null` ; \
for LIBPATH in $${LIBPATHS} ; do \
+ DESTDIR=`echo $${LIBPATH} | sed "s,^$(STAGING_DIR)/,," | xargs dirname` ; \
+ mkdir -p $(TARGET_DIR)/$${DESTDIR}; \
while true ; do \
LIBNAME=`basename $${LIBPATH}`; \
LIBDIR=`dirname $${LIBPATH}` ; \
# our sysroot, and the directory will also be
# considered when searching libraries for copy
# to the target filesystem.
+#
+# Please be very careful to check the major toolchain sources:
+# Buildroot, Crosstool-NG, CodeSourcery and Linaro
+# before doing any modification on the below logic.
+ifeq ($(BR2_STATIC_LIBS),)
define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS
- $(Q)ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
- ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
- SUPPORT_LIB_DIR="" ; \
- if test `find $${ARCH_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
- LIBSTDCPP_A_LOCATION=$$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
- if [ -e "$${LIBSTDCPP_A_LOCATION}" ]; then \
- SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
- fi ; \
- fi ; \
- if test -z "$(BR2_STATIC_LIBS)" ; then \
- $(call MESSAGE,"Copying external toolchain libraries to target...") ; \
- for libs in $(LIB_EXTERNAL_LIBS); do \
- $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/lib); \
- done ; \
- for libs in $(USR_LIB_EXTERNAL_LIBS); do \
- $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/usr/lib); \
- done ; \
- fi
+ $(Q)$(call MESSAGE,"Copying external toolchain libraries to target...") ; \
+ for libs in $(LIB_EXTERNAL_LIBS) $(USR_LIB_EXTERNAL_LIBS); do \
+ $(call copy_toolchain_lib_root,$$libs); \
+ done
endef
+endif
ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY),y)
define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_GDBSERVER
endef
define TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FDPIC
$(Q)$(call MESSAGE,"Install external toolchain FDPIC libraries to target...") ; \
- FDPIC_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))/../../bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc ; \
- FDPIC_SYSROOT_DIR="$(call toolchain_find_sysroot,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
- FDPIC_LIB_DIR="$(call toolchain_find_libdir,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
- FDPIC_SUPPORT_LIB_DIR="" ; \
- if test `find $${FDPIC_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
- FDPIC_LIBSTDCPP_A_LOCATION=$$(LANG=C $${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
- if [ -e "$${FDPIC_LIBSTDCPP_A_LOCATION}" ]; then \
- FDPIC_SUPPORT_LIB_DIR=`readlink -f $${FDPIC_LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
- fi ; \
- fi ; \
- for libs in $(LIB_EXTERNAL_LIBS); do \
- $(call copy_toolchain_lib_root,$${FDPIC_SYSROOT_DIR},$${FDPIC_SUPPORT_LIB_DIR},$${FDPIC_LIB_DIR},$$libs,/lib); \
- done ; \
- for libs in $(USR_LIB_EXTERNAL_LIBS); do \
- $(call copy_toolchain_lib_root,$${FDPIC_SYSROOT_DIR},$${FDPIC_SUPPORT_LIB_DIR},$${FDPIC_LIB_DIR},$$libs,/usr/lib); \
+ for libs in $(LIB_EXTERNAL_LIBS) $(USR_LIB_EXTERNAL_LIBS); do \
+ $(call copy_toolchain_lib_root,$$libs); \
done
endef
endif