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.

145 lines
4.1 KiB

11 years ago
11 years ago
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. OPTS = -O2
  49. SRC = $(wildcard src/*.cpp)
  50. OBJ = $(SRC:src/%.cpp=obj/%.o)
  51. DEPS = $(OBJ:obj/%.o=obj/%.d)
  52. TARGET = mergerfs
  53. MANPAGE = $(TARGET).1
  54. CFLAGS = -g -Wall \
  55. $(OPTS) \
  56. $(shell $(PKGCONFIG) fuse --cflags) \
  57. -DFUSE_USE_VERSION=26 \
  58. -MMD
  59. LDFLAGS = $(shell $(PKGCONFIG) fuse --libs)
  60. BINDIR = $(PREFIX)/usr/bin
  61. MANDIR = $(PREFIX)/usr/share/man/man1
  62. INSTALLTARGET = $(DESTDIR)/$(BINDIR)/$(TARGET)
  63. MANTARGET = $(DESTDIR)/$(MANDIR)/$(MANPAGE)
  64. ifeq ($(XATTR_AVAILABLE),0)
  65. $(warning "xattr not available: disabling")
  66. CFLAGS += -DWITHOUT_XATTR
  67. endif
  68. KERNEL = $(shell uname -s)
  69. ifeq ($(KERNEL),Linux)
  70. CFLAGS += -DLINUX
  71. endif
  72. ifeq ($(KERNEL),Darwin)
  73. CFLAGS += -DOSX
  74. endif
  75. all: $(TARGET)
  76. help:
  77. @echo "usage: make"
  78. @echo "make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)"
  79. $(TARGET): obj/obj-stamp $(OBJ)
  80. $(CXX) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
  81. changelog:
  82. $(GIT) log --pretty --numstat --summary | git2cl > ChangeLog
  83. obj/obj-stamp:
  84. $(MKDIR) -p obj
  85. $(TOUCH) $@
  86. obj/%.o: src/%.cpp
  87. $(CXX) $(CFLAGS) -c $< -o $@
  88. clean:
  89. $(RM) -rf obj "$(TARGET)" "$(MANPAGE)"
  90. $(FIND) -name "*~" -delete
  91. distclean: clean
  92. $(GIT) clean -ifd
  93. install: $(TARGET) $(MANPAGE)
  94. $(INSTALL) -m 0755 -D "$(TARGET)" "$(INSTALLTARGET)"
  95. $(INSTALL) -m 0644 -D "$(MANPAGE)" "$(MANTARGET)"
  96. install-strip: install
  97. $(STRIP) "$(INSTALLTARGET)"
  98. uninstall:
  99. $(RM) "$(INSTALLTARGET)"
  100. $(RM) "$(MANTARGET)"
  101. $(MANPAGE): README.md
  102. $(PANDOC) -s -t man -o $(MANPAGE) README.md
  103. man: $(MANPAGE)
  104. tarball: clean changelog man
  105. $(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
  106. $(eval FILENAME := $(TARGET)-$(VERSION))
  107. $(eval TMPDIR := $(shell $(MKTEMP) --tmpdir -d .$(FILENAME).XXXXXXXX))
  108. $(MKDIR) $(TMPDIR)/$(FILENAME)
  109. $(CP) -ar . $(TMPDIR)/$(FILENAME)
  110. $(TAR) --exclude=.git -cz -C $(TMPDIR) -f ../$(FILENAME).tar.gz $(FILENAME)
  111. $(RM) -rf $(TMPDIR)
  112. deb:
  113. $(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
  114. $(GIT) dch --auto --release --new-version="$(VERSION)"
  115. $(GIT) buildpackage --git-ignore-new
  116. .PHONY: all clean install help
  117. include $(wildcard obj/*.d)