xref: /OK3568_Linux_fs/buildroot/toolchain/toolchain.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# toolchain-related customisation of the content of the target/ directory
4#
5################################################################################
6
7# Those customisations are added to the TARGET_FINALIZE_HOOKS, to be applied
8# just after all packages have been built.
9
10# Install the gconv modules
11ifeq ($(BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_COPY),y)
12TOOLCHAIN_GLIBC_GCONV_LIBS = $(call qstrip,$(BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_LIST))
13define TOOLCHAIN_GLIBC_COPY_GCONV_LIBS
14	$(Q)found_gconv=no; \
15	for d in $(TOOLCHAIN_EXTERNAL_PREFIX) ''; do \
16		[ -d "$(STAGING_DIR)/usr/lib/$${d}/gconv" ] || continue; \
17		found_gconv=yes; \
18		break; \
19	done; \
20	if [ "$${found_gconv}" = "no" ]; then \
21		printf "Unable to find gconv modules\n" >&2; \
22		exit 1; \
23	fi; \
24	if [ -z "$(TOOLCHAIN_GLIBC_GCONV_LIBS)" ]; then \
25		$(INSTALL) -m 0644 -D $(STAGING_DIR)/usr/lib/$${d}/gconv/gconv-modules \
26				      $(TARGET_DIR)/usr/lib/gconv/gconv-modules && \
27		$(INSTALL) -m 0644 $(STAGING_DIR)/usr/lib/$${d}/gconv/*.so \
28				   $(TARGET_DIR)/usr/lib/gconv \
29		|| exit 1; \
30	else \
31		for l in $(TOOLCHAIN_GLIBC_GCONV_LIBS); do \
32			$(INSTALL) -m 0644 -D $(STAGING_DIR)/usr/lib/$${d}/gconv/$${l}.so \
33					      $(TARGET_DIR)/usr/lib/gconv/$${l}.so \
34			|| exit 1; \
35			$(TARGET_READELF) -d $(STAGING_DIR)/usr/lib/$${d}/gconv/$${l}.so |\
36			sort -u |\
37			sed -e '/.*(NEEDED).*\[\(.*\.so\)\]$$/!d; s//\1/;' |\
38			while read lib; do \
39				 $(INSTALL) -m 0644 -D $(STAGING_DIR)/usr/lib/$${d}/gconv/$${lib} \
40						       $(TARGET_DIR)/usr/lib/gconv/$${lib} \
41				 || exit 1; \
42			done; \
43		done; \
44		./support/scripts/expunge-gconv-modules "$(TOOLCHAIN_GLIBC_GCONV_LIBS)" \
45			<$(STAGING_DIR)/usr/lib/$${d}/gconv/gconv-modules \
46			>$(TARGET_DIR)/usr/lib/gconv/gconv-modules; \
47	fi
48endef
49TOOLCHAIN_TARGET_FINALIZE_HOOKS += TOOLCHAIN_GLIBC_COPY_GCONV_LIBS
50endif
51