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.

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