]> git.sesse.net Git - bcachefs-tools-debian/blob - Makefile
snapraid
[bcachefs-tools-debian] / Makefile
1
2 PREFIX=/usr/local
3 INSTALL=install
4 CFLAGS+=-std=gnu89 -O2 -g -MMD -Wall                            \
5         -Wno-pointer-sign                                       \
6         -fno-strict-aliasing                                    \
7         -I. -Iinclude -Iraid                                    \
8         -D_FILE_OFFSET_BITS=64                                  \
9         -D_GNU_SOURCE                                           \
10         -D_LGPL_SOURCE                                          \
11         -DRCU_MEMBARRIER                                        \
12         -DZSTD_STATIC_LINKING_ONLY                              \
13         -DNO_BCACHEFS_CHARDEV                                   \
14         -DNO_BCACHEFS_FS                                        \
15         -DNO_BCACHEFS_SYSFS                                     \
16         -DVERSION_STRING='"$(VERSION)"'                         \
17         $(EXTRA_CFLAGS)
18 LDFLAGS+=$(CFLAGS)
19
20 VERSION?=$(shell git describe --dirty 2>/dev/null || echo 0.1-nogit)
21
22 CC_VERSION=$(shell $(CC) -v 2>&1|grep -E '(gcc|clang) version')
23
24 ifneq (,$(findstring gcc,$(CC_VERSION)))
25         CFLAGS+=-Wno-unused-but-set-variable
26 endif
27
28 ifneq (,$(findstring clang,$(CC_VERSION)))
29         CFLAGS+=-Wno-missing-braces
30 endif
31
32 ifdef D
33         CFLAGS+=-Werror
34         CFLAGS+=-DCONFIG_BCACHEFS_DEBUG=y
35 endif
36
37 PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib liblz4 libzstd"
38
39 CFLAGS+=`pkg-config --cflags    ${PKGCONFIG_LIBS}`
40 LDLIBS+=`pkg-config --libs      ${PKGCONFIG_LIBS}`
41
42 LDLIBS+=-lm -lpthread -lrt -lscrypt -lkeyutils -laio
43
44 ifeq ($(PREFIX),/usr)
45         ROOT_SBINDIR=/sbin
46         INITRAMFS_DIR=$(PREFIX)/share/initramfs-tools
47 else
48         ROOT_SBINDIR=$(PREFIX)/sbin
49         INITRAMFS_DIR=/etc/initramfs-tools
50 endif
51
52 .PHONY: all
53 all: bcachefs
54
55 SRCS=$(shell find . -type f -iname '*.c')
56 DEPS=$(SRCS:.c=.d)
57 -include $(DEPS)
58
59 OBJS=$(SRCS:.c=.o)
60 bcachefs: $(OBJS)
61
62 # If the version string differs from the last build, update the last version
63 ifneq ($(VERSION),$(shell cat .version 2>/dev/null))
64 .PHONY: .version
65 endif
66 .version:
67         echo '$(VERSION)' > $@
68
69 # Rebuild the 'version' command any time the version string changes
70 cmd_version.o : .version
71
72 .PHONY: install
73 install: bcachefs
74         mkdir -p $(DESTDIR)$(ROOT_SBINDIR)
75         mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8/
76         $(INSTALL) -m0755 bcachefs      $(DESTDIR)$(ROOT_SBINDIR)
77         $(INSTALL) -m0755 fsck.bcachefs $(DESTDIR)$(ROOT_SBINDIR)
78         $(INSTALL) -m0755 mkfs.bcachefs $(DESTDIR)$(ROOT_SBINDIR)
79         $(INSTALL) -m0755 -D initramfs/hook $(DESTDIR)$(INITRAMFS_DIR)/hooks/bcachefs
80         echo "copy_exec $(ROOT_SBINDIR)/bcachefs /sbin/bcachefs" >> $(DESTDIR)$(INITRAMFS_DIR)/hooks/bcachefs
81         $(INSTALL) -m0755 -D initramfs/script $(DESTDIR)$(INITRAMFS_DIR)/scripts/local-premount/bcachefs
82         $(INSTALL) -m0644 bcachefs.8    $(DESTDIR)$(PREFIX)/share/man/man8/
83
84 .PHONY: clean
85 clean:
86         $(RM) bcachefs $(OBJS) $(DEPS)
87
88 .PHONY: deb
89 deb: all
90 # --unsigned-source --unsigned-changes --no-pre-clean --build=binary
91 # --diff-ignore --tar-ignore
92         debuild -us -uc -nc -b -i -I
93
94 .PHONE: update-bcachefs-sources
95 update-bcachefs-sources:
96         git rm -rf --ignore-unmatch libbcachefs
97         cp $(LINUX_DIR)/fs/bcachefs/*.[ch] libbcachefs/
98         cp $(LINUX_DIR)/include/trace/events/bcachefs.h include/trace/events/
99         echo `cd $(LINUX_DIR); git rev-parse HEAD` > .bcachefs_revision
100         git add libbcachefs/*.[ch] include/trace/events/bcachefs.h .bcachefs_revision
101
102 .PHONE: update-commit-bcachefs-sources
103 update-commit-bcachefs-sources: update-bcachefs-sources
104         git commit -m "Update bcachefs sources to `cd $(LINUX_DIR); git show --oneline --no-patch`"