xref: /OK3568_Linux_fs/buildroot/package/coreutils/coreutils.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# coreutils
4#
5################################################################################
6
7COREUTILS_VERSION = 9.0
8COREUTILS_SITE = $(BR2_GNU_MIRROR)/coreutils
9COREUTILS_SOURCE = coreutils-$(COREUTILS_VERSION).tar.xz
10COREUTILS_LICENSE = GPL-3.0+
11COREUTILS_LICENSE_FILES = COPYING
12COREUTILS_CPE_ID_VENDOR = gnu
13
14COREUTILS_CONF_OPTS = --disable-rpath \
15	$(if $(BR2_TOOLCHAIN_USES_MUSL),--with-included-regex)
16
17ifeq ($(BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES),y)
18COREUTILS_CONF_OPTS += --disable-single-binary
19else
20COREUTILS_CONF_OPTS += --enable-single-binary=symlinks
21endif
22
23COREUTILS_CONF_ENV = ac_cv_c_restrict=no \
24	ac_cv_func_chown_works=yes \
25	ac_cv_func_euidaccess=no \
26	ac_cv_func_fstatat=yes \
27	ac_cv_func_getdelim=yes \
28	ac_cv_func_getgroups=yes \
29	ac_cv_func_getgroups_works=yes \
30	ac_cv_func_getloadavg=no \
31	ac_cv_func_lstat_dereferences_slashed_symlink=yes \
32	ac_cv_func_lstat_empty_string_bug=no \
33	ac_cv_func_strerror_r_char_p=no \
34	ac_cv_func_strnlen_working=yes \
35	ac_cv_func_strtod=yes \
36	ac_cv_func_working_mktime=yes \
37	ac_cv_have_decl_strerror_r=yes \
38	ac_cv_have_decl_strnlen=yes \
39	ac_cv_lib_getloadavg_getloadavg=no \
40	ac_cv_lib_util_getloadavg=no \
41	ac_fsusage_space=yes \
42	ac_use_included_regex=no \
43	am_cv_func_working_getline=yes \
44	fu_cv_sys_stat_statfs2_bsize=yes \
45	gl_cv_func_getcwd_null=yes \
46	gl_cv_func_getcwd_path_max=yes \
47	gl_cv_func_gettimeofday_clobber=no \
48	gl_cv_func_fstatat_zero_flag=no \
49	gl_cv_func_link_follows_symlink=no \
50	gl_cv_func_re_compile_pattern_working=yes \
51	gl_cv_func_svid_putenv=yes \
52	gl_cv_func_tzset_clobber=no \
53	gl_cv_func_working_mkstemp=yes \
54	gl_cv_func_working_utimes=yes \
55	gl_getline_needs_run_time_check=no \
56	gl_cv_have_proc_uptime=yes \
57	utils_cv_localtime_cache=no \
58	PERL=missing \
59	MAKEINFO=true \
60	INSTALL_PROGRAM=$(INSTALL)
61
62COREUTILS_BIN_PROGS = base64 cat chgrp chmod chown cp date dd df dir echo false \
63	kill link ln ls mkdir mknod mktemp mv nice printenv pwd rm rmdir \
64	vdir sleep stty sync touch true uname join
65
66ifeq ($(BR2_PACKAGE_ACL),y)
67COREUTILS_DEPENDENCIES += acl
68else
69COREUTILS_CONF_OPTS += --disable-acl
70endif
71
72ifeq ($(BR2_PACKAGE_ATTR),y)
73COREUTILS_DEPENDENCIES += attr
74else
75COREUTILS_CONF_OPTS += --disable-xattr
76endif
77
78COREUTILS_DEPENDENCIES += $(TARGET_NLS_DEPENDENCIES)
79
80# It otherwise fails to link properly, not mandatory though
81ifeq ($(BR2_PACKAGE_GETTEXT_PROVIDES_LIBINTL),y)
82COREUTILS_CONF_OPTS += --with-libintl-prefix=$(STAGING_DIR)/usr
83endif
84
85ifeq ($(BR2_PACKAGE_GMP),y)
86COREUTILS_DEPENDENCIES += gmp
87else
88COREUTILS_CONF_OPTS += --without-gmp
89endif
90
91ifeq ($(BR2_PACKAGE_LIBCAP),y)
92COREUTILS_DEPENDENCIES += libcap
93else
94COREUTILS_CONF_OPTS += --disable-libcap
95endif
96
97ifeq ($(BR2_PACKAGE_OPENSSL),y)
98COREUTILS_CONF_OPTS += --with-openssl=yes
99COREUTILS_DEPENDENCIES += openssl
100endif
101
102ifeq ($(BR2_PACKAGE_COREUTILS_UNICODE_BYPASS),y)
103define COREUTILS_UNICODE_BYPASS
104	$(SED) "s%\(printable =\) \(isprint\)%\1 c >= ' '; // \2%" \
105		$(@D)/lib/quotearg.c || true
106endef
107COREUTILS_PRE_BUILD_HOOKS += COREUTILS_UNICODE_BYPASS
108endif
109
110ifeq ($(BR2_ROOTFS_MERGED_USR),)
111# We want to move a few binaries from /usr/bin to /bin. In the case of
112# coreutils being built as multi-call binary, we do so by re-creating
113# the corresponding symlinks. If coreutils is built with individual
114# binaries, we actually move the binaries.
115ifeq ($(BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES),y)
116define COREUTILS_FIX_BIN_LOCATION
117	$(foreach f,$(COREUTILS_BIN_PROGS), \
118		mv $(TARGET_DIR)/usr/bin/$(f) $(TARGET_DIR)/bin
119	)
120endef
121else
122define COREUTILS_FIX_BIN_LOCATION
123	# some things go in /bin rather than /usr/bin
124	$(foreach f,$(COREUTILS_BIN_PROGS), \
125		rm -f $(TARGET_DIR)/usr/bin/$(f) && \
126		ln -sf ../usr/bin/coreutils $(TARGET_DIR)/bin/$(f)
127	)
128endef
129endif
130COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_FIX_BIN_LOCATION
131endif
132
133ifeq ($(BR2_STATIC_LIBS),y)
134COREUTILS_CONF_OPTS += --enable-no-install-program=stdbuf
135endif
136
137# link for archaic shells
138define COREUTILS_CREATE_TEST_SYMLINK
139	ln -fs test $(TARGET_DIR)/usr/bin/[
140endef
141COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_CREATE_TEST_SYMLINK
142
143# gnu thinks chroot is in bin, debian thinks it's in sbin
144ifeq ($(BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES),y)
145define COREUTILS_FIX_CHROOT_LOCATION
146	mv $(TARGET_DIR)/usr/bin/chroot $(TARGET_DIR)/usr/sbin
147endef
148else
149define COREUTILS_FIX_CHROOT_LOCATION
150	rm -f $(TARGET_DIR)/usr/bin/chroot
151	ln -sf ../bin/coreutils $(TARGET_DIR)/usr/sbin/chroot
152endef
153endif
154COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_FIX_CHROOT_LOCATION
155
156# Explicitly install ln and realpath, which we *are* insterested in.
157# A lot of other programs still get installed, however, but disabling
158# them does not gain much at build time, and is a loooong list that is
159# difficult to maintain... Just avoid overwriting fakedate when creating
160# a reproducible build
161HOST_COREUTILS_CONF_OPTS = \
162	--disable-acl \
163	--disable-libcap \
164	--disable-rpath \
165	--disable-single-binary \
166	--disable-xattr \
167	--without-gmp \
168	--enable-install-program=ln,realpath \
169	--enable-no-install-program=date
170
171$(eval $(autotools-package))
172$(eval $(host-autotools-package))
173