@@ -62,44 +62,31 @@ TOYBOX_ROOT := $(BASEDIR)/tmp
6262TOYBOX_VER := 0.8.12
6363TOYBOX_SRC := $(TOYBOX_ROOT ) /toybox-$(TOYBOX_VER )
6464
65- # ------------------------------------------------------------------------
66- # Detect the host system.
67- # On Windows uname -s might return MINGW_NT-* or CYGWIN_NT-*.
68- # Otherwise let it default to the kernel name returned by uname -s
69- # (Linux, Darwin, FreeBSD, …).
70- # ------------------------------------------------------------------------
71- OS ?= $(shell uname -s)
65+ # Detect the target system
66+ # See https://doc.rust-lang.org/beta/rustc/platform-support.html
67+ # todo: support building wasm
68+ OS := $(or $(CARGO_BUILD_TARGET ) ,$(shell rustc --print host-tuple) )
7269
7370# Windows does not allow symlink by default.
7471# Allow to override LN for AppArmor.
75- ifneq (,$(findstring _NT ,$(OS ) ) )
72+ ifneq (,$(findstring windows ,$(OS ) ) )
7673 LN ?= ln -f
7774endif
7875LN ?= ln -sf
7976
80- # Possible programs
81- PROGS := \
82- $(shell sed -n '/feat_Tier1 = \[/,/\]/p' Cargo.toml | sed '1d;2d' |tr -d '],"\n') \
83- $(shell sed -n '/feat_common_core = \[/,/\]/p' Cargo.toml | sed '1d' |tr -d '],"\n')
84-
85- UNIX_PROGS := \
86- $(shell sed -n '/feat_require_unix_core = \[/,/\]/p' Cargo.toml | sed '1d' |tr -d '],"\n') \
87- hostid \
88- pinky \
89- stdbuf \
90- uptime \
91- users \
92- who
93-
9477SELINUX_PROGS := \
9578 chcon \
9679 runcon
9780
9881$(info Detected OS = $(OS))
9982
100- ifeq (,$(findstring MINGW,$(OS ) ) )
101- PROGS += $(UNIX_PROGS)
83+ ifeq (,$(findstring windows,$(OS ) ) )
84+ FEATURE_EXTRACT_UTILS := feat_os_unix
85+ else
86+ FEATURE_EXTRACT_UTILS := feat_Tier1
10287endif
88+ PROGS := $(shell cargo tree --depth 1 --features $(FEATURE_EXTRACT_UTILS ) --format "{p}" --prefix none | sed -E -n 's/^uu_([^ ]+) .*/\1/p')
89+
10390ifeq ($(SELINUX_ENABLED ) ,1)
10491 PROGS += $(SELINUX_PROGS)
10592endif
@@ -114,7 +101,7 @@ endif
114101# Programs with usable tests
115102
116103TESTS := \
117- $(sort $(filter $(UTILS ) ,$(PROGS ) $(UNIX_PROGS ) $( SELINUX_PROGS ) ) )
104+ $(sort $(filter $(UTILS ) ,$(PROGS ) $(SELINUX_PROGS ) ) )
118105
119106TEST_NO_FAIL_FAST :=
120107TEST_SPEC_FEATURE :=
@@ -288,7 +275,7 @@ install: build install-manpages install-completions install-locales
288275 mkdir -p $(INSTALLDIR_BIN )
289276ifneq (,$(and $(findstring stdbuf,$(UTILS ) ) ,$(findstring feat_external_libstdbuf,$(CARGOFLAGS ) ) ) )
290277 mkdir -p $(DESTDIR)$(LIBSTDBUF_DIR)
291- ifneq (,$(findstring CYGWIN ,$(OS ) ) )
278+ ifneq (,$(findstring cygwin ,$(OS ) ) )
292279 $(INSTALL) -m 755 $(BUILDDIR)/deps/stdbuf.dll $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.dll
293280else
294281 $(INSTALL) -m 755 $(BUILDDIR)/deps/libstdbuf.* $(DESTDIR)$(LIBSTDBUF_DIR)/
308295endif
309296
310297uninstall :
311- ifeq (,$(findstring MINGW ,$(OS ) ) )
298+ ifeq (,$(findstring windows ,$(OS ) ) )
312299 rm -f $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.*
313300 -rm -d $(DESTDIR)$(LIBSTDBUF_DIR) 2>/dev/null || true
314301endif
0 commit comments