mergerfs/libfuse/Makefile

123 lines
2.5 KiB
Makefile
Raw Normal View History

VERSION = 2.9.7-mergerfs_2.30.0
OS := $(shell uname -s)
ifeq ($(OS),Linux)
UTILS := utils
INSTALLUTILS := install-utils
else
UTILS :=
INSTALLUTILS :=
endif
ifeq ($(DEBUG),1)
OPT_FLAGS := -O0 -g -fsanitize=undefined
else
OPT_FLAGS := -O2
endif
2020-02-21 21:01:49 +08:00
DESTDIR =
PREFIX = /usr/local
EXEC_PREFIX = $(PREFIX)
DATAROOTDIR = $(PREFIX)/share
DATADIR = $(DATAROOTDIR)
BINDIR = $(EXEC_PREFIX)/bin
2020-06-30 21:30:31 +08:00
SBINDIR = /sbin
2020-02-21 21:01:49 +08:00
MANDIR = $(DATAROOTDIR)/man
MAN1DIR = $(MANDIR)/man1
INSTALLBINDIR = $(DESTDIR)$(BINDIR)
INSTALLSBINDIR = $(DESTDIR)$(SBINDIR)
INSTALLMAN1DIR = $(DESTDIR)$(MAN1DIR)
2020-08-09 04:03:28 +08:00
AR ?= ar
SRC = \
lib/buffer.c \
lib/crc32b.c \
2021-10-12 10:47:59 +08:00
lib/debug.c \
lib/fuse.c \
lib/fuse_dirents.c \
lib/fuse_loop_mt.c \
lib/fuse_lowlevel.c \
lib/fuse_mt.c \
lib/fuse_node.c \
lib/fuse_opt.c \
lib/fuse_session.c \
lib/fuse_signals.c \
lib/helper.c \
lib/mount.c
2019-04-25 04:19:01 +08:00
OBJS = $(SRC:lib/%.c=build/%.o)
DEPS = $(SRC:lib/%.c=build/%.d)
CFLAGS ?= \
$(OPT_FLAGS)
CFLAGS := \
${CFLAGS} \
-std=gnu99 \
2019-04-25 04:19:01 +08:00
-Wall \
-pipe \
2020-02-21 21:01:49 +08:00
-MMD
FUSERMOUNT_DIR = $(BINDIR)
FUSE_FLAGS = \
2019-04-25 04:19:01 +08:00
-Iinclude \
-Ibuild \
2020-02-21 21:01:49 +08:00
-D_REENTRANT \
-D_FILE_OFFSET_BITS=64 \
-DFUSE_USE_VERSION=29 \
-DPACKAGE_VERSION=\"$(VERSION)\" \
-DFUSERMOUNT_DIR=\"$(FUSERMOUNT_DIR)\"
LDFLAGS := \
${LDFLAGS} \
-lrt \
-pthread
all: build/libfuse.a $(UTILS)
2019-04-25 04:19:01 +08:00
build/config.h: build/stamp
ecfd/build | tee build/config.h
2019-04-25 04:19:01 +08:00
build/stamp:
mkdir -p build
touch $@
2019-04-25 04:19:01 +08:00
objects: build/config.h
$(MAKE) $(OBJS)
build/libfuse.a: objects
2020-08-09 04:03:28 +08:00
${AR} rcs build/libfuse.a $(OBJS)
utils: mergerfs-fusermount mount.mergerfs
2020-02-21 21:01:49 +08:00
build/mergerfs-fusermount: build/config.h util/fusermount.c lib/mount_util.c
$(CC) $(CFLAGS) $(FUSE_FLAGS) -Ilib -o build/mergerfs-fusermount util/fusermount.c lib/mount_util.c
2020-02-21 21:01:49 +08:00
mergerfs-fusermount: build/mergerfs-fusermount
build/mount.mergerfs: build/libfuse.a util/mount.mergerfs.c
$(CC) $(CFLAGS) $(FUSE_FLAGS) -o build/mount.mergerfs util/mount.mergerfs.c build/libfuse.a $(LDFLAGS)
mount.mergerfs: build/mount.mergerfs
2019-04-25 04:19:01 +08:00
build/%.o: lib/%.c
2020-02-21 21:01:49 +08:00
$(CC) $(CFLAGS) $(FUSE_FLAGS) -c $< -o $@
clean:
2019-04-25 04:19:01 +08:00
rm -rf build
distclean: clean
2020-02-21 21:01:49 +08:00
strip:
strip --strip-all build/mount.mergerfs
strip --strip-all build/mergerfs-fusermount
install-utils: mergerfs-fusermount mount.mergerfs strip
2020-02-21 21:01:49 +08:00
install -D build/mergerfs-fusermount "$(INSTALLBINDIR)/mergerfs-fusermount"
install -D build/mount.mergerfs "$(INSTALLSBINDIR)/mount.mergerfs"
chown root "$(INSTALLBINDIR)/mergerfs-fusermount"
2020-02-21 21:01:49 +08:00
chmod u+s "$(INSTALLBINDIR)/mergerfs-fusermount"
2019-04-25 04:19:01 +08:00
install: $(INSTALLUTILS)
.PHONY: objects strip utils install install-utils
-include $(DEPS)