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 <ecordonnier@snap.com>
This commit is contained in:
Etienne Cordonnier 2025-06-21 23:46:58 +02:00
parent f825409392
commit e1441eff2c
2 changed files with 14 additions and 1 deletions

View file

@ -4,7 +4,7 @@ linker = "x86_64-unknown-redox-gcc"
[env] [env]
PROJECT_NAME_FOR_VERSION_STRING = "uutils coreutils" PROJECT_NAME_FOR_VERSION_STRING = "uutils coreutils"
# See feat_external_libstdbuf in src/uu/stdbuf/Cargo.toml # 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 # libstdbuf must be a shared library, so musl libc can't be linked statically
# https://github.com/rust-lang/rust/issues/82193 # https://github.com/rust-lang/rust/issues/82193

View file

@ -33,6 +33,9 @@ PREFIX ?= /usr/local
DESTDIR ?= DESTDIR ?=
BINDIR ?= $(PREFIX)/bin BINDIR ?= $(PREFIX)/bin
DATAROOTDIR ?= $(PREFIX)/share 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) INSTALLDIR_BIN=$(DESTDIR)$(BINDIR)
@ -199,6 +202,8 @@ ifneq ($(OS),Windows_NT)
PROGS := $(PROGS) $(UNIX_PROGS) PROGS := $(PROGS) $(UNIX_PROGS)
# Build the selinux command even if not on the system # Build the selinux command even if not on the system
PROGS := $(PROGS) $(SELINUX_PROGS) PROGS := $(PROGS) $(SELINUX_PROGS)
# Always use external libstdbuf when building with make (Unix only)
CARGOFLAGS += --features feat_external_libstdbuf
endif endif
UTILS ?= $(PROGS) UTILS ?= $(PROGS)
@ -438,6 +443,10 @@ endif
install: build install-manpages install-completions install-locales install: build install-manpages install-completions install-locales
mkdir -p $(INSTALLDIR_BIN) 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) ifeq (${MULTICALL}, y)
$(INSTALL) $(BUILDDIR)/coreutils $(INSTALLDIR_BIN)/$(PROG_PREFIX)coreutils $(INSTALL) $(BUILDDIR)/coreutils $(INSTALLDIR_BIN)/$(PROG_PREFIX)coreutils
$(foreach prog, $(filter-out coreutils, $(INSTALLEES)), \ $(foreach prog, $(filter-out coreutils, $(INSTALLEES)), \
@ -452,6 +461,10 @@ else
endif endif
uninstall: uninstall:
ifneq ($(OS),Windows_NT)
rm -f $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf*
-rmdir $(DESTDIR)$(LIBSTDBUF_DIR) 2>/dev/null || true
endif
ifeq (${MULTICALL}, y) ifeq (${MULTICALL}, y)
rm -f $(addprefix $(INSTALLDIR_BIN)/,$(PROG_PREFIX)coreutils) rm -f $(addprefix $(INSTALLDIR_BIN)/,$(PROG_PREFIX)coreutils)
endif endif