1################################################################################
2#
3# coreutils
4#
5################################################################################
6
7COREUTILS_VERSION = 9.3
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_fstatat=yes \
26	ac_cv_func_getdelim=yes \
27	ac_cv_func_getgroups=yes \
28	ac_cv_func_getgroups_works=yes \
29	ac_cv_func_getloadavg=no \
30	ac_cv_func_strerror_r_char_p=no \
31	ac_cv_func_strnlen_working=yes \
32	ac_cv_have_decl_strerror_r=yes \
33	ac_cv_have_decl_strnlen=yes \
34	ac_cv_lib_getloadavg_getloadavg=no \
35	ac_cv_lib_util_getloadavg=no \
36	ac_fsusage_space=yes \
37	ac_use_included_regex=no \
38	am_cv_func_working_getline=yes \
39	fu_cv_sys_stat_statfs2_bsize=yes \
40	gl_cv_func_getcwd_null=yes \
41	gl_cv_func_getcwd_path_max=yes \
42	gl_cv_func_link_follows_symlink=no \
43	gl_cv_func_lstat_dereferences_slashed_symlink=yes \
44	gl_cv_func_re_compile_pattern_working=yes \
45	gl_cv_func_svid_putenv=yes \
46	gl_cv_func_working_mkstemp=yes \
47	gl_cv_func_working_utimes=yes \
48	gl_cv_macro_MB_CUR_MAX_good=yes \
49	gl_cv_have_proc_uptime=yes \
50	utils_cv_localtime_cache=no \
51	PERL=missing \
52	MAKEINFO=true \
53	INSTALL_PROGRAM=$(INSTALL)
54
55COREUTILS_BIN_PROGS = base64 cat chgrp chmod chown cp date dd df dir echo false \
56	kill link ln ls mkdir mknod mktemp mv nice printenv pwd rm rmdir \
57	vdir sleep stty sync touch true uname join
58
59ifeq ($(BR2_PACKAGE_ACL),y)
60COREUTILS_DEPENDENCIES += acl
61else
62COREUTILS_CONF_OPTS += --disable-acl
63endif
64
65ifeq ($(BR2_PACKAGE_ATTR),y)
66COREUTILS_DEPENDENCIES += attr
67else
68COREUTILS_CONF_OPTS += --disable-xattr
69endif
70
71COREUTILS_DEPENDENCIES += $(TARGET_NLS_DEPENDENCIES)
72
73# It otherwise fails to link properly, not mandatory though
74ifeq ($(BR2_PACKAGE_GETTEXT_PROVIDES_LIBINTL),y)
75COREUTILS_CONF_OPTS += --with-libintl-prefix=$(STAGING_DIR)/usr
76endif
77
78ifeq ($(BR2_PACKAGE_LIBCAP),y)
79COREUTILS_DEPENDENCIES += libcap
80else
81COREUTILS_CONF_OPTS += --disable-libcap
82endif
83
84ifeq ($(BR2_PACKAGE_LIBSELINUX),y)
85COREUTILS_DEPENDENCIES += libselinux
86COREUTILS_CONF_OPTS += --with-selinux
87else
88COREUTILS_CONF_OPTS += --without-selinux
89endif
90
91ifeq ($(BR2_PACKAGE_OPENSSL),y)
92COREUTILS_CONF_OPTS += --with-openssl=yes
93COREUTILS_DEPENDENCIES += openssl
94endif
95
96ifeq ($(BR2_ROOTFS_MERGED_USR),)
97# We want to move a few binaries from /usr/bin to /bin. In the case of
98# coreutils being built as multi-call binary, we do so by re-creating
99# the corresponding symlinks. If coreutils is built with individual
100# binaries, we actually move the binaries.
101ifeq ($(BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES),y)
102define COREUTILS_FIX_BIN_LOCATION
103	$(foreach f,$(COREUTILS_BIN_PROGS), \
104		mv $(TARGET_DIR)/usr/bin/$(f) $(TARGET_DIR)/bin
105	)
106endef
107else
108define COREUTILS_FIX_BIN_LOCATION
109	# some things go in /bin rather than /usr/bin
110	$(foreach f,$(COREUTILS_BIN_PROGS), \
111		rm -f $(TARGET_DIR)/usr/bin/$(f) && \
112		ln -sf ../usr/bin/coreutils $(TARGET_DIR)/bin/$(f)
113	)
114endef
115endif
116COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_FIX_BIN_LOCATION
117endif
118
119ifeq ($(BR2_STATIC_LIBS),y)
120COREUTILS_CONF_OPTS += --enable-no-install-program=stdbuf
121endif
122
123# link for archaic shells
124define COREUTILS_CREATE_TEST_SYMLINK
125	ln -fs test $(TARGET_DIR)/usr/bin/[
126endef
127COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_CREATE_TEST_SYMLINK
128
129# gnu thinks chroot is in bin, debian thinks it's in sbin
130ifeq ($(BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES),y)
131define COREUTILS_FIX_CHROOT_LOCATION
132	mv $(TARGET_DIR)/usr/bin/chroot $(TARGET_DIR)/usr/sbin
133endef
134else
135define COREUTILS_FIX_CHROOT_LOCATION
136	rm -f $(TARGET_DIR)/usr/bin/chroot
137	ln -sf ../bin/coreutils $(TARGET_DIR)/usr/sbin/chroot
138endef
139endif
140COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_FIX_CHROOT_LOCATION
141
142# Explicitly install ln and realpath, which we *are* insterested in.
143# A lot of other programs still get installed, however, but disabling
144# them does not gain much at build time, and is a loooong list that is
145# difficult to maintain... Just avoid overwriting fakedate when creating
146# a reproducible build
147HOST_COREUTILS_CONF_OPTS = \
148	--disable-acl \
149	--disable-libcap \
150	--disable-rpath \
151	--disable-single-binary \
152	--disable-xattr \
153	--without-gmp \
154	--enable-install-program=ln,realpath \
155	--enable-no-install-program=date
156
157$(eval $(autotools-package))
158$(eval $(host-autotools-package))
159