cleanup and rework build system

This commit is contained in:
Antonio SJ Musumeci 2019-04-24 16:19:01 -04:00
parent 85e2a3e71b
commit 825fcf7f35
7 changed files with 132 additions and 130 deletions

View File

@ -18,7 +18,17 @@ matrix:
dist: trusty dist: trusty
compiler: clang compiler: clang
sudo: required sudo: required
- os: linux
dist: xenial
compiler: gcc
sudo: required
- os: linux
dist: xenial
compiler: clang
sudo: required
script: script:
- sudo -E apt-get install fakeroot
- sudo -E make install-build-pkgs - sudo -E make install-build-pkgs
- make - make
- make deb

View File

@ -39,8 +39,6 @@ endif
USE_XATTR = 1 USE_XATTR = 1
FUSE_CFLAGS = -D_FILE_OFFSET_BITS=64 -Ilibfuse/include FUSE_CFLAGS = -D_FILE_OFFSET_BITS=64 -Ilibfuse/include
FUSE_LIBS = libfuse/obj/libfuse.a
FUSE_TARGET = $(FUSE_LIBS)
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
DEBUG_FLAGS := -g DEBUG_FLAGS := -g
@ -64,11 +62,11 @@ UGID_USE_RWLOCK = 0
OPTS = -O2 OPTS = -O2
SRC = $(wildcard src/*.cpp) SRC = $(wildcard src/*.cpp)
OBJ = $(SRC:src/%.cpp=obj/%.o) OBJS = $(SRC:src/%.cpp=build/%.o)
DEPS = $(OBJ:obj/%.o=obj/%.d) DEPS = $(SRC:src/%.cpp=build/%.d)
TARGET = mergerfs MANPAGE = mergerfs.1
MANPAGE = $(TARGET).1 CXXFLAGS += \
CXXFLAGS = $(OPTS) \ $(OPTS) \
$(DEBUG_FLAGS) \ $(DEBUG_FLAGS) \
$(STATIC_FLAGS) \ $(STATIC_FLAGS) \
$(LTO_FLAGS) \ $(LTO_FLAGS) \
@ -79,6 +77,9 @@ CXXFLAGS = $(OPTS) \
-MMD \ -MMD \
-DUSE_XATTR=$(USE_XATTR) \ -DUSE_XATTR=$(USE_XATTR) \
-DUGID_USE_RWLOCK=$(UGID_USE_RWLOCK) -DUGID_USE_RWLOCK=$(UGID_USE_RWLOCK)
LDFLAGS += \
-pthread \
-lrt
PREFIX = /usr/local PREFIX = /usr/local
EXEC_PREFIX = $(PREFIX) EXEC_PREFIX = $(PREFIX)
@ -93,77 +94,79 @@ INSTALLBINDIR = $(DESTDIR)$(BINDIR)
INSTALLSBINDIR = $(DESTDIR)$(SBINDIR) INSTALLSBINDIR = $(DESTDIR)$(SBINDIR)
INSTALLMAN1DIR = $(DESTDIR)$(MAN1DIR) INSTALLMAN1DIR = $(DESTDIR)$(MAN1DIR)
all: $(TARGET) .PHONY: all
all: mergerfs
.PHONY: help
help: help:
@echo "usage: make\n" @echo "usage: make\n"
@echo "make USE_XATTR=0 - build program without xattrs functionality" @echo "make USE_XATTR=0 - build program without xattrs functionality"
@echo "make STATIC=1 - build static binary" @echo "make STATIC=1 - build static binary"
@echo "make LTO=1 - build with link time optimization" @echo "make LTO=1 - build with link time optimization"
$(TARGET): version obj/obj-stamp $(FUSE_TARGET) $(OBJ) objects: version build/stamp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJ) -o $@ $(FUSE_LIBS) -pthread -lrt $(MAKE) $(OBJS)
mount.mergerfs: $(TARGET) build/mergerfs: libfuse objects
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OBJS) -o $@ libfuse/build/libfuse.a $(LDFLAGS)
mergerfs: build/mergerfs
build/mount.mergerfs: build/mergerfs
$(LN) -fs "$<" "$@" $(LN) -fs "$<" "$@"
changelog: changelog:
ifeq ($(GIT_REPO),1) ifeq ($(GIT_REPO),1)
$(GIT2DEBCL) --name $(TARGET) > ChangeLog $(GIT2DEBCL) --name mergerfs > ChangeLog
else else
@echo "WARNING: need git repo to generate ChangeLog" @echo "WARNING: need git repo to generate ChangeLog"
endif endif
authors: .PHONY: version
ifeq ($(GIT_REPO),1)
$(GIT) log --format='%aN <%aE>' | sort -f | uniq > AUTHORS
else
@echo "WARNING: need git repo to generate AUTHORS"
endif
version: version:
tools/update-version tools/update-version
obj/obj-stamp: build/stamp:
$(MKDIR) -p obj $(MKDIR) -p build
$(TOUCH) $@ $(TOUCH) $@
obj/%.o: src/%.cpp build/%.o: src/%.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
.PHONY: clean
clean: rpm-clean clean: rpm-clean
$(RM) -f src/version.hpp $(RM) -rf build
$(RM) -rf obj
$(RM) -f "$(TARGET)" mount.mergerfs
$(FIND) . -name "*~" -delete $(FIND) . -name "*~" -delete
cd libfuse && $(MAKE) clean $(MAKE) -C libfuse clean
distclean: clean distclean: clean
ifeq ($(GIT_REPO),1) ifeq ($(GIT_REPO),1)
$(GIT) clean -xfd $(GIT) clean -xfd
endif endif
.PHONY: install
install: install-base install-mount.mergerfs install-man install: install-base install-mount.mergerfs install-man
install-base: $(TARGET) install-base: build/mergerfs
$(MKDIR) -p "$(INSTALLBINDIR)" $(MKDIR) -p "$(INSTALLBINDIR)"
$(INSTALL) -v -m 0755 "$(TARGET)" "$(INSTALLBINDIR)/$(TARGET)" $(INSTALL) -v -m 0755 build/mergerfs "$(INSTALLBINDIR)/mergerfs"
install-mount.mergerfs: mount.mergerfs install-mount.mergerfs: build/mount.mergerfs
$(MKDIR) -p "$(INSTALLBINDIR)" $(MKDIR) -p "$(INSTALLBINDIR)"
$(CP) -a "$<" "$(INSTALLBINDIR)/$<" $(CP) -a build/mount.mergerfs "$(INSTALLBINDIR)/mount.mergerfs"
install-man: $(MANPAGE) install-man: $(MANPAGE)
$(MKDIR) -p "$(INSTALLMAN1DIR)" $(MKDIR) -p "$(INSTALLMAN1DIR)"
$(INSTALL) -v -m 0644 "man/$(MANPAGE)" "$(INSTALLMAN1DIR)/$(MANPAGE)" $(INSTALL) -v -m 0644 "man/$(MANPAGE)" "$(INSTALLMAN1DIR)/$(MANPAGE)"
install-strip: install-base install-strip: install-base
$(STRIP) "$(INSTALLBINDIR)/$(TARGET)" $(STRIP) "$(INSTALLBINDIR)/mergerfs"
.PHONY: uninstall
uninstall: uninstall-base uninstall-mount.mergerfs uninstall-man uninstall: uninstall-base uninstall-mount.mergerfs uninstall-man
uninstall-base: uninstall-base:
$(RM) -f "$(INSTALLBINDIR)/$(TARGET)" $(RM) -f "$(INSTALLBINDIR)/mergerfs"
uninstall-mount.mergerfs: uninstall-mount.mergerfs:
$(RM) -f "$(INSTALLBINDIR)/mount.mergerfs" $(RM) -f "$(INSTALLBINDIR)/mount.mergerfs"
@ -180,10 +183,11 @@ endif
man: $(MANPAGE) man: $(MANPAGE)
tarball: man changelog authors version .PHONY: tarball
tarball: man changelog version
$(eval VERSION := $(shell cat VERSION)) $(eval VERSION := $(shell cat VERSION))
$(eval VERSION := $(subst -,_,$(VERSION))) $(eval VERSION := $(subst -,_,$(VERSION)))
$(eval FILENAME := $(TARGET)-$(VERSION)) $(eval FILENAME := mergerfs-$(VERSION))
$(eval TMPDIR := $(shell $(MKTEMP) --tmpdir -d .$(FILENAME).XXXXXXXX)) $(eval TMPDIR := $(shell $(MKTEMP) --tmpdir -d .$(FILENAME).XXXXXXXX))
$(MKDIR) $(TMPDIR)/$(FILENAME) $(MKDIR) $(TMPDIR)/$(FILENAME)
$(CP) -ar . $(TMPDIR)/$(FILENAME) $(CP) -ar . $(TMPDIR)/$(FILENAME)
@ -192,19 +196,24 @@ tarball: man changelog authors version
debian-changelog: debian-changelog:
ifeq ($(GIT_REPO),1) ifeq ($(GIT_REPO),1)
$(GIT2DEBCL) --name $(TARGET) > debian/changelog $(GIT2DEBCL) --name mergerfs > debian/changelog
else else
cp ChangeLog debian/changelog cp ChangeLog debian/changelog
endif endif
signed-deb: distclean debian-changelog signed-deb:
$(MAKE) distclean
$(MAKE) debian-changelog
dpkg-source -b .
dpkg-buildpackage -nc dpkg-buildpackage -nc
deb: deb:
$(MAKE) distclean $(MAKE) distclean
$(MAKE) debian-changelog $(MAKE) debian-changelog
dpkg-source -b .
dpkg-buildpackage -nc -uc -us dpkg-buildpackage -nc -uc -us
.PHONY: rpm-clean
rpm-clean: rpm-clean:
$(RM) -rf rpmbuild $(RM) -rf rpmbuild
@ -212,19 +221,18 @@ rpm: tarball
$(eval VERSION := $(shell cat VERSION)) $(eval VERSION := $(shell cat VERSION))
$(eval VERSION := $(subst -,_,$(VERSION))) $(eval VERSION := $(subst -,_,$(VERSION)))
$(MKDIR) -p rpmbuild/BUILD rpmbuild/RPMS rpmbuild/SOURCES $(MKDIR) -p rpmbuild/BUILD rpmbuild/RPMS rpmbuild/SOURCES
$(SED) 's/__VERSION__/$(VERSION)/g' $(TARGET).spec > \ $(SED) 's/__VERSION__/$(VERSION)/g' mergerfs.spec > \
rpmbuild/SOURCES/$(TARGET).spec rpmbuild/SOURCES/mergerfs.spec
cp -ar $(TARGET)-$(VERSION).tar.gz rpmbuild/SOURCES cp -ar mergerfs-$(VERSION).tar.gz rpmbuild/SOURCES
$(RPMBUILD) -ba rpmbuild/SOURCES/$(TARGET).spec \ $(RPMBUILD) -ba rpmbuild/SOURCES/mergerfs.spec \
--define "_topdir $(CURDIR)/rpmbuild" --define "_topdir $(CURDIR)/rpmbuild"
.PHONY: install-build-pkgs
install-build-pkgs: install-build-pkgs:
tools/install-build-pkgs tools/install-build-pkgs
unexport CFLAGS .PHONY: libfuse
libfuse/obj/libfuse.a: libfuse:
cd libfuse && $(MAKE) libfuse.a $(MAKE) -C libfuse
.PHONY: all clean install help version
-include $(DEPS) -include $(DEPS)

View File

@ -1,6 +1,6 @@
% mergerfs(1) mergerfs user manual % mergerfs(1) mergerfs user manual
% Antonio SJ Musumeci <trapexit@spawn.link> % Antonio SJ Musumeci <trapexit@spawn.link>
% 2019-04-23 % 2019-05-03
# NAME # NAME
@ -19,7 +19,7 @@ mergerfs -o&lt;options&gt; &lt;branches&gt; &lt;mountpoint&gt;
# FEATURES # FEATURES
* Runs in userspace (FUSE) * Runs in userspace (FUSE)
* Configurable behaviors * Configurable behaviors / file placement
* Support for extended attributes (xattrs) * Support for extended attributes (xattrs)
* Support for file attributes (chattr) * Support for file attributes (chattr)
* Runtime configurable (via xattrs) * Runtime configurable (via xattrs)
@ -28,7 +28,8 @@ mergerfs -o&lt;options&gt; &lt;branches&gt; &lt;mountpoint&gt;
* Works with heterogeneous filesystem types * Works with heterogeneous filesystem types
* Handling of writes to full drives (transparently move file to drive with capacity) * Handling of writes to full drives (transparently move file to drive with capacity)
* Handles pool of read-only and read/write drives * Handles pool of read-only and read/write drives
* Turn read-only files into symlinks to increase read performance * Can turn read-only files into symlinks to underlying file
* Hard link copy-on-write / CoW
# How it works # How it works
@ -56,7 +57,7 @@ A + B = C
+-- file6 +-- file6
``` ```
mergerfs does **not** support the copy-on-write (CoW) behavior found in **aufs** and **overlayfs**. You can **not** mount a read-only filesystem and write to it. However, mergerfs will ignore read-only drives when creating new files so you can mix rw and ro drives. mergerfs does **not** support the copy-on-write (CoW) behavior found in **aufs** and **overlayfs**. You can **not** mount a read-only filesystem and write to it. However, mergerfs will ignore read-only drives when creating new files so you can mix read-write and read-only drives.
# OPTIONS # OPTIONS
@ -348,30 +349,22 @@ $ make
$ sudo make install $ sudo make install
``` ```
#### Generically with system libfuse #### Build options
**NOTE:** Configurable threading and thus `-o threads=num` option will be unavailable when built with system libfuse.
Have git, g++, make, python, pkg-config installed.
Also, install libfuse >= 2.9.7 (but not libfuse-3.x) and matching libfuse-dev (or libfuse-devel).
``` ```
$ cd mergerfs $ make help
$ make INTERNAL_FUSE=0 usage: make
$ sudo make INTERNAL_FUSE=0 install
```
#### Other build options make USE_XATTR=0 - build program without xattrs functionality
make STATIC=1 - build static binary
``` make LTO=1 - build with link time optimization
$ make STATIC=1 # builds a static binary
$ make LTO=1 # perform link time optimization
``` ```
# RUNTIME CONFIG # RUNTIME CONFIG
#### .mergerfs pseudo file #### #### .mergerfs pseudo file ####
``` ```
<mountpoint>/.mergerfs <mountpoint>/.mergerfs
``` ```

View File

@ -24,10 +24,11 @@ SRC = \
lib/fuse_signals.c \ lib/fuse_signals.c \
lib/helper.c \ lib/helper.c \
lib/mount.c lib/mount.c
OBJS = $(SRC:lib/%.c=build/%.o)
DEPS = $(SRC:lib/%.c=build/%.d)
OBJ = $(SRC:lib/%.c=obj/%.o) CFLAGS += \
DEPS = $(OBJ:obj/%.o=obj/%.d) $(OPT) \
CFLAGS = $(OPT) \
$(DEBUG_FLAGS) \ $(DEBUG_FLAGS) \
-Wall \ -Wall \
-pipe \ -pipe \
@ -37,47 +38,47 @@ CFLAGS = $(OPT) \
'-DFUSERMOUNT_DIR="/usr/local/bin"' \ '-DFUSERMOUNT_DIR="/usr/local/bin"' \
'-DPACKAGE_VERSION=$(VERSION)' \ '-DPACKAGE_VERSION=$(VERSION)' \
-Iinclude \ -Iinclude \
-Ibuild \
-MMD -MMD
LDFLAGS = \ LDFLAGS += \
-lrt \ -lrt \
-pthread -pthread
all: obj/libfuse.a all: build/libfuse.a
libfuse.a: obj/libfuse.a build/config.h: build/stamp
ecfd/build | tee build/config.h
include/config.h: build/stamp:
ecfd/build | tee include/config.h mkdir -p build
obj/obj-stamp:
mkdir -p obj
touch $@ touch $@
obj/libfuse.a: objects: build/config.h
$(MAKE) obj/obj-stamp $(MAKE) $(OBJS)
$(MAKE) include/config.h
$(MAKE) $(OBJ)
ar rcs obj/libfuse.a $(OBJ)
mergerfs-mount: include/config.h util/fusermount.c lib/mount_util.c 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 $(CC) $(CFLAGS) -Ilib -o mergerfs-mount util/fusermount.c lib/mount_util.c
mount.mergerfs: obj/libfuse.a util/mount.fuse.c build/mount.mergerfs: build/libfuse.a util/mount.fuse.c
$(CC) $(CFLAGS) -o mount.mergerfs util/mount.fuse.c obj/libfuse.a $(LDFLAGS) $(CC) $(CFLAGS) -o mount.mergerfs util/mount.fuse.c build/libfuse.a $(LDFLAGS)
obj/%.o: lib/%.c build/%.o: lib/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
clean: clean:
rm -rf obj include/config.h mergerfs-mount mount.mergerfs rm -rf build
distclean: clean distclean: clean
git clean -fdx
install: install: build/mergerfs-mount build/mount.mergerfs
install -D mergerfs-mount "$(DESTDIR)$(BINDIR)/mergerfs-mount" install -D build/mergerfs-mount "$(DESTDIR)$(BINDIR)/mergerfs-mount"
chown root:root "$(DESTDIR)$(BINDIR)/mergerfs-mount" chown root:root "$(DESTDIR)$(BINDIR)/mergerfs-mount"
chmod u+s "$(DESTDIR)$(BINDIR)/mergerfs-mount" chmod u+s "$(DESTDIR)$(BINDIR)/mergerfs-mount"
install -D mount.mergerfs "$(DESTDIR)$(SBINDIR)/mount.mergerfs" install -D build/mount.mergerfs "$(DESTDIR)$(SBINDIR)/mount.mergerfs"
.PHONY: objects
-include $(DEPS) -include $(DEPS)

View File

@ -1,7 +1,7 @@
.\"t .\"t
.\" Automatically generated by Pandoc 1.19.2.4 .\" Automatically generated by Pandoc 1.19.2.4
.\" .\"
.TH "mergerfs" "1" "2019\-04\-23" "mergerfs user manual" "" .TH "mergerfs" "1" "2019\-05\-03" "mergerfs user manual" ""
.hy .hy
.SH NAME .SH NAME
.PP .PP
@ -19,7 +19,7 @@ It is similar to \f[B]mhddfs\f[], \f[B]unionfs\f[], and \f[B]aufs\f[].
.IP \[bu] 2 .IP \[bu] 2
Runs in userspace (FUSE) Runs in userspace (FUSE)
.IP \[bu] 2 .IP \[bu] 2
Configurable behaviors Configurable behaviors / file placement
.IP \[bu] 2 .IP \[bu] 2
Support for extended attributes (xattrs) Support for extended attributes (xattrs)
.IP \[bu] 2 .IP \[bu] 2
@ -38,7 +38,9 @@ capacity)
.IP \[bu] 2 .IP \[bu] 2
Handles pool of read\-only and read/write drives Handles pool of read\-only and read/write drives
.IP \[bu] 2 .IP \[bu] 2
Turn read\-only files into symlinks to increase read performance Can turn read\-only files into symlinks to underlying file
.IP \[bu] 2
Hard link copy\-on\-write / CoW
.SH How it works .SH How it works
.PP .PP
mergerfs logically merges multiple paths together. mergerfs logically merges multiple paths together.
@ -74,7 +76,7 @@ mergerfs does \f[B]not\f[] support the copy\-on\-write (CoW) behavior
found in \f[B]aufs\f[] and \f[B]overlayfs\f[]. found in \f[B]aufs\f[] and \f[B]overlayfs\f[].
You can \f[B]not\f[] mount a read\-only filesystem and write to it. You can \f[B]not\f[] mount a read\-only filesystem and write to it.
However, mergerfs will ignore read\-only drives when creating new files However, mergerfs will ignore read\-only drives when creating new files
so you can mix rw and ro drives. so you can mix read\-write and read\-only drives.
.SH OPTIONS .SH OPTIONS
.SS mount options .SS mount options
.IP \[bu] 2 .IP \[bu] 2
@ -815,28 +817,16 @@ $\ make
$\ sudo\ make\ install $\ sudo\ make\ install
\f[] \f[]
.fi .fi
.SS Generically with system libfuse .SS Build options
.PP
\f[B]NOTE:\f[] Configurable threading and thus \f[C]\-o\ threads=num\f[]
option will be unavailable when built with system libfuse.
.PP
Have git, g++, make, python, pkg\-config installed.
Also, install libfuse >= 2.9.7 (but not libfuse\-3.x) and matching
libfuse\-dev (or libfuse\-devel).
.IP .IP
.nf .nf
\f[C] \f[C]
$\ cd\ mergerfs $\ make\ help
$\ make\ INTERNAL_FUSE=0 usage:\ make
$\ sudo\ make\ INTERNAL_FUSE=0\ install
\f[] make\ USE_XATTR=0\ \ \ \ \ \ \-\ build\ program\ without\ xattrs\ functionality
.fi make\ STATIC=1\ \ \ \ \ \ \ \ \ \-\ build\ static\ binary
.SS Other build options make\ LTO=1\ \ \ \ \ \ \ \ \ \ \ \ \-\ build\ with\ link\ time\ optimization
.IP
.nf
\f[C]
$\ make\ STATIC=1\ #\ builds\ a\ static\ binary
$\ make\ LTO=1\ \ \ \ #\ perform\ link\ time\ optimization
\f[] \f[]
.fi .fi
.SH RUNTIME CONFIG .SH RUNTIME CONFIG

View File

@ -15,13 +15,15 @@ BuildRequires: git
Requires: fuse Requires: fuse
%global debug_package %{nil}
%prep %prep
%setup -q %setup -q
%description %description
mergerfs is similar to mhddfs, unionfs, and aufs. Like mhddfs in that it too mergerfs is a union filesystem geared towards simplifying storage and
uses FUSE. Like aufs in that it provides multiple policies for how to handle management of files across numerous commodity storage devices. It is
behavior. similar to mhddfs, unionfs, and aufs.
%build %build
make %{?_smp_mflags} make %{?_smp_mflags}
@ -34,6 +36,9 @@ make install PREFIX=%{_prefix} DESTDIR=%{buildroot}
%doc %{_mandir}/* %doc %{_mandir}/*
%changelog %changelog
* Fri Apr 26 2019 Antonio SJ Musumeci <trapexit@spawn.link>
- Update description
* Mon Jan 25 2016 Antonio SJ Musumeci <trapexit@spawn.link> * Mon Jan 25 2016 Antonio SJ Musumeci <trapexit@spawn.link>
- Remove sbin files - Remove sbin files

View File

@ -1,10 +1,5 @@
#!/bin/sh #!/bin/sh
GIT=$(which git)
if [ "${GIT}" = "" ]; then
exit 0
fi
VERSION=$(git describe --always --tags --dirty) VERSION=$(git describe --always --tags --dirty)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
VERSION=$(cat VERSION) VERSION=$(cat VERSION)