]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - Makefile
cmd_fsck: -k, run fsck in kernel
[bcachefs-tools-debian] / Makefile
index 8b9bcdeeac4ad83049ec79bc3d0d45f2de37a8eb..581e8b41d1c75e7c2840c15b52ae8b43a98ea680 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,10 +15,16 @@ endif
 
 ifeq ($(BUILD_VERBOSE),1)
   Q =
+  CARGO_CLEAN_ARGS = --verbose
 else
   Q = @
+  CARGO_CLEAN_ARGS = --quiet
 endif
 
+# Prevent recursive expansions of $(CFLAGS) to avoid repeatedly performing
+# compile tests
+CFLAGS:=$(CFLAGS)
+
 CFLAGS+=-std=gnu11 -O2 -g -MMD -Wall -fPIC                     \
        -Wno-pointer-sign                                       \
        -Wno-deprecated-declarations                            \
@@ -36,6 +42,9 @@ CFLAGS+=-std=gnu11 -O2 -g -MMD -Wall -fPIC                    \
        -DNO_BCACHEFS_SYSFS                                     \
        -DVERSION_STRING='"$(VERSION)"'                         \
        $(EXTRA_CFLAGS)
+
+# Intenionally not doing the above to $(LDFLAGS) because we rely on
+# recursive expansion here (CFLAGS is not yet completely built by this line)
 LDFLAGS+=$(CFLAGS) $(EXTRA_LDFLAGS)
 
 ifdef CARGO_TOOLCHAIN_VERSION
@@ -46,9 +55,12 @@ CARGO_ARGS=${CARGO_TOOLCHAIN}
 CARGO=cargo $(CARGO_ARGS)
 CARGO_PROFILE=release
 # CARGO_PROFILE=debug
+CARGO_MANIFEST=--manifest-path rust-src/Cargo.toml
 
 CARGO_BUILD_ARGS=--$(CARGO_PROFILE)
-CARGO_BUILD=$(CARGO) build $(CARGO_BUILD_ARGS)
+CARGO_BUILD=$(CARGO) build $(CARGO_BUILD_ARGS) $(CARGO_MANIFEST)
+
+CARGO_CLEAN=$(CARGO) clean $(CARGO_CLEAN_ARGS) $(CARGO_MANIFEST)
 
 include Makefile.compiler
 
@@ -149,11 +161,11 @@ TAGS:
 tags:
        ctags -R .
 
-SRCS=$(sort $(shell find . -type f ! -path '*/.*/*' -iname '*.c'))
-DEPS=$(SRCS:.c=.d)
+SRCS:=$(sort $(shell find . -type f ! -path '*/.*/*' -iname '*.c'))
+DEPS:=$(SRCS:.c=.d)
 -include $(DEPS)
 
-OBJS=$(SRCS:.c=.o)
+OBJS:=$(SRCS:.c=.o)
 
 %.o: %.c
        @echo "    [CC]     $@"
@@ -175,9 +187,9 @@ libbcachefs.a: $(filter-out ./tests/%.o, $(OBJS))
        @echo "    [AR]     $@"
        $(Q)ar -rc $@ $+
 
-RUST_SRCS=$(shell find rust-src/src rust-src/bch_bindgen/src -type f -iname '*.rs')
+RUST_SRCS:=$(shell find rust-src/src rust-src/bch_bindgen/src -type f -iname '*.rs')
 rust-src/target/release/libbcachefs_rust.a: $(RUST_SRCS)
-       $(CARGO_BUILD) --manifest-path rust-src/Cargo.toml
+       $(CARGO_BUILD)
 
 tests/test_helper: $(filter ./tests/%.o, $(OBJS))
        @echo "    [LD]     $@"
@@ -222,7 +234,7 @@ install_systemd: $(systemd_services) $(systemd_libfiles)
 clean:
        @echo "Cleaning all"
        $(Q)$(RM) bcachefs libbcachefs.a tests/test_helper .version *.tar.xz $(OBJS) $(DEPS) $(DOCGENERATED)
-       $(Q)$(RM) -rf rust-src/*/target
+       $(Q)$(CARGO_CLEAN)
        $(Q)$(RM) -f $(built_scripts)
 
 .PHONY: deb