toolchain: Allow external toolchains to specify libthread-db
[openwrt/openwrt.git] / package / libs / toolchain / Makefile
index 120193ad50e3d0268356d31fa46a4571f33dafcc..8a90b5eda665803218bc0e1c1db9020bdf2855ce 100644 (file)
@@ -9,9 +9,11 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=toolchain
 PKG_RELEASE:=1
 
 PKG_NAME:=toolchain
 PKG_RELEASE:=1
 
-PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
 PKG_LICENSE:=GPL-3.0-with-GCC-exception
 
 PKG_LICENSE:=GPL-3.0-with-GCC-exception
 
+PKG_FLAGS:=hold essential nonshared
+
 include $(INCLUDE_DIR)/package.mk
 
 ifneq ($(DUMP),1)
 include $(INCLUDE_DIR)/package.mk
 
 ifneq ($(DUMP),1)
@@ -139,7 +141,6 @@ define Package/libc/Default
   VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
   DEPENDS:=+libgcc
   URL:=$(LIBC_URL)
   VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
   DEPENDS:=+libgcc
   URL:=$(LIBC_URL)
-  PKG_FLAGS:=hold essential
 endef
 
 
 endef
 
 
@@ -163,7 +164,7 @@ define Package/libc/config
                string
                prompt "libc shared library files (use wildcards)"
                depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
                string
                prompt "libc shared library files (use wildcards)"
                depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
-               default "./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
+               default "./lib/ld{*.so*,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
 
        endmenu
 endef
 
        endmenu
 endef
@@ -201,6 +202,26 @@ $(call Package/libc/Default)
   TITLE:=POSIX thread library debugging support
 endef
 
   TITLE:=POSIX thread library debugging support
 endef
 
+define Package/libthread-db/config
+       menu "Configuration"
+       depends on EXTERNAL_TOOLCHAIN && PACKAGE_libthread-db
+
+       config LIBTHREAD_DB_ROOT_DIR
+               string
+               prompt "POSIX thread debugging shared library base directory"
+               depends on EXTERNAL_TOOLCHAIN && PACKAGE_libthread-db
+               default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+               default "/"  if NATIVE_TOOLCHAIN
+
+       config LIBTHREAD_DB_FILE_SPEC
+               string
+               prompt "POSIX thread debugging shared library files (use wildcards)"
+               depends on EXTERNAL_TOOLCHAIN && PACKAGE_libthread-db
+               default "./lib/libthread_db{-*.so,.so.*}"
+
+       endmenu
+endef
+
 define Package/librt
 $(call Package/libc/Default)
   TITLE:=POSIX.1b RealTime extension library
 define Package/librt
 $(call Package/libc/Default)
   TITLE:=POSIX.1b RealTime extension library
@@ -322,9 +343,6 @@ LIBGCC_SO=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*))
 define Build/Compile/uClibc
        $(CP) \
                $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
 define Build/Compile/uClibc
        $(CP) \
                $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
-               $(TOOLCHAIN_DIR)/lib/libcrypt-*.so \
-               $(TOOLCHAIN_DIR)/lib/libm-*.so \
-               $(TOOLCHAIN_DIR)/lib/libpthread-*.so \
                $(PKG_BUILD_DIR)/
 endef
 ifneq ($(LIBGCC_SO),)
                $(PKG_BUILD_DIR)/
 endef
 ifneq ($(LIBGCC_SO),)
@@ -394,17 +412,8 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
                $(TOOLCHAIN_DIR)/lib/libc.so.* \
                $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
                $(1)/lib/
                $(TOOLCHAIN_DIR)/lib/libc.so.* \
                $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
                $(1)/lib/
-       for file in libcrypt libdl libm libutil; do \
-               $(CP) \
-                       $(TOOLCHAIN_DIR)/lib/$$$$file.so.* \
-                       $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so \
-                       $(1)/lib/; \
-       done
-
        $(CP) \
                $(PKG_BUILD_DIR)/libuClibc-* \
        $(CP) \
                $(PKG_BUILD_DIR)/libuClibc-* \
-               $(PKG_BUILD_DIR)/libm-* \
-               $(PKG_BUILD_DIR)/libcrypt-* \
                $(1)/lib/
   endef
 
                $(1)/lib/
   endef
 
@@ -436,7 +445,7 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
 
   define Package/libpthread/install
        $(INSTALL_DIR) $(1)/lib
 
   define Package/libpthread/install
        $(INSTALL_DIR) $(1)/lib
-  ifneq ($(CONFIG_USE_MUSL),y)
+  ifneq ($(CONFIG_USE_MUSL)$(CONFIG_USE_UCLIBC),y)
        $(CP) \
                $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
                $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
        $(CP) \
                $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
                $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
@@ -461,7 +470,7 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
 
   define Package/librt/install
        $(INSTALL_DIR) $(1)/lib
 
   define Package/librt/install
        $(INSTALL_DIR) $(1)/lib
-  ifneq ($(CONFIG_USE_MUSL),y)
+  ifneq ($(CONFIG_USE_MUSL)$(CONFIG_USE_UCLIBC),y)
        $(CP) \
                $(TOOLCHAIN_DIR)/lib/librt.so.* \
                $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
        $(CP) \
                $(TOOLCHAIN_DIR)/lib/librt.so.* \
                $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
@@ -483,71 +492,71 @@ else
 
   define Package/libgcc/install
        for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
 
   define Package/libgcc/install
        for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
-               dir=`dirname $$$$file` ; \
-               $(INSTALL_DIR) $(1)/$$$$dir ; \
-               $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+               $(INSTALL_DIR) $(1)/lib ; \
+               $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
        done ; \
        exit 0
   endef
 
   define Package/libgfortran/install
        for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
        done ; \
        exit 0
   endef
 
   define Package/libgfortran/install
        for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
-               dir=`dirname $$$$file` ; \
-               $(INSTALL_DIR) $(1)/$$$$dir ; \
-               $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+               $(INSTALL_DIR) $(1)/lib ; \
+               $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
        done
   endef
 
   define Package/libssp/install
        for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
        done
   endef
 
   define Package/libssp/install
        for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
-               dir=`dirname $$$$file` ; \
-               $(INSTALL_DIR) $(1)/$$$$dir ; \
-               $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+               $(INSTALL_DIR) $(1)/lib ; \
+               $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/lib/ ; \
        done ; \
        exit 0
   endef
 
   define Package/libstdcpp/install
        for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
        done ; \
        exit 0
   endef
 
   define Package/libstdcpp/install
        for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
-               dir=`dirname $$$$file` ; \
-               $(INSTALL_DIR) $(1)/$$$$dir ; \
-               $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+               $(INSTALL_DIR) $(1)/lib ; \
+               $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/lib/ ; \
        done ; \
        exit 0
   endef
 
   define Package/libc/install
        for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
        done ; \
        exit 0
   endef
 
   define Package/libc/install
        for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
-               dir=`dirname $$$$file` ; \
-               $(INSTALL_DIR) $(1)/$$$$dir ; \
-               $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+               $(INSTALL_DIR) $(1)/lib ; \
+               $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
        done ; \
        exit 0
   endef
 
   define Package/libpthread/install
        for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
        done ; \
        exit 0
   endef
 
   define Package/libpthread/install
        for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
-               dir=`dirname $$$$file` ; \
-               $(INSTALL_DIR) $(1)/$$$$dir ; \
-               $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+               $(INSTALL_DIR) $(1)/lib ; \
+               $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+       done ; \
+       exit 0
+  endef
+
+  define Package/libthread-db/install
+       for file in $(call qstrip,$(CONFIG_LIBTHREAD_DB_FILE_SPEC)); do \
+               $(INSTALL_DIR) $(1)/lib ; \
+               $(CP) $(call qstrip,$(CONFIG_LIBTHREAD_DB_ROOT_DIR))/$$$$file $(1)/lib/ ; \
        done ; \
        exit 0
   endef
 
   define Package/librt/install
        for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
        done ; \
        exit 0
   endef
 
   define Package/librt/install
        for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
-               dir=`dirname $$$$file` ; \
-               $(INSTALL_DIR) $(1)/$$$$dir ; \
-               $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+               $(INSTALL_DIR) $(1)/lib ; \
+               $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/lib/ ; \
        done ; \
        exit 0
   endef
 
   define Package/libatomic/install
        for file in $(call qstrip,$(CONFIG_LIBATOMIC_FILE_SPEC)); do \
        done ; \
        exit 0
   endef
 
   define Package/libatomic/install
        for file in $(call qstrip,$(CONFIG_LIBATOMIC_FILE_SPEC)); do \
-               dir=`dirname $$$$file` ; \
-               $(INSTALL_DIR) $(1)/$$$$dir ; \
-               $(CP) $(call qstrip,$(CONFIG_LIBATOMIC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+               $(INSTALL_DIR) $(1)/lib ; \
+               $(CP) $(call qstrip,$(CONFIG_LIBATOMIC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
        done ; \
        exit 0
   endef
        done ; \
        exit 0
   endef