2016-01-15 05:50:22 +08:00
|
|
|
# Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
|
2014-05-13 00:41:46 +08:00
|
|
|
#
|
2016-01-15 05:50:22 +08:00
|
|
|
# Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
|
|
# copyright notice and this permission notice appear in all copies.
|
2014-05-13 00:41:46 +08:00
|
|
|
#
|
2016-01-15 05:50:22 +08:00
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
2018-11-29 09:03:22 +08:00
|
|
|
GIT = git
|
|
|
|
TAR = tar
|
|
|
|
MKDIR = mkdir
|
|
|
|
TOUCH = touch
|
|
|
|
CP = cp
|
|
|
|
RM = rm
|
|
|
|
LN = ln
|
|
|
|
FIND = find
|
|
|
|
INSTALL = install
|
|
|
|
MKTEMP = mktemp
|
|
|
|
STRIP = strip
|
|
|
|
PANDOC = pandoc
|
|
|
|
SED = sed
|
|
|
|
RPMBUILD = rpmbuild
|
|
|
|
GIT2DEBCL = ./tools/git2debcl
|
|
|
|
PKGCONFIG = pkg-config
|
2014-06-09 22:30:53 +08:00
|
|
|
|
2017-08-07 02:39:56 +08:00
|
|
|
GIT_REPO = 0
|
2018-11-29 09:03:22 +08:00
|
|
|
ifneq ($(shell $(GIT) --version 2> /dev/null),)
|
2017-08-07 02:39:56 +08:00
|
|
|
ifeq ($(shell test -e .git; echo $$?),0)
|
|
|
|
GIT_REPO = 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2018-10-09 23:58:06 +08:00
|
|
|
USE_XATTR = 1
|
2014-06-09 22:30:53 +08:00
|
|
|
|
2018-08-20 01:14:08 +08:00
|
|
|
FUSE_CFLAGS = -D_FILE_OFFSET_BITS=64 -Ilibfuse/include
|
2019-02-18 03:11:39 +08:00
|
|
|
FUSE_LIBS = libfuse/obj/libfuse.a
|
2018-08-20 01:14:08 +08:00
|
|
|
FUSE_TARGET = $(FUSE_LIBS)
|
|
|
|
|
2018-11-29 09:03:22 +08:00
|
|
|
ifeq ($(STATIC),1)
|
|
|
|
STATIC_FLAG := -static
|
|
|
|
else
|
|
|
|
STATIC_FLAG :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(LTO),1)
|
|
|
|
LTO_FLAG := -flto
|
|
|
|
else
|
|
|
|
LTO_FLAG :=
|
|
|
|
endif
|
|
|
|
|
2015-09-09 03:56:02 +08:00
|
|
|
UGID_USE_RWLOCK = 0
|
|
|
|
|
2018-11-29 09:03:22 +08:00
|
|
|
OPTS = -O2 -g
|
2014-11-05 02:42:20 +08:00
|
|
|
SRC = $(wildcard src/*.cpp)
|
|
|
|
OBJ = $(SRC:src/%.cpp=obj/%.o)
|
|
|
|
DEPS = $(OBJ:obj/%.o=obj/%.d)
|
|
|
|
TARGET = mergerfs
|
|
|
|
MANPAGE = $(TARGET).1
|
2018-11-29 09:03:22 +08:00
|
|
|
CXXFLAGS = $(OPTS) \
|
|
|
|
$(STATIC_FLAG) \
|
|
|
|
$(LTO_FLAG) \
|
|
|
|
-Wall \
|
2015-09-09 03:56:02 +08:00
|
|
|
-Wno-unused-result \
|
2014-11-05 02:42:20 +08:00
|
|
|
$(FUSE_CFLAGS) \
|
2016-08-05 02:02:59 +08:00
|
|
|
-DFUSE_USE_VERSION=29 \
|
2014-11-05 02:42:20 +08:00
|
|
|
-MMD \
|
2018-10-09 23:58:06 +08:00
|
|
|
-DUSE_XATTR=$(USE_XATTR) \
|
2015-09-09 03:56:02 +08:00
|
|
|
-DUGID_USE_RWLOCK=$(UGID_USE_RWLOCK)
|
2014-11-05 02:42:20 +08:00
|
|
|
|
2015-08-07 01:11:17 +08:00
|
|
|
PREFIX = /usr/local
|
|
|
|
EXEC_PREFIX = $(PREFIX)
|
|
|
|
DATAROOTDIR = $(PREFIX)/share
|
|
|
|
DATADIR = $(DATAROOTDIR)
|
|
|
|
BINDIR = $(EXEC_PREFIX)/bin
|
2015-09-30 06:55:30 +08:00
|
|
|
SBINDIR = $(EXEC_PREFIX)/sbin
|
2015-08-07 01:11:17 +08:00
|
|
|
MANDIR = $(DATAROOTDIR)/man
|
|
|
|
MAN1DIR = $(MANDIR)/man1
|
|
|
|
|
|
|
|
INSTALLBINDIR = $(DESTDIR)$(BINDIR)
|
2015-09-30 06:55:30 +08:00
|
|
|
INSTALLSBINDIR = $(DESTDIR)$(SBINDIR)
|
2015-08-07 01:11:17 +08:00
|
|
|
INSTALLMAN1DIR = $(DESTDIR)$(MAN1DIR)
|
2014-05-13 00:41:46 +08:00
|
|
|
|
2016-01-22 03:48:12 +08:00
|
|
|
all: $(TARGET)
|
2014-05-13 00:41:46 +08:00
|
|
|
|
|
|
|
help:
|
2018-11-29 09:03:22 +08:00
|
|
|
@echo "usage: make\n"
|
2018-10-09 23:58:06 +08:00
|
|
|
@echo "make USE_XATTR=0 - build program without xattrs functionality"
|
2018-11-29 09:03:22 +08:00
|
|
|
@echo "make STATIC=1 - build static binary"
|
|
|
|
@echo "make LTO=1 - build with link time optimization"
|
2014-05-13 00:41:46 +08:00
|
|
|
|
2018-08-20 01:14:08 +08:00
|
|
|
$(TARGET): version obj/obj-stamp $(FUSE_TARGET) $(OBJ)
|
2018-11-29 09:03:22 +08:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJ) -o $@ $(FUSE_LIBS) -ldl -pthread -lrt
|
2014-05-13 00:41:46 +08:00
|
|
|
|
2015-10-13 11:43:17 +08:00
|
|
|
mount.mergerfs: $(TARGET)
|
|
|
|
$(LN) -fs "$<" "$@"
|
|
|
|
|
2014-05-29 19:23:46 +08:00
|
|
|
changelog:
|
2017-08-07 02:39:56 +08:00
|
|
|
ifeq ($(GIT_REPO),1)
|
2015-08-07 01:11:17 +08:00
|
|
|
$(GIT2DEBCL) --name $(TARGET) > ChangeLog
|
2018-11-29 09:03:22 +08:00
|
|
|
else
|
|
|
|
@echo "WARNING: need git repo to generate ChangeLog"
|
2017-08-07 02:39:56 +08:00
|
|
|
endif
|
2015-08-07 01:11:17 +08:00
|
|
|
|
|
|
|
authors:
|
2017-08-07 02:39:56 +08:00
|
|
|
ifeq ($(GIT_REPO),1)
|
2015-08-07 01:11:17 +08:00
|
|
|
$(GIT) log --format='%aN <%aE>' | sort -f | uniq > AUTHORS
|
2018-11-29 09:03:22 +08:00
|
|
|
else
|
|
|
|
@echo "WARNING: need git repo to generate AUTHORS"
|
2017-08-07 02:39:56 +08:00
|
|
|
endif
|
2014-05-29 19:23:46 +08:00
|
|
|
|
2017-08-07 02:39:56 +08:00
|
|
|
version:
|
2018-03-10 09:48:36 +08:00
|
|
|
tools/update-version
|
2015-09-06 09:48:15 +08:00
|
|
|
|
2014-05-13 00:41:46 +08:00
|
|
|
obj/obj-stamp:
|
2014-05-29 19:23:46 +08:00
|
|
|
$(MKDIR) -p obj
|
|
|
|
$(TOUCH) $@
|
2014-05-13 00:41:46 +08:00
|
|
|
|
|
|
|
obj/%.o: src/%.cpp
|
2018-11-29 09:03:22 +08:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
|
2014-05-13 00:41:46 +08:00
|
|
|
|
2019-02-18 03:11:39 +08:00
|
|
|
clean: rpm-clean
|
2015-09-06 10:29:28 +08:00
|
|
|
$(RM) -f src/version.hpp
|
2016-12-15 10:42:43 +08:00
|
|
|
$(RM) -rf obj
|
2016-03-11 07:42:32 +08:00
|
|
|
$(RM) -f "$(TARGET)" mount.mergerfs
|
2015-08-07 01:11:17 +08:00
|
|
|
$(FIND) . -name "*~" -delete
|
2016-10-05 21:33:37 +08:00
|
|
|
cd libfuse && $(MAKE) clean
|
2014-05-29 19:23:46 +08:00
|
|
|
|
2019-02-18 03:11:39 +08:00
|
|
|
distclean: clean
|
2018-11-29 09:03:22 +08:00
|
|
|
ifeq ($(GIT_REPO),1)
|
|
|
|
$(GIT) clean -xfd
|
|
|
|
endif
|
|
|
|
|
2016-01-22 03:48:12 +08:00
|
|
|
install: install-base install-mount.mergerfs install-man
|
2015-01-28 07:25:20 +08:00
|
|
|
|
|
|
|
install-base: $(TARGET)
|
2016-10-25 05:26:45 +08:00
|
|
|
$(MKDIR) -p "$(INSTALLBINDIR)"
|
|
|
|
$(INSTALL) -v -m 0755 "$(TARGET)" "$(INSTALLBINDIR)/$(TARGET)"
|
2015-01-28 07:25:20 +08:00
|
|
|
|
2015-10-13 11:43:17 +08:00
|
|
|
install-mount.mergerfs: mount.mergerfs
|
|
|
|
$(MKDIR) -p "$(INSTALLBINDIR)"
|
|
|
|
$(CP) -a "$<" "$(INSTALLBINDIR)/$<"
|
2015-01-28 07:25:20 +08:00
|
|
|
|
|
|
|
install-man: $(MANPAGE)
|
2016-10-25 05:26:45 +08:00
|
|
|
$(MKDIR) -p "$(INSTALLMAN1DIR)"
|
|
|
|
$(INSTALL) -v -m 0644 "man/$(MANPAGE)" "$(INSTALLMAN1DIR)/$(MANPAGE)"
|
2015-01-28 07:25:20 +08:00
|
|
|
|
|
|
|
install-strip: install-base
|
|
|
|
$(STRIP) "$(INSTALLBINDIR)/$(TARGET)"
|
|
|
|
|
2016-01-22 03:48:12 +08:00
|
|
|
uninstall: uninstall-base uninstall-mount.mergerfs uninstall-man
|
2015-01-28 07:25:20 +08:00
|
|
|
|
|
|
|
uninstall-base:
|
|
|
|
$(RM) -f "$(INSTALLBINDIR)/$(TARGET)"
|
2014-05-29 19:23:46 +08:00
|
|
|
|
2016-01-22 03:48:12 +08:00
|
|
|
uninstall-mount.mergerfs:
|
|
|
|
$(RM) -f "$(INSTALLBINDIR)/mount.mergerfs"
|
2014-05-29 19:23:46 +08:00
|
|
|
|
2015-01-28 07:25:20 +08:00
|
|
|
uninstall-man:
|
2015-08-07 01:11:17 +08:00
|
|
|
$(RM) -f "$(INSTALLMAN1DIR)/$(MANPAGE)"
|
2014-06-09 22:30:53 +08:00
|
|
|
|
|
|
|
$(MANPAGE): README.md
|
2018-11-29 09:03:22 +08:00
|
|
|
ifneq ($(shell $(PANDOC) --version 2> /dev/null),)
|
2016-03-11 07:42:32 +08:00
|
|
|
$(PANDOC) -s -t man -o "man/$(MANPAGE)" README.md
|
2018-11-29 09:03:22 +08:00
|
|
|
else
|
|
|
|
$(warning "pandoc does not appear available: unable to build manpage")
|
2015-10-17 06:50:51 +08:00
|
|
|
endif
|
2014-06-09 22:30:53 +08:00
|
|
|
|
|
|
|
man: $(MANPAGE)
|
2014-05-29 19:23:46 +08:00
|
|
|
|
2018-11-29 09:03:22 +08:00
|
|
|
tarball: superclean man changelog authors version
|
2017-08-07 02:39:56 +08:00
|
|
|
$(eval VERSION := $(shell cat VERSION))
|
2015-09-06 05:56:45 +08:00
|
|
|
$(eval VERSION := $(subst -,_,$(VERSION)))
|
2014-05-29 19:23:46 +08:00
|
|
|
$(eval FILENAME := $(TARGET)-$(VERSION))
|
|
|
|
$(eval TMPDIR := $(shell $(MKTEMP) --tmpdir -d .$(FILENAME).XXXXXXXX))
|
|
|
|
$(MKDIR) $(TMPDIR)/$(FILENAME)
|
|
|
|
$(CP) -ar . $(TMPDIR)/$(FILENAME)
|
2015-09-06 05:56:45 +08:00
|
|
|
$(TAR) --exclude=.git -cz -C $(TMPDIR) -f $(FILENAME).tar.gz $(FILENAME)
|
2014-05-29 19:23:46 +08:00
|
|
|
$(RM) -rf $(TMPDIR)
|
|
|
|
|
2015-08-07 01:11:17 +08:00
|
|
|
debian-changelog:
|
2017-08-07 02:39:56 +08:00
|
|
|
ifeq ($(GIT_REPO),1)
|
2015-08-07 01:11:17 +08:00
|
|
|
$(GIT2DEBCL) --name $(TARGET) > debian/changelog
|
2017-08-07 02:39:56 +08:00
|
|
|
else
|
|
|
|
cp ChangeLog debian/changelog
|
|
|
|
endif
|
2015-08-07 01:11:17 +08:00
|
|
|
|
2015-09-27 02:12:10 +08:00
|
|
|
signed-deb: debian-changelog
|
2015-08-07 01:11:17 +08:00
|
|
|
dpkg-buildpackage
|
|
|
|
|
2015-09-27 02:12:10 +08:00
|
|
|
deb: debian-changelog
|
2015-08-07 01:11:17 +08:00
|
|
|
dpkg-buildpackage -uc -us
|
2014-05-13 00:41:46 +08:00
|
|
|
|
2015-09-06 05:56:45 +08:00
|
|
|
rpm-clean:
|
|
|
|
$(RM) -rf rpmbuild
|
|
|
|
|
|
|
|
rpm: tarball
|
2017-08-07 02:39:56 +08:00
|
|
|
$(eval VERSION := $(shell cat VERSION))
|
2015-09-06 05:56:45 +08:00
|
|
|
$(eval VERSION := $(subst -,_,$(VERSION)))
|
2015-12-15 12:50:02 +08:00
|
|
|
$(MKDIR) -p rpmbuild/BUILD rpmbuild/RPMS rpmbuild/SOURCES
|
2015-09-06 05:56:45 +08:00
|
|
|
$(SED) 's/__VERSION__/$(VERSION)/g' $(TARGET).spec > \
|
|
|
|
rpmbuild/SOURCES/$(TARGET).spec
|
|
|
|
cp -ar $(TARGET)-$(VERSION).tar.gz rpmbuild/SOURCES
|
|
|
|
$(RPMBUILD) -ba rpmbuild/SOURCES/$(TARGET).spec \
|
|
|
|
--define "_topdir $(CURDIR)/rpmbuild"
|
|
|
|
|
2016-10-05 21:33:37 +08:00
|
|
|
install-build-pkgs:
|
2018-11-29 09:03:22 +08:00
|
|
|
tools/install-build-pkgs
|
2016-10-05 21:33:37 +08:00
|
|
|
|
2018-08-12 12:24:39 +08:00
|
|
|
unexport CFLAGS
|
2019-02-18 03:11:39 +08:00
|
|
|
libfuse/obj/libfuse.a:
|
|
|
|
cd libfuse && $(MAKE) libfuse.a
|
2016-10-05 21:33:37 +08:00
|
|
|
|
2018-03-10 09:48:36 +08:00
|
|
|
.PHONY: all clean install help version
|
2014-05-13 00:41:46 +08:00
|
|
|
|
2016-10-05 21:33:37 +08:00
|
|
|
-include $(DEPS)
|