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.

123 lines
2.6 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 = \
  29. lib/buffer.c \
  30. lib/crc32b.c \
  31. lib/debug.c \
  32. lib/fuse.c \
  33. lib/fuse_dirents.c \
  34. lib/fuse_kern_chan.c \
  35. lib/fuse_loop_mt.c \
  36. lib/fuse_lowlevel.c \
  37. lib/fuse_mt.c \
  38. lib/fuse_node.c \
  39. lib/fuse_opt.c \
  40. lib/fuse_session.c \
  41. lib/fuse_signals.c \
  42. lib/helper.c \
  43. lib/mount.c
  44. OBJS = $(SRC:lib/%.c=build/%.o)
  45. DEPS = $(SRC:lib/%.c=build/%.d)
  46. CFLAGS ?= \
  47. $(OPT_FLAGS)
  48. CFLAGS := \
  49. ${CFLAGS} \
  50. -std=gnu99 \
  51. -Wall \
  52. -pipe \
  53. -MMD
  54. FUSERMOUNT_DIR = $(BINDIR)
  55. FUSE_FLAGS = \
  56. -Iinclude \
  57. -Ibuild \
  58. -D_REENTRANT \
  59. -D_FILE_OFFSET_BITS=64 \
  60. -DFUSE_USE_VERSION=29 \
  61. -DPACKAGE_VERSION=\"$(VERSION)\" \
  62. -DFUSERMOUNT_DIR=\"$(FUSERMOUNT_DIR)\"
  63. LDFLAGS := \
  64. ${LDFLAGS} \
  65. -lrt \
  66. -pthread
  67. all: build/libfuse.a $(UTILS)
  68. build/config.h: build/stamp
  69. ecfd/build | tee build/config.h
  70. build/stamp:
  71. mkdir -p build
  72. touch $@
  73. objects: build/config.h
  74. $(MAKE) $(OBJS)
  75. build/libfuse.a: objects
  76. ${AR} rcs build/libfuse.a $(OBJS)
  77. utils: mergerfs-fusermount mount.mergerfs
  78. build/mergerfs-fusermount: build/config.h util/fusermount.c lib/mount_util.c
  79. $(CC) $(CFLAGS) $(FUSE_FLAGS) -Ilib -o build/mergerfs-fusermount util/fusermount.c lib/mount_util.c
  80. mergerfs-fusermount: build/mergerfs-fusermount
  81. build/mount.mergerfs: build/libfuse.a util/mount.mergerfs.c
  82. $(CC) $(CFLAGS) $(FUSE_FLAGS) -o build/mount.mergerfs util/mount.mergerfs.c build/libfuse.a $(LDFLAGS)
  83. mount.mergerfs: build/mount.mergerfs
  84. build/%.o: lib/%.c
  85. $(CC) $(CFLAGS) $(FUSE_FLAGS) -c $< -o $@
  86. clean:
  87. rm -rf build
  88. distclean: clean
  89. strip:
  90. strip --strip-all build/mount.mergerfs
  91. strip --strip-all build/mergerfs-fusermount
  92. install-utils: mergerfs-fusermount mount.mergerfs strip
  93. install -D build/mergerfs-fusermount "$(INSTALLBINDIR)/mergerfs-fusermount"
  94. install -D build/mount.mergerfs "$(INSTALLSBINDIR)/mount.mergerfs"
  95. chown root "$(INSTALLBINDIR)/mergerfs-fusermount"
  96. chmod u+s "$(INSTALLBINDIR)/mergerfs-fusermount"
  97. install: $(INSTALLUTILS)
  98. .PHONY: objects strip utils install install-utils
  99. -include $(DEPS)