2010-05-15 19:26:35 +04:00
|
|
|
|
2010-12-16 12:22:45 +03:00
|
|
|
PREFIX=/usr
|
2013-10-07 01:13:05 +04:00
|
|
|
INSTALL=install
|
2017-02-02 06:16:42 +03:00
|
|
|
CFLAGS+=-std=gnu99 -O2 -g -MMD -Wall \
|
2017-01-08 12:13:18 +03:00
|
|
|
-Wno-unused-but-set-variable \
|
|
|
|
-Wno-pointer-sign \
|
|
|
|
-fno-strict-aliasing \
|
|
|
|
-I. -Iinclude -Ilibbcache \
|
|
|
|
-D_FILE_OFFSET_BITS=64 \
|
|
|
|
-D_GNU_SOURCE \
|
|
|
|
-D_LGPL_SOURCE \
|
|
|
|
-DRCU_MEMBARRIER \
|
|
|
|
$(EXTRA_CFLAGS)
|
2017-02-02 06:16:42 +03:00
|
|
|
LDFLAGS+=-O2 -g
|
|
|
|
|
|
|
|
ifdef D
|
|
|
|
CFLAGS+=-Werror
|
|
|
|
else
|
2017-02-03 09:45:08 +03:00
|
|
|
CFLAGS+=-flto
|
2017-02-02 06:16:42 +03:00
|
|
|
LDFLAGS+=-flto
|
|
|
|
endif
|
2010-05-15 19:26:35 +04:00
|
|
|
|
2016-10-04 06:22:17 +03:00
|
|
|
PKGCONFIG_LIBS="blkid uuid liburcu libsodium"
|
2016-08-24 06:50:31 +03:00
|
|
|
CFLAGS+=`pkg-config --cflags ${PKGCONFIG_LIBS}`
|
2016-10-04 06:22:17 +03:00
|
|
|
LDLIBS+=`pkg-config --libs ${PKGCONFIG_LIBS}` \
|
|
|
|
-lm -lpthread -lrt -lscrypt -lkeyutils
|
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
|
|
|
|
else
|
|
|
|
ROOT_SBINDIR=$(PREFIX)/sbin
|
|
|
|
endif
|
2010-05-15 19:26:35 +04:00
|
|
|
|
2016-08-29 05:00:50 +03:00
|
|
|
.PHONY: all
|
2016-04-26 04:13:15 +03:00
|
|
|
all: bcache
|
|
|
|
|
2016-03-12 09:18:42 +03:00
|
|
|
CCANSRCS=$(wildcard ccan/*/*.c)
|
|
|
|
CCANOBJS=$(patsubst %.c,%.o,$(CCANSRCS))
|
2014-12-06 06:20:03 +03:00
|
|
|
|
2017-01-08 12:13:18 +03:00
|
|
|
# Linux kernel shim:
|
|
|
|
LINUX_SRCS=$(wildcard linux/*.c linux/*/*.c)
|
|
|
|
LINUX_OBJS=$(LINUX_SRCS:.c=.o)
|
2016-03-12 09:18:42 +03:00
|
|
|
|
2017-02-02 06:16:42 +03:00
|
|
|
OBJS=bcache.o \
|
|
|
|
bcache-userspace-shim.o \
|
|
|
|
cmd_assemble.o \
|
2017-02-03 09:45:08 +03:00
|
|
|
cmd_debug.o \
|
2017-02-02 06:16:42 +03:00
|
|
|
cmd_device.o \
|
|
|
|
cmd_fs.o \
|
|
|
|
cmd_fsck.o \
|
|
|
|
cmd_format.o \
|
2016-10-04 06:22:17 +03:00
|
|
|
cmd_key.o \
|
2017-02-02 06:16:42 +03:00
|
|
|
cmd_run.o \
|
2016-10-04 06:22:17 +03:00
|
|
|
crypto.o \
|
2017-02-02 06:16:42 +03:00
|
|
|
libbcache.o \
|
2017-02-03 09:45:08 +03:00
|
|
|
qcow2.o \
|
2017-02-02 06:16:42 +03:00
|
|
|
tools-util.o \
|
|
|
|
$(LINUX_OBJS) \
|
|
|
|
$(CCANOBJS)
|
2014-12-06 06:20:03 +03:00
|
|
|
|
2017-01-08 12:13:18 +03:00
|
|
|
DEPS=$(OBJS:.o=.d)
|
|
|
|
-include $(DEPS)
|
2016-10-12 04:50:54 +03:00
|
|
|
|
2017-01-08 12:13:18 +03:00
|
|
|
bcache: $(OBJS)
|
2016-04-26 04:13:15 +03:00
|
|
|
|
2016-08-29 05:00:50 +03:00
|
|
|
.PHONY: install
|
|
|
|
install: bcache
|
|
|
|
mkdir -p $(DESTDIR)$(ROOT_SBINDIR)
|
|
|
|
mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8/
|
|
|
|
$(INSTALL) -m0755 bcache $(DESTDIR)$(ROOT_SBINDIR)
|
|
|
|
$(INSTALL) -m0755 mkfs.bcache $(DESTDIR)$(ROOT_SBINDIR)
|
|
|
|
$(INSTALL) -m0644 bcache.8 $(DESTDIR)$(PREFIX)/share/man/man8/
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2017-01-08 12:13:18 +03:00
|
|
|
$(RM) bcache $(OBJS) $(DEPS)
|
2016-08-29 05:00:50 +03:00
|
|
|
|
|
|
|
.PHONY: deb
|
|
|
|
deb: all
|
2016-12-12 02:45:48 +03:00
|
|
|
debuild --unsigned-source \
|
|
|
|
--unsigned-changes \
|
|
|
|
--no-pre-clean \
|
|
|
|
--build=binary \
|
|
|
|
--diff-ignore \
|
|
|
|
--tar-ignore
|
2017-01-08 12:13:18 +03:00
|
|
|
|
|
|
|
.PHONE: update-bcache-sources
|
|
|
|
update-bcache-sources:
|
|
|
|
echo BCACHE_REVISION=`cd $(LINUX_DIR); git rev-parse HEAD` > .bcache_revision
|
|
|
|
cp $(LINUX_DIR)/drivers/md/bcache/*.[ch] libbcache/
|
|
|
|
cp $(LINUX_DIR)/include/trace/events/bcache.h include/trace/events/
|
|
|
|
cp $(LINUX_DIR)/include/uapi/linux/bcache.h include/linux/
|
|
|
|
cp $(LINUX_DIR)/include/uapi/linux/bcache-ioctl.h include/linux/
|