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.

137 lines
2.9 KiB

  1. VERSION = 2.9.7-mergerfs_2.30.0
  2. OS := $(shell uname -s)
  3. ifeq ($(OS),Linux)
  4. UTILS := utils
  5. INSTALLUTILS := install-utils
  6. else
  7. UTILS :=
  8. INSTALLUTILS :=
  9. endif
  10. ifeq ($(DEBUG),1)
  11. OPT_FLAGS := -O0 -g -fsanitize=undefined
  12. else
  13. OPT_FLAGS := -O2
  14. endif
  15. DESTDIR =
  16. PREFIX = /usr/local
  17. EXEC_PREFIX = $(PREFIX)
  18. DATAROOTDIR = $(PREFIX)/share
  19. DATADIR = $(DATAROOTDIR)
  20. BINDIR = $(EXEC_PREFIX)/bin
  21. SBINDIR = /sbin
  22. MANDIR = $(DATAROOTDIR)/man
  23. MAN1DIR = $(MANDIR)/man1
  24. INSTALLBINDIR = $(DESTDIR)$(BINDIR)
  25. INSTALLSBINDIR = $(DESTDIR)$(SBINDIR)
  26. INSTALLMAN1DIR = $(DESTDIR)$(MAN1DIR)
  27. AR ?= ar
  28. SRC_C = \
  29. lib/buffer.c \
  30. lib/crc32b.c \
  31. lib/debug.c \
  32. lib/fuse.c \
  33. lib/fuse_dirents.c \
  34. lib/fuse_lowlevel.c \
  35. lib/fuse_mt.c \
  36. lib/fuse_node.c \
  37. lib/fuse_opt.c \
  38. lib/fuse_session.c \
  39. lib/fuse_signals.c \
  40. lib/helper.c \
  41. lib/mount.c
  42. SRC_CPP = \
  43. lib/format.cpp \
  44. lib/os.cpp \
  45. lib/cpu.cpp \
  46. lib/fuse_loop_mt.cpp \
  47. lib/fuse_msgbuf.cpp
  48. OBJS_C = $(SRC_C:lib/%.c=build/%.o)
  49. OBJS_CPP = $(SRC_CPP:lib/%.cpp=build/%.o)
  50. DEPS_C = $(SRC_C:lib/%.c=build/%.d)
  51. DEPS_CPP = $(SRC_CPP:lib/%.cpp=build/%.d)
  52. CFLAGS ?= \
  53. $(OPT_FLAGS)
  54. CFLAGS := \
  55. ${CFLAGS} \
  56. -std=gnu99 \
  57. -Wall \
  58. -pipe \
  59. -MMD
  60. CXXFLAGS := \
  61. ${CXXFLAGS} \
  62. -std=c++11 \
  63. -Wall \
  64. -pipe \
  65. -MMD
  66. FUSERMOUNT_DIR = $(BINDIR)
  67. FUSE_FLAGS = \
  68. -Iinclude \
  69. -Ibuild \
  70. -D_REENTRANT \
  71. -D_FILE_OFFSET_BITS=64 \
  72. -DPACKAGE_VERSION=\"$(VERSION)\" \
  73. -DFUSERMOUNT_DIR=\"$(FUSERMOUNT_DIR)\"
  74. LDFLAGS := \
  75. ${LDFLAGS} \
  76. -lrt \
  77. -pthread
  78. all: build/libfuse.a $(UTILS)
  79. build/config.h: build/stamp
  80. ecfd/build | tee build/config.h
  81. build/stamp:
  82. mkdir -p build
  83. touch $@
  84. objects: build/config.h
  85. $(MAKE) $(OBJS_C) $(OBJS_CPP)
  86. build/libfuse.a: objects
  87. ${AR} rcs build/libfuse.a $(OBJS_C) $(OBJS_CPP)
  88. utils: mergerfs-fusermount mount.mergerfs
  89. build/mergerfs-fusermount: build/config.h util/fusermount.c lib/mount_util.c
  90. $(CC) $(CFLAGS) $(FUSE_FLAGS) -Ilib -o build/mergerfs-fusermount util/fusermount.c lib/mount_util.c
  91. mergerfs-fusermount: build/mergerfs-fusermount
  92. build/mount.mergerfs: build/libfuse.a util/mount.mergerfs.c
  93. $(CC) $(CFLAGS) $(FUSE_FLAGS) -o build/mount.mergerfs util/mount.mergerfs.c build/libfuse.a $(LDFLAGS)
  94. mount.mergerfs: build/mount.mergerfs
  95. build/%.o: lib/%.c
  96. $(CC) $(CFLAGS) $(FUSE_FLAGS) -c $< -o $@
  97. build/%.o: lib/%.cpp
  98. $(CXX) $(CXXFLAGS) $(FUSE_FLAGS) -c $< -o $@
  99. clean:
  100. rm -rf build
  101. distclean: clean
  102. strip:
  103. strip --strip-all build/mount.mergerfs
  104. strip --strip-all build/mergerfs-fusermount
  105. install-utils: mergerfs-fusermount mount.mergerfs strip
  106. install -D build/mergerfs-fusermount "$(INSTALLBINDIR)/mergerfs-fusermount"
  107. install -D build/mount.mergerfs "$(INSTALLSBINDIR)/mount.mergerfs"
  108. chown root "$(INSTALLBINDIR)/mergerfs-fusermount"
  109. chmod u+s "$(INSTALLBINDIR)/mergerfs-fusermount"
  110. install: $(INSTALLUTILS)
  111. .PHONY: objects strip utils install install-utils
  112. -include $(DEPS_C) $(DEPS_CPP)