mirror of
https://github.com/trapexit/mergerfs.git
synced 2024-11-22 11:39:52 +08:00
rework makefiles + install mount tools
This commit is contained in:
parent
2f769e75c4
commit
5ce428ca59
32
Makefile
32
Makefile
|
@ -37,8 +37,7 @@ endif
|
|||
endif
|
||||
|
||||
USE_XATTR = 1
|
||||
|
||||
FUSE_CFLAGS = -D_FILE_OFFSET_BITS=64 -Ilibfuse/include
|
||||
UGID_USE_RWLOCK = 0
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
DEBUG_FLAGS := -g
|
||||
|
@ -58,29 +57,30 @@ else
|
|||
LTO_FLAGS :=
|
||||
endif
|
||||
|
||||
UGID_USE_RWLOCK = 0
|
||||
|
||||
OPTS = -O2
|
||||
SRC = $(wildcard src/*.cpp)
|
||||
OBJS = $(SRC:src/%.cpp=build/%.o)
|
||||
DEPS = $(SRC:src/%.cpp=build/%.d)
|
||||
MANPAGE = mergerfs.1
|
||||
CXXFLAGS += \
|
||||
$(OPTS) \
|
||||
CXXFLAGS = \
|
||||
-O2 \
|
||||
$(DEBUG_FLAGS) \
|
||||
$(STATIC_FLAGS) \
|
||||
$(LTO_FLAGS) \
|
||||
-Wall \
|
||||
-Wno-unused-result \
|
||||
$(FUSE_CFLAGS) \
|
||||
-DFUSE_USE_VERSION=29 \
|
||||
-MMD \
|
||||
-MMD
|
||||
FUSE_FLAGS = \
|
||||
-Ilibfuse/include \
|
||||
-D_FILE_OFFSET_BITS=64 \
|
||||
-DFUSE_USE_VERSION=29
|
||||
MFS_FLAGS = \
|
||||
-DUSE_XATTR=$(USE_XATTR) \
|
||||
-DUGID_USE_RWLOCK=$(UGID_USE_RWLOCK)
|
||||
LDFLAGS += \
|
||||
LDFLAGS = \
|
||||
-pthread \
|
||||
-lrt
|
||||
|
||||
DESTDIR =
|
||||
PREFIX = /usr/local
|
||||
EXEC_PREFIX = $(PREFIX)
|
||||
DATAROOTDIR = $(PREFIX)/share
|
||||
|
@ -108,7 +108,7 @@ objects: version build/stamp
|
|||
$(MAKE) $(OBJS)
|
||||
|
||||
build/mergerfs: libfuse objects
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OBJS) -o $@ libfuse/build/libfuse.a $(LDFLAGS)
|
||||
$(CXX) $(CXXFLAGS) $(FUSE_FLAGS) $(MFS_FLAGS) $(CPPFLAGS) $(OBJS) -o $@ libfuse/build/libfuse.a $(LDFLAGS)
|
||||
|
||||
mergerfs: build/mergerfs
|
||||
|
||||
|
@ -128,7 +128,7 @@ build/stamp:
|
|||
$(TOUCH) $@
|
||||
|
||||
build/%.o: src/%.cpp
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
$(CXX) $(CXXFLAGS) $(FUSE_FLAGS) $(MFS_FLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
.PHONY: clean
|
||||
clean: rpm-clean
|
||||
|
@ -142,15 +142,15 @@ ifeq ($(GIT_REPO),1)
|
|||
endif
|
||||
|
||||
.PHONY: install
|
||||
install: install-base install-mount.mergerfs install-man
|
||||
install: install-base install-mount-tools install-man
|
||||
|
||||
install-base: build/mergerfs
|
||||
$(MKDIR) -p "$(INSTALLBINDIR)"
|
||||
$(INSTALL) -v -m 0755 build/mergerfs "$(INSTALLBINDIR)/mergerfs"
|
||||
|
||||
install-mount.mergerfs: install-base
|
||||
install-mount-tools: install-base
|
||||
$(MKDIR) -p "$(INSTALLBINDIR)"
|
||||
$(LN) -fs "mergerfs" "$(INSTALLBINDIR)/mount.mergerfs"
|
||||
$(MAKE) -C libfuse install
|
||||
|
||||
install-man: $(MANPAGE)
|
||||
$(MKDIR) -p "$(INSTALLMAN1DIR)"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
VERSION = "2.9.7-mergerfs_2.29.0"
|
||||
OPTS = -O2
|
||||
VERSION = 2.9.7-mergerfs_2.29.0
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
DEBUG_FLAGS := -g
|
||||
|
@ -7,9 +6,20 @@ else
|
|||
DEBUG_FLAGS :=
|
||||
endif
|
||||
|
||||
DESTDIR = "/"
|
||||
BINDIR = "/bin"
|
||||
SBINDIR = "/sbin"
|
||||
DESTDIR =
|
||||
PREFIX = /usr/local
|
||||
EXEC_PREFIX = $(PREFIX)
|
||||
DATAROOTDIR = $(PREFIX)/share
|
||||
DATADIR = $(DATAROOTDIR)
|
||||
BINDIR = $(EXEC_PREFIX)/bin
|
||||
SBINDIR = $(EXEC_PREFIX)/sbin
|
||||
MANDIR = $(DATAROOTDIR)/man
|
||||
MAN1DIR = $(MANDIR)/man1
|
||||
|
||||
INSTALLBINDIR = $(DESTDIR)$(BINDIR)
|
||||
INSTALLSBINDIR = $(DESTDIR)$(SBINDIR)
|
||||
INSTALLMAN1DIR = $(DESTDIR)$(MAN1DIR)
|
||||
|
||||
SRC = \
|
||||
lib/buffer.c \
|
||||
lib/cuse_lowlevel.c \
|
||||
|
@ -27,24 +37,26 @@ SRC = \
|
|||
OBJS = $(SRC:lib/%.c=build/%.o)
|
||||
DEPS = $(SRC:lib/%.c=build/%.d)
|
||||
|
||||
CFLAGS += \
|
||||
$(OPTS) \
|
||||
CFLAGS = \
|
||||
-O2 \
|
||||
$(DEBUG_FLAGS) \
|
||||
-Wall \
|
||||
-pipe \
|
||||
'-D_FILE_OFFSET_BITS=64' \
|
||||
'-D_REENTRANT' \
|
||||
'-DFUSE_USE_VERSION=29' \
|
||||
'-DFUSERMOUNT_DIR="/usr/local/bin"' \
|
||||
'-DPACKAGE_VERSION=$(VERSION)' \
|
||||
-MMD
|
||||
FUSERMOUNT_DIR = $(BINDIR)
|
||||
FUSE_FLAGS = \
|
||||
-Iinclude \
|
||||
-Ibuild \
|
||||
-MMD
|
||||
LDFLAGS += \
|
||||
-D_REENTRANT \
|
||||
-D_FILE_OFFSET_BITS=64 \
|
||||
-DFUSE_USE_VERSION=29 \
|
||||
-DPACKAGE_VERSION=\"$(VERSION)\" \
|
||||
-DFUSERMOUNT_DIR=\"$(FUSERMOUNT_DIR)\"
|
||||
LDFLAGS = \
|
||||
-lrt \
|
||||
-pthread
|
||||
|
||||
all: build/libfuse.a
|
||||
all: build/libfuse.a mount.mergerfs mergerfs-fusermount
|
||||
|
||||
build/config.h: build/stamp
|
||||
ecfd/build | tee build/config.h
|
||||
|
@ -59,26 +71,34 @@ objects: build/config.h
|
|||
build/libfuse.a: objects
|
||||
ar rcs build/libfuse.a $(OBJS)
|
||||
|
||||
build/mergerfs-mount: build/config.h util/fusermount.c lib/mount_util.c
|
||||
$(CC) $(CFLAGS) -Ilib -o mergerfs-mount util/fusermount.c lib/mount_util.c
|
||||
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
|
||||
|
||||
build/mount.mergerfs: build/libfuse.a util/mount.fuse.c
|
||||
$(CC) $(CFLAGS) -o mount.mergerfs util/mount.fuse.c build/libfuse.a $(LDFLAGS)
|
||||
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
|
||||
|
||||
build/%.o: lib/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(FUSE_FLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
distclean: clean
|
||||
|
||||
install: build/mergerfs-mount build/mount.mergerfs
|
||||
install -D build/mergerfs-mount "$(DESTDIR)$(BINDIR)/mergerfs-mount"
|
||||
chown root:root "$(DESTDIR)$(BINDIR)/mergerfs-mount"
|
||||
chmod u+s "$(DESTDIR)$(BINDIR)/mergerfs-mount"
|
||||
install -D build/mount.mergerfs "$(DESTDIR)$(SBINDIR)/mount.mergerfs"
|
||||
strip:
|
||||
strip --strip-all build/mount.mergerfs
|
||||
strip --strip-all build/mergerfs-fusermount
|
||||
|
||||
.PHONY: objects
|
||||
install: mergerfs-fusermount mount.mergerfs strip
|
||||
install -D build/mergerfs-fusermount "$(INSTALLBINDIR)/mergerfs-fusermount"
|
||||
install -D build/mount.mergerfs "$(INSTALLSBINDIR)/mount.mergerfs"
|
||||
chown root:root "$(INSTALLBINDIR)/mergerfs-fusermount"
|
||||
chmod u+s "$(INSTALLBINDIR)/mergerfs-fusermount"
|
||||
|
||||
.PHONY: objects strip
|
||||
|
||||
-include $(DEPS)
|
||||
|
|
|
@ -143,7 +143,9 @@ static void mount_help(void)
|
|||
|
||||
static void exec_fusermount(const char *argv[])
|
||||
{
|
||||
execv(FUSERMOUNT_DIR "/" FUSERMOUNT_PROG, (char **) argv);
|
||||
execv(FUSERMOUNT_DIR "/mergerfs-" FUSERMOUNT_PROG, (char **) argv);
|
||||
execvp("mergerfs-" FUSERMOUNT_PROG, (char **) argv);
|
||||
execv(FUSERMOUNT_DIR "/" FUSERMOUNT_PROG, (char **) argv);
|
||||
execvp(FUSERMOUNT_PROG, (char **) argv);
|
||||
}
|
||||
|
||||
|
@ -407,7 +409,7 @@ static int fuse_mount_fusermount(const char *mountpoint, struct mount_opts *mo,
|
|||
rv = receive_fd(fds[1]);
|
||||
|
||||
if (!mo->auto_unmount) {
|
||||
/* with auto_unmount option fusermount will not exit until
|
||||
/* with auto_unmount option fusermount will not exit until
|
||||
this socket is closed */
|
||||
close(fds[1]);
|
||||
waitpid(pid, NULL, 0); /* bury zombie */
|
||||
|
|
|
@ -1293,7 +1293,7 @@ int main(int argc, char *argv[])
|
|||
return 0;
|
||||
|
||||
/* Become a daemon and wait for the parent to exit or die.
|
||||
ie For the control socket to get closed.
|
||||
ie For the control socket to get closed.
|
||||
btw We don't want to use daemon() function here because
|
||||
it forks and messes with the file descriptors. */
|
||||
setsid();
|
||||
|
|
|
@ -93,6 +93,7 @@ int main(int argc, char *argv[])
|
|||
else
|
||||
basename = argv[0];
|
||||
|
||||
type = "mergerfs";
|
||||
if (strncmp(basename, "mount.fuse.", 11) == 0)
|
||||
type = basename + 11;
|
||||
if (strncmp(basename, "mount.fuseblk.", 14) == 0)
|
|
@ -1,7 +1,7 @@
|
|||
Name: mergerfs
|
||||
Version: __VERSION__
|
||||
Release: 1%{?dist}
|
||||
Summary: A FUSE union filesystem
|
||||
Summary: A featureful FUSE based union filesystem
|
||||
|
||||
Group: Applications/System
|
||||
License: ISC
|
||||
|
@ -33,6 +33,7 @@ make install PREFIX=%{_prefix} DESTDIR=%{buildroot}
|
|||
|
||||
%files
|
||||
%{_bindir}/*
|
||||
%{_sbindir}/*
|
||||
%doc %{_mandir}/*
|
||||
|
||||
%changelog
|
||||
|
|
Loading…
Reference in New Issue
Block a user