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.

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