mergerfs/libfuse/Makefile

147 lines
3.0 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
ifeq ($(LTO),1)
LTO_FLAGS := -flto
else
LTO_FLAGS :=
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
2022-11-30 07:24:09 +08:00
SRC_C = \
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_lowlevel.c \
lib/node.c \
lib/fuse_node.c \
lib/fuse_opt.c \
lib/fuse_session.c \
lib/fuse_signals.c \
lib/helper.c \
lib/mount.c
2022-11-30 07:24:09 +08:00
SRC_CPP = \
lib/format.cpp \
lib/os.cpp \
lib/cpu.cpp \
lib/fuse_config.cpp \
lib/fuse_loop.cpp \
2022-11-30 07:24:09 +08:00
lib/fuse_msgbuf.cpp
OBJS_C = $(SRC_C:lib/%.c=build/%.o)
OBJS_CPP = $(SRC_CPP:lib/%.cpp=build/%.o)
DEPS_C = $(SRC_C:lib/%.c=build/%.d)
DEPS_CPP = $(SRC_CPP:lib/%.cpp=build/%.d)
CFLAGS ?= \
$(OPT_FLAGS)
CFLAGS := \
${CFLAGS} \
$(LTO_FLAGS) \
-std=gnu99 \
2019-04-25 04:19:01 +08:00
-Wall \
-pipe \
2020-02-21 21:01:49 +08:00
-MMD
2022-11-30 07:24:09 +08:00
CXXFLAGS := \
${CXXFLAGS} \
$(LTO_FLAGS) \
2022-11-30 07:24:09 +08:00
-std=c++11 \
-Wall \
-pipe \
-MMD
2020-02-21 21:01:49 +08:00
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 \
-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
2022-11-30 07:24:09 +08:00
$(MAKE) $(OBJS_C) $(OBJS_CPP)
2019-04-25 04:19:01 +08:00
build/libfuse.a: objects
2022-11-30 07:24:09 +08:00
${AR} rcs build/libfuse.a $(OBJS_C) $(OBJS_CPP)
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 $@
2022-11-30 07:24:09 +08:00
build/%.o: lib/%.cpp
$(CXX) $(CXXFLAGS) $(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
2022-11-30 07:24:09 +08:00
-include $(DEPS_C) $(DEPS_CPP)