Browse Source

rework makefiles for better manage parallel builds

pull/589/head
Antonio SJ Musumeci 6 years ago
parent
commit
1be9900733
  1. 23
      Makefile
  2. 24
      libfuse/Makefile

23
Makefile

@ -42,29 +42,36 @@ FUSE_CFLAGS = -D_FILE_OFFSET_BITS=64 -Ilibfuse/include
FUSE_LIBS = libfuse/obj/libfuse.a FUSE_LIBS = libfuse/obj/libfuse.a
FUSE_TARGET = $(FUSE_LIBS) FUSE_TARGET = $(FUSE_LIBS)
ifeq ($(DEBUG),1)
DEBUG_FLAGS := -g
else
DEBUG_FLAGS :=
endif
ifeq ($(STATIC),1) ifeq ($(STATIC),1)
STATIC_FLAG := -static
STATIC_FLAGS := -static
else else
STATIC_FLAG :=
STATIC_FLAGS :=
endif endif
ifeq ($(LTO),1) ifeq ($(LTO),1)
LTO_FLAG := -flto
LTO_FLAGS := -flto
else else
LTO_FLAG :=
LTO_FLAGS :=
endif endif
UGID_USE_RWLOCK = 0 UGID_USE_RWLOCK = 0
OPTS = -O2 -g
OPTS = -O2
SRC = $(wildcard src/*.cpp) SRC = $(wildcard src/*.cpp)
OBJ = $(SRC:src/%.cpp=obj/%.o) OBJ = $(SRC:src/%.cpp=obj/%.o)
DEPS = $(OBJ:obj/%.o=obj/%.d) DEPS = $(OBJ:obj/%.o=obj/%.d)
TARGET = mergerfs TARGET = mergerfs
MANPAGE = $(TARGET).1 MANPAGE = $(TARGET).1
CXXFLAGS = $(OPTS) \ CXXFLAGS = $(OPTS) \
$(STATIC_FLAG) \
$(LTO_FLAG) \
$(DEBUG_FLAGS) \
$(STATIC_FLAGS) \
$(LTO_FLAGS) \
-Wall \ -Wall \
-Wno-unused-result \ -Wno-unused-result \
$(FUSE_CFLAGS) \ $(FUSE_CFLAGS) \
@ -95,7 +102,7 @@ help:
@echo "make LTO=1 - build with link time optimization" @echo "make LTO=1 - build with link time optimization"
$(TARGET): version obj/obj-stamp $(FUSE_TARGET) $(OBJ) $(TARGET): version obj/obj-stamp $(FUSE_TARGET) $(OBJ)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJ) -o $@ $(FUSE_LIBS) -ldl -pthread -lrt
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJ) -o $@ $(FUSE_LIBS) -pthread -lrt
mount.mergerfs: $(TARGET) mount.mergerfs: $(TARGET)
$(LN) -fs "$<" "$@" $(LN) -fs "$<" "$@"

24
libfuse/Makefile

@ -1,6 +1,12 @@
VERSION = "2.9.7-mergerfs_2.26.0" VERSION = "2.9.7-mergerfs_2.26.0"
OPT = -O2 OPT = -O2
ifeq ($(DEBUG),1)
DEBUG_FLAGS := -g
else
DEBUG_FLAGS :=
endif
DESTDIR = "/" DESTDIR = "/"
BINDIR = "/bin" BINDIR = "/bin"
SBINDIR = "/sbin" SBINDIR = "/sbin"
@ -22,7 +28,7 @@ SRC = \
OBJ = $(SRC:lib/%.c=obj/%.o) OBJ = $(SRC:lib/%.c=obj/%.o)
DEPS = $(OBJ:obj/%.o=obj/%.d) DEPS = $(OBJ:obj/%.o=obj/%.d)
CFLAGS = $(OPT) \ CFLAGS = $(OPT) \
-g \
$(DEBUG_FLAGS) \
-Wall \ -Wall \
-pipe \ -pipe \
'-D_FILE_OFFSET_BITS=64' \ '-D_FILE_OFFSET_BITS=64' \
@ -33,18 +39,24 @@ CFLAGS = $(OPT) \
-Iinclude \ -Iinclude \
-MMD -MMD
LDFLAGS = \ LDFLAGS = \
-ldl \
-lrt \ -lrt \
-pthread -pthread
all: obj/libfuse.a mergerfs-mount mount.mergerfs
all: obj/libfuse.a
libfuse.a: obj/libfuse.a libfuse.a: obj/libfuse.a
include/config.h: include/config.h:
ecfd/build | tee include/config.h ecfd/build | tee include/config.h
obj/libfuse.a: obj/obj-stamp include/config.h $(OBJ)
obj/obj-stamp:
mkdir -p obj
touch $@
obj/libfuse.a:
$(MAKE) obj/obj-stamp
$(MAKE) include/config.h
$(MAKE) $(OBJ)
ar rcs obj/libfuse.a $(OBJ) ar rcs obj/libfuse.a $(OBJ)
mergerfs-mount: include/config.h util/fusermount.c lib/mount_util.c mergerfs-mount: include/config.h util/fusermount.c lib/mount_util.c
@ -53,10 +65,6 @@ mergerfs-mount: include/config.h util/fusermount.c lib/mount_util.c
mount.mergerfs: obj/libfuse.a util/mount.fuse.c mount.mergerfs: obj/libfuse.a util/mount.fuse.c
$(CC) $(CFLAGS) -o mount.mergerfs util/mount.fuse.c obj/libfuse.a $(LDFLAGS) $(CC) $(CFLAGS) -o mount.mergerfs util/mount.fuse.c obj/libfuse.a $(LDFLAGS)
obj/obj-stamp:
mkdir -p obj
touch $@
obj/%.o: lib/%.c obj/%.o: lib/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@

Loading…
Cancel
Save