From cde2d0e2fcc5f2a2691975b6ec6b657cd8322c6a Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Tue, 15 Nov 2022 13:11:52 -0600 Subject: [PATCH] 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 --- Makefile | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 01aa0b7..b006666 100644 --- a/Makefile +++ b/Makefile @@ -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 -- 2.39.2