Skip to content

Commit 42339fe

Browse files
authored
GNUMakefile: install libstdbuf (#8238)
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>
2 parents 56ce0e2 + e1441ef commit 42339fe

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ linker = "x86_64-unknown-redox-gcc"
44
[env]
55
PROJECT_NAME_FOR_VERSION_STRING = "uutils coreutils"
66
# See feat_external_libstdbuf in src/uu/stdbuf/Cargo.toml
7-
LIBSTDBUF_DIR = "/usr/lib"
7+
LIBSTDBUF_DIR = "/usr/local/libexec/coreutils"
88

99
# libstdbuf must be a shared library, so musl libc can't be linked statically
1010
# https://github.com/rust-lang/rust/issues/82193

GNUmakefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ PREFIX ?= /usr/local
3333
DESTDIR ?=
3434
BINDIR ?= $(PREFIX)/bin
3535
DATAROOTDIR ?= $(PREFIX)/share
36+
LIBSTDBUF_DIR ?= $(PREFIX)/libexec/coreutils
37+
# Export variable so that it is used during the build
38+
export LIBSTDBUF_DIR
3639

3740
INSTALLDIR_BIN=$(DESTDIR)$(BINDIR)
3841

@@ -199,6 +202,8 @@ ifneq ($(OS),Windows_NT)
199202
PROGS := $(PROGS) $(UNIX_PROGS)
200203
# Build the selinux command even if not on the system
201204
PROGS := $(PROGS) $(SELINUX_PROGS)
205+
# Always use external libstdbuf when building with make (Unix only)
206+
CARGOFLAGS += --features feat_external_libstdbuf
202207
endif
203208

204209
UTILS ?= $(PROGS)
@@ -438,6 +443,10 @@ endif
438443

439444
install: build install-manpages install-completions install-locales
440445
mkdir -p $(INSTALLDIR_BIN)
446+
ifneq ($(OS),Windows_NT)
447+
mkdir -p $(DESTDIR)$(LIBSTDBUF_DIR)
448+
$(INSTALL) -m 755 $(BUILDDIR)/deps/libstdbuf* $(DESTDIR)$(LIBSTDBUF_DIR)/
449+
endif
441450
ifeq (${MULTICALL}, y)
442451
$(INSTALL) $(BUILDDIR)/coreutils $(INSTALLDIR_BIN)/$(PROG_PREFIX)coreutils
443452
$(foreach prog, $(filter-out coreutils, $(INSTALLEES)), \
@@ -452,6 +461,10 @@ else
452461
endif
453462

454463
uninstall:
464+
ifneq ($(OS),Windows_NT)
465+
rm -f $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf*
466+
-rmdir $(DESTDIR)$(LIBSTDBUF_DIR) 2>/dev/null || true
467+
endif
455468
ifeq (${MULTICALL}, y)
456469
rm -f $(addprefix $(INSTALLDIR_BIN)/,$(PROG_PREFIX)coreutils)
457470
endif

0 commit comments

Comments
 (0)