@@ -444,20 +444,10 @@ world: target-post-image
$(BUILD_DIR) $(TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
@mkdir -p $@
-# We make a symlink lib32->lib or lib64->lib as appropriate
-# MIPS64/n32 requires lib32 even though it's a 64-bit arch.
-ifeq ($(BR2_ARCH_IS_64)$(BR2_MIPS_NABI32),y)
-LIB_SYMLINK = lib64
-else
-LIB_SYMLINK = lib32
-endif
-
$(STAGING_DIR):
@mkdir -p $(STAGING_DIR)/bin
@mkdir -p $(STAGING_DIR)/lib
- @ln -snf lib $(STAGING_DIR)/$(LIB_SYMLINK)
@mkdir -p $(STAGING_DIR)/usr/lib
- @ln -snf lib $(STAGING_DIR)/usr/$(LIB_SYMLINK)
@mkdir -p $(STAGING_DIR)/usr/include
@mkdir -p $(STAGING_DIR)/usr/bin
@ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
@@ -62,4 +62,21 @@ HOST_GCC_INITIAL_MAKE_OPTS += all-target-libgcc
HOST_GCC_INITIAL_INSTALL_OPTS += install-target-libgcc
endif
+# The creation of lib32/lib64 symlinks into target and staging directories
+# needs to be done before the C library is installed. Hooking into the libc
+# hooks directly is tricky because there are multiple C libraries supported.
+# Instead, hook into the install step of host-gcc-initial.
+#
+# MIPS64/n32 requires lib32 even though it's a 64-bit arch.
+ifeq ($(BR2_ARCH_IS_64)$(BR2_MIPS_NABI32),y)
+HOST_GCC_INITIAL_LIB_SYMLINK = lib64
+else
+HOST_GCC_INITIAL_LIB_SYMLINK = lib32
+endif
+define HOST_GCC_INITIAL_CREATE_STAGING_TARGET_SYMLINK
+ $(Q)$(call create_lib_symlinks,$(HOST_GCC_INITIAL_LIB_SYMLINK),$(STAGING_DIR))
+ $(Q)$(call create_lib_symlinks,$(HOST_GCC_INITIAL_LIB_SYMLINK),$(TARGET_DIR))
+endef
+HOST_GCC_INITIAL_POST_INSTALL_HOOKS += HOST_GCC_INITIAL_CREATE_STAGING_TARGET_SYMLINK
+
$(eval $(host-autotools-package))
@@ -25,9 +25,6 @@ define SKELETON_INSTALL_TARGET_CMDS
$(SKELETON_PATH)/ $(TARGET_DIR)/
$(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
$(TARGET_DIR_WARNING_FILE)
- ln -snf lib $(TARGET_DIR)/$(LIB_SYMLINK)
- mkdir -p $(TARGET_DIR)/usr
- ln -snf lib $(TARGET_DIR)/usr/$(LIB_SYMLINK)
endef
SKELETON_TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
@@ -1,5 +1,18 @@
# This Makefile fragment declares toolchain related helper functions.
+# Create the necessary symlink from (usr/)lib32|lib64|lib32-fp|... to lib
+# In general, for external toolchains, the correct link name is $ARCH_LIB_DIR.
+# $1: link name
+# $2: destination directory (TARGET_DIR / STAGING_DIR)
+create_lib_symlinks = \
+ LIB_SYMLINK="$(strip $1)" ; \
+ DESTDIR="$(strip $2)" ; \
+ if [ "$${LIB_SYMLINK}" != "lib" ]; then \
+ mkdir -p "$${DESTDIR}/usr" ; \
+ ln -snf lib "$${DESTDIR}/$${LIB_SYMLINK}" ; \
+ ln -snf lib "$${DESTDIR}/usr/$${LIB_SYMLINK}" ; \
+ fi
+
# The copy_toolchain_lib_root function copies a toolchain library and
# its symbolic links from the sysroot directory to the target
# directory. Note that this function is used both by the external
@@ -615,6 +615,16 @@ define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS
$(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR})
endef
+define TOOLCHAIN_EXTERNAL_CREATE_STAGING_LIB_SYMLINK
+ $(Q)ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
+ $(call create_lib_symlinks,$${ARCH_LIB_DIR},$(STAGING_DIR))
+endef
+
+define TOOLCHAIN_EXTERNAL_CREATE_TARGET_LIB_SYMLINK
+ $(Q)ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
+ $(call create_lib_symlinks,$${ARCH_LIB_DIR},$(TARGET_DIR))
+endef
+
# Special installation target used on the Blackfin architecture when
# FDPIC is not the primary binary format being used, but the user has
# nonetheless requested the installation of the FDPIC libraries to the
@@ -733,6 +743,7 @@ define TOOLCHAIN_EXTERNAL_FIXUP_UCLIBCNG_LDSO
endef
define TOOLCHAIN_EXTERNAL_INSTALL_STAGING_CMDS
+ $(TOOLCHAIN_EXTERNAL_CREATE_STAGING_LIB_SYMLINK)
$(TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS)
$(TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER)
$(TOOLCHAIN_EXTERNAL_INSTALL_GDBINIT)
@@ -742,6 +753,7 @@ endef
# and the target directory, we do everything within the
# install-staging step, arbitrarily.
define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_CMDS
+ $(TOOLCHAIN_EXTERNAL_CREATE_TARGET_LIB_SYMLINK)
$(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS)
$(TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FDPIC)
$(TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FLAT)