Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ jobs:
fi
# Check that we don't cross-build uudoc
# also do not try to generate manpages for part of hashsum
make install-manpages PREFIX=/tmp/usr UTILS=true RUSTC_ARCH="--target aarch64-unknown-linux-gnu"
env CARGO_BUILD_TARGET=aarch64-unknown-linux-gnu make install-manpages PREFIX=/tmp/usr UTILS=true
# build (host)
make build
echo "Check that target directory will be ignored by backup tools"
Expand Down
28 changes: 14 additions & 14 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ endif
# Binaries
CARGO ?= cargo
CARGOFLAGS ?=
RUSTC_ARCH ?= # should be empty except for cross-build, not --target $(shell rustc --print host-tuple)

#prefix prepended to all binaries and library dir
PROG_PREFIX ?=
Expand All @@ -43,11 +42,12 @@ INSTALLDIR_BIN=$(DESTDIR)$(BINDIR)

# This won't support any directory with spaces in its name, but you can just
# make a symlink without spaces that points to the directory.
# CARGO_BUILD_TARGET should be undefined for native (non-cross) build.
BASEDIR ?= $(shell pwd)
ifdef CARGO_TARGET_DIR
BUILDDIR := $(CARGO_TARGET_DIR)/${PROFILE}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should define BUILDDIR_UUDOC at lines 49 and 51 and take CARGO_TARGET_DIR into account. The problem with current state of the PR is that:

  1. "$(BASEDIR)/target/$(PROFILE)/uudoc" is duplicated 4 times
  2. it doesn't work with CARGO_TARGET_DIR:
env CARGO_TARGET_DIR=foobar CARGO_BUILD_TARGET=aarch64-unknown-linux-gnu make install-manpages PREFIX=/tmp/usr UTILS=true
mkdir -p /tmp/usr/share/man/man1
/home/asteba/dev/coreutils/target/debug/uudoc manpage true > /tmp/usr/share/man/man1/true.1 
/bin/sh: 1: /home/asteba/dev/coreutils/target/debug/uudoc: not found
make: *** [GNUmakefile:389: install-manpages] Error 127
...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ifdef CARGO_TARGET_DIR
BUILDDIR := $(CARGO_TARGET_DIR)/${PROFILE}
BUILDDIR_UUDOC := $(CARGO_TARGET_DIR)/${PROFILE}
else
BUILDDIR := $(BASEDIR)/target/$(CARGO_BUILD_TARGET)/${PROFILE}
BUILDDIR_UUDOC := $(BASEDIR)/target/${PROFILE}
endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have @unset CARGO_BUILD_TARGET && ${CARGO} build ${CARGOFLAGS} --bin uudoc .... Not enough?
I add BUILDDIR_UUDOC in any case.

Copy link
Collaborator

@Ecordonnier Ecordonnier Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not enough, setting @unset CARGO_BUILD_TARGET does not have an impact on CARGO_TARGET_DIR. The issue is that the build directory is not under BASEDIR when setting CARGO_TARGET_DIR to another directory.

else
BUILDDIR := $(BASEDIR)/target/${PROFILE}
BUILDDIR := $(BASEDIR)/target/$(CARGO_BUILD_TARGET)/${PROFILE}
endif
PKG_BUILDDIR := $(BUILDDIR)/deps
DOCSDIR := $(BASEDIR)/docs
Expand Down Expand Up @@ -316,14 +316,14 @@ all: build
build-pkgs:
ifneq (${MULTICALL}, y)
ifdef BUILD_SPEC_FEATURE
${CARGO} build ${CARGOFLAGS} --features "$(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH)
${CARGO} build ${CARGOFLAGS} --features "$(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg))
else
${CARGO} build ${CARGOFLAGS} ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH)
${CARGO} build ${CARGOFLAGS} ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg))
endif
endif

build-coreutils:
${CARGO} build ${CARGOFLAGS} --features "${EXES} $(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} --no-default-features $(RUSTC_ARCH)
${CARGO} build ${CARGOFLAGS} --features "${EXES} $(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} --no-default-features

build: build-coreutils build-pkgs locales

Expand Down Expand Up @@ -373,21 +373,21 @@ busytest: $(BUILDDIR)/busybox $(addprefix test_busybox_,$(filter-out $(SKIP_UTIL
endif

clean:
cargo clean $(RUSTC_ARCH)
cd $(DOCSDIR) && $(MAKE) clean $(RUSTC_ARCH)
cargo clean
cd $(DOCSDIR) && $(MAKE) clean

distclean: clean
$(CARGO) clean $(CARGOFLAGS) $(RUSTC_ARCH) && $(CARGO) update $(CARGOFLAGS) $(RUSTC_ARCH)
$(CARGO) clean $(CARGOFLAGS) && $(CARGO) update $(CARGOFLAGS)

ifeq ($(MANPAGES),y)
# Do not cross-build uudoc
build-uudoc:
# Use same PROFILE with coreutils to share crates (if not cross-build)
${CARGO} build ${CARGOFLAGS} --bin uudoc --features "uudoc ${EXES}" ${PROFILE_CMD} --no-default-features
@unset CARGO_BUILD_TARGET && ${CARGO} build ${CARGOFLAGS} --bin uudoc --features "uudoc ${EXES}" ${PROFILE_CMD} --no-default-features

install-manpages: build-uudoc
mkdir -p $(DESTDIR)$(DATAROOTDIR)/man/man1
$(foreach prog, $(INSTALLEES) $(HASHSUM_PROGS), \
$(BUILDDIR)/uudoc manpage $(prog) > $(DESTDIR)$(DATAROOTDIR)/man/man1/$(PROG_PREFIX)$(prog).1 $(newline) \
$(BASEDIR)/target/$(PROFILE)/uudoc manpage $(prog) > $(DESTDIR)$(DATAROOTDIR)/man/man1/$(PROG_PREFIX)$(prog).1 $(newline) \
)
else
install-manpages:
Expand All @@ -400,9 +400,9 @@ install-completions: build-uudoc
mkdir -p $(DESTDIR)$(DATAROOTDIR)/bash-completion/completions
mkdir -p $(DESTDIR)$(DATAROOTDIR)/fish/vendor_completions.d
$(foreach prog, $(INSTALLEES) $(HASHSUM_PROGS) , \
$(BUILDDIR)/uudoc completion $(prog) zsh > $(DESTDIR)$(DATAROOTDIR)/zsh/site-functions/_$(PROG_PREFIX)$(prog) $(newline) \
$(BUILDDIR)/uudoc completion $(prog) bash > $(DESTDIR)$(DATAROOTDIR)/bash-completion/completions/$(PROG_PREFIX)$(prog).bash $(newline) \
$(BUILDDIR)/uudoc completion $(prog) fish > $(DESTDIR)$(DATAROOTDIR)/fish/vendor_completions.d/$(PROG_PREFIX)$(prog).fish $(newline) \
$(BASEDIR)/target/$(PROFILE)/uudoc completion $(prog) zsh > $(DESTDIR)$(DATAROOTDIR)/zsh/site-functions/_$(PROG_PREFIX)$(prog) $(newline) \
$(BASEDIR)/target/$(PROFILE)/uudoc completion $(prog) bash > $(DESTDIR)$(DATAROOTDIR)/bash-completion/completions/$(PROG_PREFIX)$(prog).bash $(newline) \
$(BASEDIR)/target/$(PROFILE)/uudoc completion $(prog) fish > $(DESTDIR)$(DATAROOTDIR)/fish/vendor_completions.d/$(PROG_PREFIX)$(prog).fish $(newline) \
)
else
install-completions:
Expand Down
Loading