[Buildroot] [PATCH v5 1/9] toolchain/external: allow installing of libc utils

Alex Bennée alex.bennee at linaro.org
Thu Sep 11 21:27:41 UTC 2025


For buildroot's own tools we have BR2_PACKAGE_GLIBC_UTILS (and similar
for ulibc). As we need the tools for somethings we should also support
this for external toolchains.

Signed-off-by: Alex Bennée <alex.bennee at linaro.org>
---
 toolchain/toolchain-external/Config.in        |  7 ++++++
 .../pkg-toolchain-external.mk                 | 24 +++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/toolchain/toolchain-external/Config.in b/toolchain/toolchain-external/Config.in
index 831387bc4e..e79dafa365 100644
--- a/toolchain/toolchain-external/Config.in
+++ b/toolchain/toolchain-external/Config.in
@@ -125,4 +125,11 @@ config BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
 	  Copy the gdbserver provided by the external toolchain to the
 	  target.
 
+config BR2_TOOLCHAIN_EXTERNAL_LIBC_UTILS_COPY
+	bool "Install libc utilities"
+	depends on BR2_TOOLCHAIN_EXTERNAL
+	help
+	  Enabling this option will compile and install the getconf,
+	  ldd and locale gibc utilities for the target.
+
 endif # BR2_TOOLCHAIN_EXTERNAL
diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk
index 2c2afa76c0..4281c240af 100644
--- a/toolchain/toolchain-external/pkg-toolchain-external.mk
+++ b/toolchain/toolchain-external/pkg-toolchain-external.mk
@@ -450,6 +450,29 @@ define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_GDBSERVER
 endef
 endif
 
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LIBC_UTILS_COPY),y)
+define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBC_UTILS
+	$(Q)$(call MESSAGE,"Copying libc utils")
+	$(Q)ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
+	utils_found=0 ; \
+	for d in $${ARCH_SYSROOT_DIR} \
+	         $${ARCH_SYSROOT_DIR}/usr \
+		 $(TOOLCHAIN_EXTERNAL_INSTALL_DIR); do \
+		if test -f $${d}/bin/getconf ; then \
+			for f in getconf ldd locale; do \
+				install -m 0755 -D $${d}/bin/$${f} $(TARGET_DIR)/usr/bin ; \
+			done ; \
+			utils_found=1 ; \
+			break ; \
+		fi ; \
+	done ; \
+	if [ $${utils_found} -eq 0 ] ; then \
+		echo "Could not find libc utils in external toolchain" ; \
+		exit 1 ; \
+	fi
+endef
+endif
+
 define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS
 	$(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
 	ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
@@ -631,6 +654,7 @@ endef
 define $(2)_INSTALL_TARGET_CMDS
 	$$(TOOLCHAIN_EXTERNAL_CREATE_TARGET_LIB_SYMLINK)
 	$$(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS)
+	$$(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBC_UTILS)
 	$$(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_GDBSERVER)
 	$$(TOOLCHAIN_EXTERNAL_FIXUP_UCLIBCNG_LDSO)
 	$$(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LDD)
-- 
2.47.3



More information about the buildroot mailing list