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.

135 lines
4.0 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. PKGCONFIG = $(shell which pkg-config)
  23. GIT = $(shell which git)
  24. TAR = $(shell which tar)
  25. MKDIR = $(shell which mkdir)
  26. TOUCH = $(shell which touch)
  27. CP = $(shell which cp)
  28. RM = $(shell which rm)
  29. FIND = $(shell which find)
  30. INSTALL = $(shell which install)
  31. MKTEMP = $(shell which mktemp)
  32. STRIP = $(shell which strip)
  33. PANDOC = $(shell which pandoc)
  34. ifeq ($(PKGCONFIG),"")
  35. $(error "pkg-config not installed"
  36. endif
  37. ifeq ($(PANDOC),"")
  38. $(warning "pandoc does not appear available: manpage won't be buildable")
  39. endif
  40. XATTR_AVAILABLE = $(shell test ! -e /usr/include/attr/xattr.h; echo $$?)
  41. FUSE_AVAILABLE = $(shell ! pkg-config --exists fuse; echo $$?)
  42. ifeq ($(FUSE_AVAILABLE),0)
  43. FUSE_AVAILABLE = $(shell test ! -e /usr/include/fuse.h; echo $$?)
  44. endif
  45. ifeq ($(FUSE_AVAILABLE),0)
  46. $(error "FUSE development package doesn't appear available")
  47. endif
  48. SRC = $(wildcard src/*.cpp)
  49. OBJ = $(SRC:src/%.cpp=obj/%.o)
  50. DEPS = $(OBJ:obj/%.o=obj/%.d)
  51. TARGET = mergerfs
  52. MANPAGE = $(TARGET).1
  53. CFLAGS = -g -Wall \
  54. $(shell $(PKGCONFIG) fuse --cflags) \
  55. -DFUSE_USE_VERSION=26 \
  56. -MMD
  57. LDFLAGS = $(shell $(PKGCONFIG) fuse --libs)
  58. BINDIR = $(PREFIX)/usr/bin
  59. MANDIR = $(PREFIX)/usr/share/man/man1
  60. INSTALLTARGET = $(DESTDIR)/$(BINDIR)/$(TARGET)
  61. MANTARGET = $(DESTDIR)/$(MANDIR)/$(MANPAGE)
  62. ifeq ($(XATTR_AVAILABLE),0)
  63. $(warning "xattr not available: disabling")
  64. CFLAGS += -DWITHOUT_XATTR
  65. endif
  66. all: $(TARGET)
  67. help:
  68. @echo "usage: make"
  69. @echo "make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)"
  70. $(TARGET): obj/obj-stamp $(OBJ)
  71. $(CXX) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
  72. changelog:
  73. $(GIT) log --pretty --numstat --summary | git2cl > ChangeLog
  74. obj/obj-stamp:
  75. $(MKDIR) -p obj
  76. $(TOUCH) $@
  77. obj/%.o: src/%.cpp
  78. $(CXX) $(CFLAGS) -c $< -o $@
  79. clean:
  80. $(RM) -rf obj "$(TARGET)" "$(MANPAGE)"
  81. $(FIND) -name "*~" -delete
  82. distclean: clean
  83. $(GIT) clean -ifd
  84. install: $(TARGET) $(MANPAGE)
  85. $(INSTALL) -m 0755 -D "$(TARGET)" "$(INSTALLTARGET)"
  86. $(INSTALL) -m 0644 -D "$(MANPAGE)" "$(MANTARGET)"
  87. install-strip: install
  88. $(STRIP) "$(INSTALLTARGET)"
  89. uninstall:
  90. $(RM) "$(INSTALLTARGET)"
  91. $(RM) "$(MANTARGET)"
  92. $(MANPAGE): README.md
  93. $(PANDOC) -s -t man -o $(MANPAGE) README.md
  94. man: $(MANPAGE)
  95. tarball: clean changelog man
  96. $(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
  97. $(eval FILENAME := $(TARGET)-$(VERSION))
  98. $(eval TMPDIR := $(shell $(MKTEMP) --tmpdir -d .$(FILENAME).XXXXXXXX))
  99. $(MKDIR) $(TMPDIR)/$(FILENAME)
  100. $(CP) -ar . $(TMPDIR)/$(FILENAME)
  101. $(TAR) --exclude=.git -cz -C $(TMPDIR) -f ../$(FILENAME).tar.gz $(FILENAME)
  102. $(RM) -rf $(TMPDIR)
  103. deb:
  104. $(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
  105. $(GIT) dch --auto --release --new-version="$(VERSION)"
  106. $(GIT) buildpackage --git-ignore-new
  107. .PHONY: all clean install help
  108. include $(wildcard obj/*.d)