mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-02 00:00:03 +03:00
a00998c4cd
The experimental fuse3 support is not complete yet, and fuse3 is new and still difficult to install on some platforms. Make it optional at compile time, and default to off. Signed-off-by: Justin Husted <sigstop@gmail.com>
139 lines
3.9 KiB
Makefile
139 lines
3.9 KiB
Makefile
|
|
PREFIX?=/usr/local
|
|
PKG_CONFIG?=pkg-config
|
|
INSTALL=install
|
|
PYTEST=pytest-3
|
|
CFLAGS+=-std=gnu89 -O2 -g -MMD -Wall \
|
|
-Wno-pointer-sign \
|
|
-fno-strict-aliasing \
|
|
-fno-delete-null-pointer-checks \
|
|
-I. -Iinclude -Iraid \
|
|
-D_FILE_OFFSET_BITS=64 \
|
|
-D_GNU_SOURCE \
|
|
-D_LGPL_SOURCE \
|
|
-DRCU_MEMBARRIER \
|
|
-DZSTD_STATIC_LINKING_ONLY \
|
|
-DFUSE_USE_VERSION=32 \
|
|
-DNO_BCACHEFS_CHARDEV \
|
|
-DNO_BCACHEFS_FS \
|
|
-DNO_BCACHEFS_SYSFS \
|
|
-DVERSION_STRING='"$(VERSION)"' \
|
|
$(EXTRA_CFLAGS)
|
|
LDFLAGS+=$(CFLAGS) $(EXTRA_LDFLAGS)
|
|
|
|
VERSION?=$(shell git describe --dirty=+ 2>/dev/null || echo v0.1-nogit)
|
|
|
|
CC_VERSION=$(shell $(CC) -v 2>&1|grep -E '(gcc|clang) version')
|
|
|
|
ifneq (,$(findstring gcc,$(CC_VERSION)))
|
|
CFLAGS+=-Wno-unused-but-set-variable
|
|
endif
|
|
|
|
ifneq (,$(findstring clang,$(CC_VERSION)))
|
|
CFLAGS+=-Wno-missing-braces
|
|
endif
|
|
|
|
ifdef D
|
|
CFLAGS+=-Werror
|
|
CFLAGS+=-DCONFIG_BCACHEFS_DEBUG=y
|
|
endif
|
|
|
|
PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib liblz4 libzstd"
|
|
ifdef BCACHEFS_FUSE
|
|
PKGCONFIG_LIBS+="fuse3"
|
|
CFLAGS+=-DBCACHEFS_FUSE
|
|
endif
|
|
|
|
PKGCONFIG_CFLAGS:=$(shell $(PKG_CONFIG) --cflags $(PKGCONFIG_LIBS))
|
|
ifeq (,$(PKGCONFIG_CFLAGS))
|
|
$(error pkg-config error, command: $(PKG_CONFIG) --cflags $(PKGCONFIG_LIBS))
|
|
endif
|
|
PKGCONFIG_LDLIBS:=$(shell $(PKG_CONFIG) --libs $(PKGCONFIG_LIBS))
|
|
ifeq (,$(PKGCONFIG_LDLIBS))
|
|
$(error pkg-config error, command: $(PKG_CONFIG) --libs $(PKGCONFIG_LIBS))
|
|
endif
|
|
|
|
CFLAGS+=$(PKGCONFIG_CFLAGS)
|
|
LDLIBS+=$(PKGCONFIG_LDLIBS)
|
|
|
|
LDLIBS+=-lm -lpthread -lrt -lscrypt -lkeyutils -laio
|
|
LDLIBS+=$(EXTRA_LDLIBS)
|
|
|
|
ifeq ($(PREFIX),/usr)
|
|
ROOT_SBINDIR=/sbin
|
|
INITRAMFS_DIR=$(PREFIX)/share/initramfs-tools
|
|
else
|
|
ROOT_SBINDIR=$(PREFIX)/sbin
|
|
INITRAMFS_DIR=/etc/initramfs-tools
|
|
endif
|
|
|
|
.PHONY: all
|
|
all: bcachefs
|
|
|
|
.PHONY: check
|
|
check: tests/test_helper bcachefs
|
|
cd tests; $(PYTEST)
|
|
|
|
.PHONY: TAGS tags
|
|
TAGS:
|
|
ctags -e -R .
|
|
|
|
tags:
|
|
ctags -R .
|
|
|
|
SRCS=$(shell find . -type f -iname '*.c')
|
|
DEPS=$(SRCS:.c=.d)
|
|
-include $(DEPS)
|
|
|
|
OBJS=$(SRCS:.c=.o)
|
|
bcachefs: $(filter-out ./tests/%.o, $(OBJS))
|
|
|
|
tests/test_helper: $(filter ./tests/%.o, $(OBJS))
|
|
|
|
# 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
|
|
|
|
.PHONY: install
|
|
install: INITRAMFS_HOOK=$(INITRAMFS_DIR)/hooks/bcachefs
|
|
install: INITRAMFS_SCRIPT=$(INITRAMFS_DIR)/scripts/local-premount/bcachefs
|
|
install: bcachefs
|
|
$(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)
|
|
sed -i '/^# Note: make install replaces/,$$d' $(DESTDIR)$(INITRAMFS_HOOK)
|
|
echo "copy_exec $(ROOT_SBINDIR)/bcachefs /sbin/bcachefs" >> $(DESTDIR)$(INITRAMFS_HOOK)
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
$(RM) bcachefs tests/test_helper .version $(OBJS) $(DEPS)
|
|
|
|
.PHONY: deb
|
|
deb: all
|
|
# --unsigned-source --unsigned-changes --no-pre-clean --build=binary
|
|
# --diff-ignore --tar-ignore
|
|
debuild -us -uc -nc -b -i -I
|
|
|
|
.PHONE: update-bcachefs-sources
|
|
update-bcachefs-sources:
|
|
git rm -rf --ignore-unmatch libbcachefs
|
|
test -d libbcachefs || mkdir libbcachefs
|
|
cp $(LINUX_DIR)/fs/bcachefs/*.[ch] libbcachefs/
|
|
cp $(LINUX_DIR)/include/trace/events/bcachefs.h include/trace/events/
|
|
$(RM) libbcachefs/*.mod.c
|
|
git -C $(LINUX_DIR) rev-parse HEAD | tee .bcachefs_revision
|
|
git add libbcachefs/*.[ch] include/trace/events/bcachefs.h .bcachefs_revision
|
|
|
|
.PHONE: update-commit-bcachefs-sources
|
|
update-commit-bcachefs-sources: update-bcachefs-sources
|
|
git commit -m "Update bcachefs sources to $(shell git -C $(LINUX_DIR) show --oneline --no-patch)"
|