2019-02-24 12:50:20 +03:00
|
|
|
PREFIX?=/usr/local
|
2019-02-24 12:47:35 +03:00
|
|
|
PKG_CONFIG?=pkg-config
|
2013-10-07 01:13:05 +04:00
|
|
|
INSTALL=install
|
2019-11-03 10:35:03 +03:00
|
|
|
PYTEST=pytest-3
|
2017-08-18 00:11:06 +03:00
|
|
|
CFLAGS+=-std=gnu89 -O2 -g -MMD -Wall \
|
2017-01-08 12:13:18 +03:00
|
|
|
-Wno-pointer-sign \
|
|
|
|
-fno-strict-aliasing \
|
2019-08-27 20:33:57 +03:00
|
|
|
-fno-delete-null-pointer-checks \
|
2018-11-23 08:44:20 +03:00
|
|
|
-I. -Iinclude -Iraid \
|
2017-01-08 12:13:18 +03:00
|
|
|
-D_FILE_OFFSET_BITS=64 \
|
|
|
|
-D_GNU_SOURCE \
|
|
|
|
-D_LGPL_SOURCE \
|
|
|
|
-DRCU_MEMBARRIER \
|
2018-02-16 23:36:33 +03:00
|
|
|
-DZSTD_STATIC_LINKING_ONLY \
|
2019-10-01 21:06:58 +03:00
|
|
|
-DFUSE_USE_VERSION=32 \
|
2017-10-06 00:42:19 +03:00
|
|
|
-DNO_BCACHEFS_CHARDEV \
|
|
|
|
-DNO_BCACHEFS_FS \
|
|
|
|
-DNO_BCACHEFS_SYSFS \
|
2018-02-14 12:28:24 +03:00
|
|
|
-DVERSION_STRING='"$(VERSION)"' \
|
2017-01-08 12:13:18 +03:00
|
|
|
$(EXTRA_CFLAGS)
|
2019-01-14 02:01:12 +03:00
|
|
|
LDFLAGS+=$(CFLAGS) $(EXTRA_LDFLAGS)
|
2017-02-02 06:16:42 +03:00
|
|
|
|
2019-01-14 02:01:12 +03:00
|
|
|
VERSION?=$(shell git describe --dirty=+ 2>/dev/null || echo v0.1-nogit)
|
2018-02-14 12:28:24 +03:00
|
|
|
|
2021-07-29 00:26:38 +03:00
|
|
|
include Makefile.compiler
|
2017-04-04 11:28:13 +03:00
|
|
|
|
2021-07-24 09:29:32 +03:00
|
|
|
CFLAGS+=$(call cc-disable-warning, unused-but-set-variable)
|
|
|
|
CFLAGS+=$(call cc-disable-warning, stringop-overflow)
|
|
|
|
CFLAGS+=$(call cc-disable-warning, zero-length-bounds)
|
|
|
|
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)
|
2010-05-15 19:26:35 +04:00
|
|
|
|
2020-05-04 16:28:38 +03:00
|
|
|
PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib liblz4 libzstd libudev"
|
2019-11-11 23:00:08 +03:00
|
|
|
ifdef BCACHEFS_FUSE
|
2019-12-06 08:51:10 +03:00
|
|
|
PKGCONFIG_LIBS+="fuse3 >= 3.7"
|
2019-11-11 23:00:08 +03:00
|
|
|
CFLAGS+=-DBCACHEFS_FUSE
|
|
|
|
endif
|
2018-02-16 23:36:33 +03:00
|
|
|
|
2019-02-24 12:47:35 +03:00
|
|
|
PKGCONFIG_CFLAGS:=$(shell $(PKG_CONFIG) --cflags $(PKGCONFIG_LIBS))
|
2019-01-14 11:25:02 +03:00
|
|
|
ifeq (,$(PKGCONFIG_CFLAGS))
|
2019-02-24 12:47:35 +03:00
|
|
|
$(error pkg-config error, command: $(PKG_CONFIG) --cflags $(PKGCONFIG_LIBS))
|
2019-01-14 11:25:02 +03:00
|
|
|
endif
|
2019-02-24 12:47:35 +03:00
|
|
|
PKGCONFIG_LDLIBS:=$(shell $(PKG_CONFIG) --libs $(PKGCONFIG_LIBS))
|
2019-01-14 11:25:02 +03:00
|
|
|
ifeq (,$(PKGCONFIG_LDLIBS))
|
2019-02-24 12:47:35 +03:00
|
|
|
$(error pkg-config error, command: $(PKG_CONFIG) --libs $(PKGCONFIG_LIBS))
|
2019-01-14 11:25:02 +03:00
|
|
|
endif
|
2019-01-14 02:01:12 +03:00
|
|
|
|
|
|
|
CFLAGS+=$(PKGCONFIG_CFLAGS)
|
|
|
|
LDLIBS+=$(PKGCONFIG_LDLIBS)
|
2018-02-16 23:36:33 +03:00
|
|
|
|
2020-05-04 16:28:38 +03:00
|
|
|
LDLIBS+=-lm -lpthread -lrt -lscrypt -lkeyutils -laio -ldl
|
2019-01-14 02:01:12 +03:00
|
|
|
LDLIBS+=$(EXTRA_LDLIBS)
|
2016-08-24 06:50:31 +03:00
|
|
|
|
2016-08-29 05:00:50 +03:00
|
|
|
ifeq ($(PREFIX),/usr)
|
2016-04-26 04:13:15 +03:00
|
|
|
ROOT_SBINDIR=/sbin
|
2018-02-11 20:35:15 +03:00
|
|
|
INITRAMFS_DIR=$(PREFIX)/share/initramfs-tools
|
2016-04-26 04:13:15 +03:00
|
|
|
else
|
|
|
|
ROOT_SBINDIR=$(PREFIX)/sbin
|
2018-02-11 20:35:15 +03:00
|
|
|
INITRAMFS_DIR=/etc/initramfs-tools
|
2016-04-26 04:13:15 +03:00
|
|
|
endif
|
2010-05-15 19:26:35 +04:00
|
|
|
|
2021-07-24 10:50:52 +03:00
|
|
|
var := $(shell rst2man -V 2>/dev/null)
|
2021-07-23 23:06:26 +03:00
|
|
|
ifeq ($(.SHELLSTATUS),0)
|
|
|
|
RST2MAN=rst2man
|
|
|
|
endif
|
|
|
|
|
2021-07-24 10:50:52 +03:00
|
|
|
var := $(shell rst2man.py -V 2>/dev/null)
|
2021-07-23 23:06:26 +03:00
|
|
|
ifeq ($(.SHELLSTATUS),0)
|
|
|
|
RST2MAN=rst2man.py
|
|
|
|
endif
|
|
|
|
|
|
|
|
undefine var
|
|
|
|
|
2021-07-24 10:50:52 +03:00
|
|
|
ifeq (,$(RST2MAN))
|
|
|
|
@echo "WARNING: no RST2MAN found!"
|
|
|
|
endif
|
|
|
|
|
2016-08-29 05:00:50 +03:00
|
|
|
.PHONY: all
|
2021-07-06 08:44:37 +03:00
|
|
|
all: bcachefs bcachefs.5
|
2016-04-26 04:13:15 +03:00
|
|
|
|
2019-12-29 02:16:09 +03:00
|
|
|
.PHONY: tests
|
|
|
|
tests: tests/test_helper
|
|
|
|
|
2019-11-03 10:35:03 +03:00
|
|
|
.PHONY: check
|
2019-12-29 02:16:09 +03:00
|
|
|
check: tests bcachefs
|
2019-11-03 10:35:03 +03:00
|
|
|
cd tests; $(PYTEST)
|
|
|
|
|
2019-11-04 08:27:57 +03:00
|
|
|
.PHONY: TAGS tags
|
|
|
|
TAGS:
|
|
|
|
ctags -e -R .
|
|
|
|
|
|
|
|
tags:
|
|
|
|
ctags -R .
|
|
|
|
|
2021-07-08 08:07:22 +03:00
|
|
|
DOCSRC := opts_macro.h bcachefs.5.rst.tmpl
|
|
|
|
DOCGENERATED := bcachefs.5 doc/bcachefs.5.rst
|
|
|
|
DOCDEPS := $(addprefix ./doc/,$(DOCSRC))
|
2021-07-06 08:44:37 +03:00
|
|
|
bcachefs.5: $(DOCDEPS) libbcachefs/opts.h
|
2021-07-08 08:07:22 +03:00
|
|
|
$(CC) doc/opts_macro.h -I libbcachefs -I include -E 2>/dev/null \
|
|
|
|
| doc/macro2rst.py
|
2021-07-23 23:06:26 +03:00
|
|
|
$(RST2MAN) doc/bcachefs.5.rst bcachefs.5
|
2021-07-06 08:44:37 +03:00
|
|
|
|
2017-11-26 09:55:12 +03:00
|
|
|
SRCS=$(shell find . -type f -iname '*.c')
|
2017-03-20 02:56:34 +03:00
|
|
|
DEPS=$(SRCS:.c=.d)
|
2017-01-08 12:13:18 +03:00
|
|
|
-include $(DEPS)
|
2016-10-12 04:50:54 +03:00
|
|
|
|
2017-03-20 02:56:34 +03:00
|
|
|
OBJS=$(SRCS:.c=.o)
|
2019-11-03 10:35:03 +03:00
|
|
|
bcachefs: $(filter-out ./tests/%.o, $(OBJS))
|
|
|
|
|
2020-05-04 16:28:38 +03:00
|
|
|
MOUNT_SRCS=$(shell find mount/src -type f -iname '*.rs') \
|
|
|
|
mount/Cargo.toml mount/Cargo.lock mount/build.rs
|
2021-07-24 01:06:02 +03:00
|
|
|
|
|
|
|
debug: CFLAGS+=-Werror -DCONFIG_BCACHEFS_DEBUG=y -DCONFIG_VALGRIND=y
|
|
|
|
debug: bcachefs
|
|
|
|
|
2020-05-04 16:28:38 +03:00
|
|
|
libbcachefs_mount.a: $(MOUNT_SRCS)
|
|
|
|
LIBBCACHEFS_INCLUDE=$(CURDIR) cargo build --manifest-path mount/Cargo.toml --release
|
|
|
|
cp mount/target/release/libbcachefs_mount.a $@
|
|
|
|
|
|
|
|
MOUNT_OBJ=$(filter-out ./bcachefs.o ./tests/%.o ./cmd_%.o , $(OBJS))
|
|
|
|
mount.bcachefs: libbcachefs_mount.a $(MOUNT_OBJ)
|
|
|
|
$(CC) -Wl,--gc-sections libbcachefs_mount.a $(MOUNT_OBJ) -o $@ $(LDLIBS)
|
|
|
|
|
2019-11-03 10:35:03 +03:00
|
|
|
tests/test_helper: $(filter ./tests/%.o, $(OBJS))
|
2016-04-26 04:13:15 +03:00
|
|
|
|
2018-02-14 12:28:24 +03:00
|
|
|
# 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)' > $@
|
|
|
|
|
|
|
|
# Rebuild the 'version' command any time the version string changes
|
|
|
|
cmd_version.o : .version
|
|
|
|
|
2016-08-29 05:00:50 +03:00
|
|
|
.PHONY: install
|
2019-01-14 05:47:41 +03:00
|
|
|
install: INITRAMFS_HOOK=$(INITRAMFS_DIR)/hooks/bcachefs
|
|
|
|
install: INITRAMFS_SCRIPT=$(INITRAMFS_DIR)/scripts/local-premount/bcachefs
|
2017-03-20 02:56:34 +03:00
|
|
|
install: bcachefs
|
2019-01-14 05:47:41 +03:00
|
|
|
$(INSTALL) -m0755 -D bcachefs -t $(DESTDIR)$(ROOT_SBINDIR)
|
|
|
|
$(INSTALL) -m0755 fsck.bcachefs $(DESTDIR)$(ROOT_SBINDIR)
|
|
|
|
$(INSTALL) -m0755 mkfs.bcachefs $(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)
|
2020-08-25 03:23:45 +03:00
|
|
|
$(INSTALL) -m0755 -D mount.bcachefs.sh $(DESTDIR)$(ROOT_SBINDIR)
|
2019-01-14 05:47:41 +03:00
|
|
|
sed -i '/^# Note: make install replaces/,$$d' $(DESTDIR)$(INITRAMFS_HOOK)
|
|
|
|
echo "copy_exec $(ROOT_SBINDIR)/bcachefs /sbin/bcachefs" >> $(DESTDIR)$(INITRAMFS_HOOK)
|
2016-08-29 05:00:50 +03:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2021-07-06 08:44:37 +03:00
|
|
|
$(RM) bcachefs mount.bcachefs libbcachefs_mount.a tests/test_helper .version $(OBJS) $(DEPS) $(DOCGENERATED)
|
2020-05-04 16:28:38 +03:00
|
|
|
$(RM) -rf mount/target
|
2016-08-29 05:00:50 +03:00
|
|
|
|
|
|
|
.PHONY: deb
|
|
|
|
deb: all
|
2018-02-12 02:32:34 +03:00
|
|
|
debuild -us -uc -nc -b -i -I
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2021-07-06 20:41:31 +03:00
|
|
|
.PHONY: update-bcachefs-sources
|
2017-03-20 02:56:34 +03:00
|
|
|
update-bcachefs-sources:
|
2017-11-05 01:32:07 +03:00
|
|
|
git rm -rf --ignore-unmatch libbcachefs
|
2019-01-14 02:01:12 +03:00
|
|
|
test -d libbcachefs || mkdir libbcachefs
|
2017-03-20 02:56:34 +03:00
|
|
|
cp $(LINUX_DIR)/fs/bcachefs/*.[ch] libbcachefs/
|
2020-05-15 04:46:09 +03:00
|
|
|
git add libbcachefs/*.[ch]
|
2017-03-20 02:56:34 +03:00
|
|
|
cp $(LINUX_DIR)/include/trace/events/bcachefs.h include/trace/events/
|
2020-05-15 04:46:09 +03:00
|
|
|
git add include/trace/events/bcachefs.h
|
2021-06-30 13:35:36 +03:00
|
|
|
cp $(LINUX_DIR)/include/linux/xxhash.h include/linux/
|
|
|
|
git add include/linux/xxhash.h
|
|
|
|
cp $(LINUX_DIR)/lib/xxhash.c linux/
|
|
|
|
git add linux/xxhash.c
|
2020-05-15 04:46:09 +03:00
|
|
|
cp $(LINUX_DIR)/kernel/locking/six.c linux/
|
|
|
|
git add linux/six.c
|
|
|
|
cp $(LINUX_DIR)/include/linux/six.h include/linux/
|
|
|
|
git add include/linux/six.h
|
2021-03-29 00:38:28 +03:00
|
|
|
cp $(LINUX_DIR)/include/linux/list_nulls.h include/linux/
|
|
|
|
git add include/linux/list_nulls.h
|
|
|
|
cp $(LINUX_DIR)/include/linux/poison.h include/linux/
|
|
|
|
git add include/linux/poison.h
|
2021-07-29 00:26:38 +03:00
|
|
|
cp $(LINUX_DIR)/scripts/Makefile.compiler ./
|
|
|
|
git add Makefile.compiler
|
2019-01-14 02:01:12 +03:00
|
|
|
$(RM) libbcachefs/*.mod.c
|
|
|
|
git -C $(LINUX_DIR) rev-parse HEAD | tee .bcachefs_revision
|
2020-05-15 04:46:09 +03:00
|
|
|
git add .bcachefs_revision
|
2017-04-04 10:05:13 +03:00
|
|
|
|
2021-07-06 20:41:31 +03:00
|
|
|
.PHONY: update-commit-bcachefs-sources
|
2017-04-04 10:05:13 +03:00
|
|
|
update-commit-bcachefs-sources: update-bcachefs-sources
|
2019-01-14 02:01:12 +03:00
|
|
|
git commit -m "Update bcachefs sources to $(shell git -C $(LINUX_DIR) show --oneline --no-patch)"
|