mergerfs/Makefile

248 lines
6.9 KiB
Makefile
Raw Normal View History

# Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
2014-05-13 00:41:46 +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
#
# 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.
2014-11-05 02:42:20 +08:00
GIT = $(shell which git)
TAR = $(shell which tar)
MKDIR = $(shell which mkdir)
TOUCH = $(shell which touch)
CP = $(shell which cp)
RM = $(shell which rm)
2015-01-28 07:25:20 +08:00
LN = $(shell which ln)
2014-11-05 02:42:20 +08:00
FIND = $(shell which find)
INSTALL = $(shell which install)
MKTEMP = $(shell which mktemp)
STRIP = $(shell which strip)
PANDOC = $(shell which pandoc)
2015-09-06 05:56:45 +08:00
SED = $(shell which sed)
GZIP = $(shell which gzip)
RPMBUILD = $(shell which rpmbuild)
GIT2DEBCL = ./tools/git2debcl
PKGCONFIG = pkg-config
2017-08-07 02:39:56 +08:00
GIT_REPO = 0
ifneq ($(GIT),)
ifeq ($(shell test -e .git; echo $$?),0)
GIT_REPO = 1
endif
endif
ifeq ($(PANDOC),)
$(warning "pandoc does not appear available: manpage won't be buildable")
endif
XATTR_AVAILABLE = $(shell test ! -e /usr/include/attr/xattr.h; echo $$?)
INTERNAL_FUSE = 1
EXTERNAL_FUSE_MIN_REQ = 2.9.7
ifeq ($(INTERNAL_FUSE),1)
FUSE_CFLAGS = -D_FILE_OFFSET_BITS=64 -Ilibfuse/include
FUSE_LIBS = libfuse/lib/.libs/libfuse.a
FUSE_TARGET = $(FUSE_LIBS)
else
FUSE_CFLAGS := $(shell $(PKGCONFIG) --cflags 'fuse >= $(EXTERNAL_FUSE_MIN_REQ)')
FUSE_LIBS := $(shell $(PKGCONFIG) --libs 'fuse >= $(EXTERNAL_FUSE_MIN_REQ)')
FUSE_TARGET :=
ifeq ($(FUSE_CFLAGS)$(FUSE_LIBS),)
$(error "Use of external FUSE requested, but no libfuse >= $(EXTERNAL_FUSE_MIN_REQ) found.")
endif
endif
UGID_USE_RWLOCK = 0
2014-11-05 02:42:20 +08:00
OPTS = -O2
SRC = $(wildcard src/*.cpp)
OBJ = $(SRC:src/%.cpp=obj/%.o)
DEPS = $(OBJ:obj/%.o=obj/%.d)
TARGET = mergerfs
MANPAGE = $(TARGET).1
CFLAGS = -g -Wall \
$(OPTS) \
-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 \
-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
SBINDIR = $(EXEC_PREFIX)/sbin
2015-08-07 01:11:17 +08:00
MANDIR = $(DATAROOTDIR)/man
MAN1DIR = $(MANDIR)/man1
INSTALLBINDIR = $(DESTDIR)$(BINDIR)
INSTALLSBINDIR = $(DESTDIR)$(SBINDIR)
2015-08-07 01:11:17 +08:00
INSTALLMAN1DIR = $(DESTDIR)$(MAN1DIR)
2014-05-13 00:41:46 +08:00
2014-05-29 09:38:31 +08:00
ifeq ($(XATTR_AVAILABLE),0)
$(warning "xattr not available: disabling")
2014-05-29 09:38:31 +08:00
CFLAGS += -DWITHOUT_XATTR
2014-05-13 00:41:46 +08:00
endif
2016-01-22 03:48:12 +08:00
all: $(TARGET)
2014-05-13 00:41:46 +08:00
help:
2014-05-29 19:23:46 +08:00
@echo "usage: make"
@echo "make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)"
@echo "make INTERNAL_FUSE=0 - to build program with external (system) libfuse rather than the bundled one ('-o threads=' option will be unavailable)"
2014-05-13 00:41:46 +08:00
$(TARGET): version obj/obj-stamp $(FUSE_TARGET) $(OBJ)
$(CXX) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $@ $(FUSE_LIBS) -ldl -pthread -lrt
2014-05-13 00:41:46 +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
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
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
2014-05-29 09:38:31 +08:00
$(CXX) $(CFLAGS) -c $< -o $@
2014-05-13 00:41:46 +08:00
clean: rpm-clean libfuse_Makefile
2015-09-06 10:29:28 +08:00
$(RM) -f src/version.hpp
$(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
ifeq ($(INTERNAL_FUSE),1)
cd libfuse && $(MAKE) clean
endif
distclean: clean libfuse_Makefile
ifeq ($(INTERNAL_FUSE),1)
cd libfuse && $(MAKE) distclean
endif
2017-08-07 02:39:56 +08:00
ifeq ($(GIT_REPO),1)
$(GIT) clean -fd
2017-08-07 02:39:56 +08:00
endif
2014-05-29 19:23:46 +08:00
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
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)"
$(MANPAGE): README.md
2017-08-07 02:39:56 +08:00
ifneq ($(PANDOC),)
2016-03-11 07:42:32 +08:00
$(PANDOC) -s -t man -o "man/$(MANPAGE)" README.md
endif
man: $(MANPAGE)
2014-05-29 19:23:46 +08:00
2017-08-07 02:39:56 +08:00
tarball: distclean man changelog authors version
$(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
signed-deb: debian-changelog
2015-08-07 01:11:17 +08:00
dpkg-buildpackage
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)))
$(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"
install-build-pkgs:
ifeq ($(shell test -e /usr/bin/apt-get; echo $$?),0)
apt-get -qy update
apt-get -qy --no-install-suggests --no-install-recommends --force-yes \
install build-essential git g++ debhelper libattr1-dev python automake libtool lsb-release
else ifeq ($(shell test -e /usr/bin/dnf; echo $$?),0)
dnf -y update
dnf -y install git rpm-build libattr-devel gcc-c++ make which python automake libtool gettext-devel
else ifeq ($(shell test -e /usr/bin/yum; echo $$?),0)
yum -y update
yum -y install git rpm-build libattr-devel gcc-c++ make which python automake libtool gettext-devel
endif
unexport CFLAGS
.PHONY: libfuse_Makefile
libfuse_Makefile:
ifeq ($(INTERNAL_FUSE),1)
ifeq ($(shell test -e libfuse/Makefile; echo $$?),1)
cd libfuse && \
$(MKDIR) -p m4 && \
autoreconf --force --install && \
./configure --enable-lib --disable-util --disable-example
endif
endif
libfuse/lib/.libs/libfuse.a: libfuse_Makefile
cd libfuse && $(MAKE)
2018-03-10 09:48:36 +08:00
.PHONY: all clean install help version
2014-05-13 00:41:46 +08:00
-include $(DEPS)