]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - Makefile
Disable pristine-tar option in gbp.conf, since there is no pristine-tar branch.
[bcachefs-tools-debian] / Makefile
index a7926f46dec03dedae85f20fc11bdbca32368188..6e5d0e56aa7fbc52bac355cfd794cbeba3741907 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,11 @@
-VERSION=1.3.3
+VERSION=1.6.3
 
 PREFIX?=/usr/local
+LIBEXECDIR?=$(PREFIX)/libexec
 PKG_CONFIG?=pkg-config
 INSTALL=install
 LN=ln
+.DEFAULT_GOAL=all
 
 ifeq ("$(origin V)", "command line")
   BUILD_VERBOSE = $(V)
@@ -14,16 +16,22 @@ 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                            \
        -fno-strict-aliasing                                    \
        -fno-delete-null-pointer-checks                         \
-       -I. -Iinclude -Iraid                                    \
+       -I. -Ic_src -Iinclude -Iraid                            \
        -D_FILE_OFFSET_BITS=64                                  \
        -D_GNU_SOURCE                                           \
        -D_LGPL_SOURCE                                          \
@@ -35,6 +43,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
@@ -49,6 +60,8 @@ CARGO_PROFILE=release
 CARGO_BUILD_ARGS=--$(CARGO_PROFILE)
 CARGO_BUILD=$(CARGO) build $(CARGO_BUILD_ARGS)
 
+CARGO_CLEAN=$(CARGO) clean $(CARGO_CLEAN_ARGS)
+
 include Makefile.compiler
 
 CFLAGS+=$(call cc-disable-warning, unused-but-set-variable)
@@ -58,11 +71,13 @@ CFLAGS+=$(call cc-disable-warning, missing-braces)
 CFLAGS+=$(call cc-disable-warning, zero-length-array)
 CFLAGS+=$(call cc-disable-warning, shift-overflow)
 CFLAGS+=$(call cc-disable-warning, enum-conversion)
+CFLAGS+=$(call cc-disable-warning, gnu-variable-sized-type-not-at-end)
 
 PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib liblz4 libzstd libudev libkeyutils udev"
 ifdef BCACHEFS_FUSE
        PKGCONFIG_LIBS+="fuse3 >= 3.7"
        CFLAGS+=-DBCACHEFS_FUSE
+       export RUSTFLAGS=--cfg fuse
 endif
 
 PKGCONFIG_CFLAGS:=$(shell $(PKG_CONFIG) --cflags $(PKGCONFIG_LIBS))
@@ -91,14 +106,13 @@ else
        ROOT_SBINDIR?=$(PREFIX)/sbin
        INITRAMFS_DIR=/etc/initramfs-tools
 endif
-LIBDIR=$(PREFIX)/lib
 
 PKGCONFIG_SERVICEDIR:=$(shell $(PKG_CONFIG) --variable=systemdsystemunitdir systemd)
 ifeq (,$(PKGCONFIG_SERVICEDIR))
-       $(warning skipping systemd integration)
+  $(warning skipping systemd integration)
 else
 BCACHEFSCK_ARGS=-f -n
-systemd_libfiles=\
+systemd_libexecfiles=\
        fsck/bcachefsck_fail \
        fsck/bcachefsck_all
 
@@ -119,14 +133,14 @@ built_scripts+=\
 
 %.service: %.service.in
        @echo "    [SED]    $@"
-       $(Q)sed -e "s|@libdir@|$(LIBDIR)|g" \
+       $(Q)sed -e "s|@libexecdir@|$(LIBEXECDIR)|g" \
                -e "s|@bcachefsck_args@|$(BCACHEFSCK_ARGS)|g" < $< > $@
 
 fsck/bcachefsck_all: fsck/bcachefsck_all.in
        @echo "    [SED]    $@"
        $(Q)sed -e "s|@bcachefsck_args@|$(BCACHEFSCK_ARGS)|g" < $< > $@
 
-optional_build+=$(systemd_libfiles) $(systemd_services)
+optional_build+=$(systemd_libexecfiles) $(systemd_services)
 optional_install+=install_systemd
 endif  # PKGCONFIG_SERVICEDIR
 
@@ -147,36 +161,26 @@ 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]     $@"
        $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
 
 BCACHEFS_DEPS=libbcachefs.a
+RUST_SRCS:=$(shell find src bch_bindgen/src -type f -iname '*.rs')
 
-ifndef NO_RUST
-       BCACHEFS_DEPS+=rust-src/target/release/libbcachefs_rust.a
-else
-       CFLAGS+=-DBCACHEFS_NO_RUST
-endif
-
-bcachefs: $(BCACHEFS_DEPS)
-       @echo "    [LD]     $@"
-       $(Q)$(CC) $(LDFLAGS) -Wl,--whole-archive $+ $(LOADLIBES) -Wl,--no-whole-archive $(LDLIBS) -o $@
+bcachefs: $(BCACHEFS_DEPS) $(RUST_SRCS)
+       $(Q)$(CARGO_BUILD)
 
 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-src/target/release/libbcachefs_rust.a: $(RUST_SRCS)
-       $(CARGO_BUILD) --manifest-path rust-src/Cargo.toml
-
 tests/test_helper: $(filter ./tests/%.o, $(OBJS))
        @echo "    [LD]     $@"
        $(Q)$(CC) $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@
@@ -196,7 +200,7 @@ cmd_version.o : .version
 install: INITRAMFS_HOOK=$(INITRAMFS_DIR)/hooks/bcachefs
 install: INITRAMFS_SCRIPT=$(INITRAMFS_DIR)/scripts/local-premount/bcachefs
 install: bcachefs $(optional_install)
-       $(INSTALL) -m0755 -D bcachefs      -t $(DESTDIR)$(ROOT_SBINDIR)
+       $(INSTALL) -m0755 -D target/release/bcachefs -t $(DESTDIR)$(ROOT_SBINDIR)
        $(INSTALL) -m0644 -D bcachefs.8    -t $(DESTDIR)$(PREFIX)/share/man/man8/
        $(INSTALL) -m0755 -D initramfs/script $(DESTDIR)$(INITRAMFS_SCRIPT)
        $(INSTALL) -m0755 -D initramfs/hook   $(DESTDIR)$(INITRAMFS_HOOK)
@@ -210,17 +214,18 @@ install: bcachefs $(optional_install)
 
        sed -i '/^# Note: make install replaces/,$$d' $(DESTDIR)$(INITRAMFS_HOOK)
        echo "copy_exec $(ROOT_SBINDIR)/bcachefs /sbin/bcachefs" >> $(DESTDIR)$(INITRAMFS_HOOK)
+       echo "copy_exec $(ROOT_SBINDIR)/mount.bcachefs /sbin/mount.bcachefs" >> $(DESTDIR)$(INITRAMFS_HOOK)
 
 .PHONY: install_systemd
-install_systemd: $(systemd_services) $(systemd_libfiles)
-       $(INSTALL) -m0755 -D $(systemd_libfiles) -t $(DESTDIR)$(LIBDIR)
+install_systemd: $(systemd_services) $(systemd_libexecfiles)
+       $(INSTALL) -m0755 -D $(systemd_libexecfiles) -t $(DESTDIR)$(LIBEXECDIR)
        $(INSTALL) -m0644 -D $(systemd_services) -t $(DESTDIR)$(PKGCONFIG_SERVICEDIR)
 
 .PHONY: clean
 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)$(RM) libbcachefs.a c_src/libbcachefs.a tests/test_helper .version *.tar.xz $(OBJS) $(DEPS) $(DOCGENERATED)
+       $(Q)$(CARGO_CLEAN)
        $(Q)$(RM) -f $(built_scripts)
 
 .PHONY: deb
@@ -239,8 +244,8 @@ doc: bcachefs-principles-of-operation.pdf
 
 .PHONY: cargo-update-msrv
 cargo-update-msrv:
-       cargo +nightly generate-lockfile --manifest-path rust-src/Cargo.toml -Zmsrv-policy
-       cargo +nightly generate-lockfile --manifest-path rust-src/bch_bindgen/Cargo.toml -Zmsrv-policy
+       cargo +nightly generate-lockfile -Zmsrv-policy
+       cargo +nightly generate-lockfile --manifest-path bch_bindgen/Cargo.toml -Zmsrv-policy
 
 .PHONY: update-bcachefs-sources
 update-bcachefs-sources:
@@ -268,11 +273,20 @@ update-bcachefs-sources:
        git add include/linux/kmemleak.h
        cp $(LINUX_DIR)/lib/math/int_sqrt.c linux/
        git add linux/int_sqrt.c
-       git rm libbcachefs/mean_and_variance_test.c
-#      cp $(LINUX_DIR)/lib/math/mean_and_variance.c linux/
-#      git add linux/mean_and_variance.c
-#      cp $(LINUX_DIR)/include/linux/mean_and_variance.h include/linux/
-#      git add include/linux/mean_and_variance.h
+       cp $(LINUX_DIR)/lib/math/mean_and_variance.c linux/
+       git add linux/mean_and_variance.c
+       cp $(LINUX_DIR)/include/linux/mean_and_variance.h include/linux/
+       git add include/linux/mean_and_variance.h
+       cp $(LINUX_DIR)/lib/time_stats.c linux/
+       git add linux/time_stats.c
+       cp $(LINUX_DIR)/include/linux/time_stats.h include/linux/
+       git add include/linux/time_stats.h
+       cp $(LINUX_DIR)/include/linux/darray.h include/linux/
+       git add include/linux/darray.h
+       cp $(LINUX_DIR)/include/linux/darray_types.h include/linux/
+       git add include/linux/darray_types.h
+       cp $(LINUX_DIR)/include/linux/eytzinger.h include/linux/
+       git add include/linux/eytzinger.h
        cp $(LINUX_DIR)/scripts/Makefile.compiler ./
        git add Makefile.compiler
        $(RM) libbcachefs/*.mod.c