-VERSION=1.3.3
+VERSION=1.4.0
PREFIX?=/usr/local
PKG_CONFIG?=pkg-config
INSTALL=install
LN=ln
+.DEFAULT_GOAL=all
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE = $(V)
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 \
-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
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
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
ROOT_SBINDIR?=$(PREFIX)/sbin
INITRAMFS_DIR=/etc/initramfs-tools
endif
-LIBDIR=$(PREFIX)/lib
+LIBEXECDIR=$(PREFIX)/libexec
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
%.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
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] $@"
@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] $@"
echo "copy_exec $(ROOT_SBINDIR)/bcachefs /sbin/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)$(CARGO_CLEAN)
$(Q)$(RM) -f $(built_scripts)
.PHONY: deb
git add include/linux/kmemleak.h
cp $(LINUX_DIR)/lib/math/int_sqrt.c linux/
git add linux/int_sqrt.c
- rm libbcachefs/mean_and_variance_test.c
+ git rm -f 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/