You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.5 KiB

11 years ago
11 years ago
11 years ago
11 years ago
  1. # The MIT License (MIT)
  2. #
  3. # Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. # THE SOFTWARE.
  22. XATTR_AVAILABLE = $(shell test ! -e /usr/include/attr/xattr.h; echo $$?)
  23. FUSE_AVAILABLE = $(shell ! pkg-config --exists fuse; echo $$?)
  24. ifeq ($(FUSE_AVAILABLE),0)
  25. FUSE_AVAILABLE = $(shell test ! -e /usr/include/fuse.h; echo $$?)
  26. endif
  27. ifeq ($(FUSE_AVAILABLE),0)
  28. $(error "FUSE development package doesn't appear available")
  29. endif
  30. PKGCONFIG = $(shell which pkg-config)
  31. GIT = $(shell which git)
  32. TAR = $(shell which tar)
  33. MKDIR = $(shell which mkdir)
  34. TOUCH = $(shell which touch)
  35. CP = $(shell which cp)
  36. RM = $(shell which rm)
  37. FIND = $(shell which find)
  38. INSTALL = $(shell which install)
  39. MKTEMP = $(shell which mktemp)
  40. STRIP = $(shell which strip)
  41. SRC = $(wildcard src/*.cpp)
  42. OBJ = $(SRC:src/%.cpp=obj/%.o)
  43. DEPS = $(OBJ:obj/%.o=obj/%.d)
  44. TARGET = mergerfs
  45. CFLAGS = -g -Wall \
  46. $(shell $(PKGCONFIG) fuse --cflags) \
  47. -DFUSE_USE_VERSION=26 \
  48. -MMD
  49. LDFLAGS = $(shell $(PKGCONFIG) fuse --libs)
  50. BINDIR = $(PREFIX)/usr/bin
  51. MANDIR = $(PREFIX)/share/man/man1
  52. INSTALLPATH = $(DESTDIR)/$(BINDIR)
  53. INSTALLTARGET = $(INSTALLPATH)/$(TARGET)
  54. ifeq ($(XATTR_AVAILABLE),0)
  55. CFLAGS += -DWITHOUT_XATTR
  56. endif
  57. all: $(TARGET)
  58. help:
  59. @echo "usage: make"
  60. @echo "make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)"
  61. $(TARGET): obj/obj-stamp $(OBJ)
  62. $(CXX) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
  63. changelog:
  64. $(GIT) log --pretty --numstat --summary | git2cl > ChangeLog
  65. obj/obj-stamp:
  66. $(MKDIR) -p obj
  67. $(TOUCH) $@
  68. obj/%.o: src/%.cpp
  69. $(CXX) $(CFLAGS) -c $< -o $@
  70. clean:
  71. $(RM) -rf obj "$(TARGET)"
  72. $(FIND) -name "*~" -delete
  73. distclean: clean
  74. $(GIT) clean -ifd
  75. install: $(TARGET)
  76. $(INSTALL) -m 0755 -D "$(TARGET)" "$(INSTALLTARGET)"
  77. install-strip: install
  78. $(STRIP) "$(INSTALLTARGET)"
  79. uninstall:
  80. $(RM) "$(INSTALLTARGET)"
  81. tarball: distclean changelog
  82. $(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
  83. $(eval FILENAME := $(TARGET)-$(VERSION))
  84. $(eval TMPDIR := $(shell $(MKTEMP) --tmpdir -d .$(FILENAME).XXXXXXXX))
  85. $(MKDIR) $(TMPDIR)/$(FILENAME)
  86. $(CP) -ar . $(TMPDIR)/$(FILENAME)
  87. $(TAR) --exclude=.git -cz -C $(TMPDIR) -f ../$(FILENAME).tar.gz $(FILENAME)
  88. $(RM) -rf $(TMPDIR)
  89. deb:
  90. $(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
  91. $(GIT) dch --auto --release --new-version="$(VERSION)"
  92. $(GIT) buildpackage --git-ignore-new
  93. .PHONY: all clean install help
  94. include $(wildcard obj/*.d)