]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - Makefile
bcachefs-tools: Prettify make output
[bcachefs-tools-debian] / Makefile
index 01aa0b71b4cb478c42161db6aa941c19d63508d1..b0066666c8ea69dd45dddf51c75ae69511f3aebf 100644 (file)
--- 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