bcachefs-tools: Prettify make output

Make the default "make" output look more like kbuild; this makes
errors and warnings much easier to spot. "Make V=1" will revert to
showing the full command lines.

This is done by redefining some implicit rules to add the echo and
the quiet variable.  These changes are similar to those in xfsprogs.
and btrfs-progs

This patch also silences things if pytest-3 is not found.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
This commit is contained in:
Eric Sandeen 2022-11-15 13:11:52 -06:00 committed by Kent Overstreet
parent e2442e57f2
commit cde2d0e2fc

View File

@ -2,6 +2,19 @@ PREFIX?=/usr/local
PKG_CONFIG?=pkg-config
INSTALL=install
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE = $(V)
endif
ifndef BUILD_VERBOSE
BUILD_VERBOSE = 0
endif
ifeq ($(BUILD_VERBOSE),1)
Q =
else
Q = @
endif
CFLAGS+=-std=gnu11 -O2 -g -MMD -Wall -fPIC \
-Wno-pointer-sign \
-fno-strict-aliasing \
@ -24,7 +37,7 @@ LDFLAGS+=$(CFLAGS) $(EXTRA_LDFLAGS)
PYTEST_ARGS?=
PYTEST_CMD?=$(shell \
command -v pytest-3 \
|| which pytest-3 \
|| which pytest-3 2>/dev/null \
)
PYTEST:=$(PYTEST_CMD) $(PYTEST_ARGS)
@ -104,7 +117,14 @@ DEPS=$(SRCS:.c=.d)
-include $(DEPS)
OBJS=$(SRCS:.c=.o)
%.o: %.c
@echo " [CC] $@"
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
bcachefs: $(filter-out ./tests/%.o, $(OBJS))
@echo " [LD] $@"
$(Q)$(CC) $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@
RUST_SRCS=$(shell find rust-src/ -type f -iname '*.rs')
MOUNT_SRCS=$(filter %mount, $(RUST_SRCS))
@ -115,7 +135,8 @@ debug: bcachefs
MOUNT_OBJ=$(filter-out ./bcachefs.o ./tests/%.o ./cmd_%.o , $(OBJS))
libbcachefs.so: LDFLAGS+=-shared
libbcachefs.so: $(MOUNT_OBJ)
$(CC) $(LDFLAGS) $+ -o $@ $(LDLIBS)
@echo " [CC] $@"
$(Q)$(CC) $(LDFLAGS) $+ -o $@ $(LDLIBS)
MOUNT_TOML=rust-src/mount/Cargo.toml
mount.bcachefs: lib $(MOUNT_SRCS)
@ -127,13 +148,16 @@ mount.bcachefs: lib $(MOUNT_SRCS)
tests/test_helper: $(filter ./tests/%.o, $(OBJS))
@echo " [LD] $@"
$(Q)$(CC) $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@
# If the version string differs from the last build, update the last version
ifneq ($(VERSION),$(shell cat .version 2>/dev/null))
.PHONY: .version
endif
.version:
echo '$(VERSION)' > $@
@echo " [VERS] $@"
$(Q)echo '$(VERSION)' > $@
# Rebuild the 'version' command any time the version string changes
cmd_version.o : .version
@ -156,8 +180,9 @@ install: bcachefs lib
.PHONY: clean
clean:
$(RM) bcachefs mount.bcachefs libbcachefs_mount.a tests/test_helper .version $(OBJS) $(DEPS) $(DOCGENERATED)
$(RM) -rf rust-src/*/target
@echo "Cleaning all"
$(Q)$(RM) bcachefs mount.bcachefs libbcachefs_mount.a tests/test_helper .version $(OBJS) $(DEPS) $(DOCGENERATED)
$(Q)$(RM) -rf rust-src/*/target
.PHONY: deb
deb: all