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.

146 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. SRC_CPP = \
  48. lib/format.cpp \
  49. lib/os.cpp \
  50. lib/cpu.cpp \
  51. lib/fuse_config.cpp \
  52. lib/fuse_loop.cpp \
  53. lib/fuse_msgbuf.cpp
  54. OBJS_C = $(SRC_C:lib/%.c=build/%.o)
  55. OBJS_CPP = $(SRC_CPP:lib/%.cpp=build/%.o)
  56. DEPS_C = $(SRC_C:lib/%.c=build/%.d)
  57. DEPS_CPP = $(SRC_CPP:lib/%.cpp=build/%.d)
  58. CFLAGS ?= \
  59. $(OPT_FLAGS)
  60. CFLAGS := \
  61. ${CFLAGS} \
  62. $(LTO_FLAGS) \
  63. -std=gnu99 \
  64. -Wall \
  65. -pipe \
  66. -MMD
  67. CXXFLAGS := \
  68. ${CXXFLAGS} \
  69. $(LTO_FLAGS) \
  70. -std=c++11 \
  71. -Wall \
  72. -pipe \
  73. -MMD
  74. FUSERMOUNT_DIR = $(BINDIR)
  75. FUSE_FLAGS = \
  76. -Iinclude \
  77. -Ibuild \
  78. -D_REENTRANT \
  79. -D_FILE_OFFSET_BITS=64 \
  80. -DPACKAGE_VERSION=\"$(VERSION)\" \
  81. -DFUSERMOUNT_DIR=\"$(FUSERMOUNT_DIR)\"
  82. LDFLAGS := \
  83. ${LDFLAGS} \
  84. -lrt \
  85. -pthread
  86. all: build/libfuse.a $(UTILS)
  87. build/config.h: build/stamp
  88. ecfd/build | tee build/config.h
  89. build/stamp:
  90. mkdir -p build
  91. touch $@
  92. objects: build/config.h
  93. $(MAKE) $(OBJS_C) $(OBJS_CPP)
  94. build/libfuse.a: objects
  95. ${AR} rcs build/libfuse.a $(OBJS_C) $(OBJS_CPP)
  96. utils: mergerfs-fusermount mount.mergerfs
  97. build/mergerfs-fusermount: build/config.h util/fusermount.c lib/mount_util.c
  98. $(CC) $(CFLAGS) $(FUSE_FLAGS) -Ilib -o build/mergerfs-fusermount util/fusermount.c lib/mount_util.c
  99. mergerfs-fusermount: build/mergerfs-fusermount
  100. build/mount.mergerfs: build/libfuse.a util/mount.mergerfs.c
  101. $(CC) $(CFLAGS) $(FUSE_FLAGS) -o build/mount.mergerfs util/mount.mergerfs.c build/libfuse.a $(LDFLAGS)
  102. mount.mergerfs: build/mount.mergerfs
  103. build/%.o: lib/%.c
  104. $(CC) $(CFLAGS) $(FUSE_FLAGS) -c $< -o $@
  105. build/%.o: lib/%.cpp
  106. $(CXX) $(CXXFLAGS) $(FUSE_FLAGS) -c $< -o $@
  107. clean:
  108. rm -rf build
  109. distclean: clean
  110. strip:
  111. strip --strip-all build/mount.mergerfs
  112. strip --strip-all build/mergerfs-fusermount
  113. install-utils: mergerfs-fusermount mount.mergerfs strip
  114. install -D build/mergerfs-fusermount "$(INSTALLBINDIR)/mergerfs-fusermount"
  115. install -D build/mount.mergerfs "$(INSTALLSBINDIR)/mount.mergerfs"
  116. chown root "$(INSTALLBINDIR)/mergerfs-fusermount"
  117. chmod u+s "$(INSTALLBINDIR)/mergerfs-fusermount"
  118. install: $(INSTALLUTILS)
  119. .PHONY: objects strip utils install install-utils
  120. -include $(DEPS_C) $(DEPS_CPP)