From e1441eff2c72b33d7cf486267f8b6aeceedfea47 Mon Sep 17 00:00:00 2001 From: Etienne Cordonnier Date: Sat, 21 Jun 2025 23:46:58 +0200 Subject: [PATCH] GNUMakefile: install libstdbuf Use external libstdbuf.so when building with make, as embedding the library is only needed to work around "cargo install" limitations with shared libraries. Also change default installation directory to /usr/local/libexec/coreutils/ for consistency with GNU coreutils Signed-off-by: Etienne Cordonnier --- .cargo/config.toml | 2 +- GNUmakefile | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index c97dc5701..3ac918295 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,7 +4,7 @@ linker = "x86_64-unknown-redox-gcc" [env] PROJECT_NAME_FOR_VERSION_STRING = "uutils coreutils" # See feat_external_libstdbuf in src/uu/stdbuf/Cargo.toml -LIBSTDBUF_DIR = "/usr/lib" +LIBSTDBUF_DIR = "/usr/local/libexec/coreutils" # libstdbuf must be a shared library, so musl libc can't be linked statically # https://github.com/rust-lang/rust/issues/82193 diff --git a/GNUmakefile b/GNUmakefile index 9cfae72f9..9cc210004 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -33,6 +33,9 @@ PREFIX ?= /usr/local DESTDIR ?= BINDIR ?= $(PREFIX)/bin DATAROOTDIR ?= $(PREFIX)/share +LIBSTDBUF_DIR ?= $(PREFIX)/libexec/coreutils +# Export variable so that it is used during the build +export LIBSTDBUF_DIR INSTALLDIR_BIN=$(DESTDIR)$(BINDIR) @@ -199,6 +202,8 @@ ifneq ($(OS),Windows_NT) PROGS := $(PROGS) $(UNIX_PROGS) # Build the selinux command even if not on the system PROGS := $(PROGS) $(SELINUX_PROGS) +# Always use external libstdbuf when building with make (Unix only) + CARGOFLAGS += --features feat_external_libstdbuf endif UTILS ?= $(PROGS) @@ -438,6 +443,10 @@ endif install: build install-manpages install-completions install-locales mkdir -p $(INSTALLDIR_BIN) +ifneq ($(OS),Windows_NT) + mkdir -p $(DESTDIR)$(LIBSTDBUF_DIR) + $(INSTALL) -m 755 $(BUILDDIR)/deps/libstdbuf* $(DESTDIR)$(LIBSTDBUF_DIR)/ +endif ifeq (${MULTICALL}, y) $(INSTALL) $(BUILDDIR)/coreutils $(INSTALLDIR_BIN)/$(PROG_PREFIX)coreutils $(foreach prog, $(filter-out coreutils, $(INSTALLEES)), \ @@ -452,6 +461,10 @@ else endif uninstall: +ifneq ($(OS),Windows_NT) + rm -f $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf* + -rmdir $(DESTDIR)$(LIBSTDBUF_DIR) 2>/dev/null || true +endif ifeq (${MULTICALL}, y) rm -f $(addprefix $(INSTALLDIR_BIN)/,$(PROG_PREFIX)coreutils) endif