-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
46 lines (36 loc) · 1016 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 指令编译器和选项
CC = g++
DEF = __KERNEL__ _FILE_OFFSET_BITS=64 HAVE_SETXATTR
LIBS = fuse3
INCLUDEDIR = -Iinclude
INCLUDEDIR += $(shell pkg-config --cflags $(LIBS))
OPTFLAGS = -Wall -Wextra -pthread
OBJ_DIR = obj
CXXFLAGS = -std=c++17 -pthread
CXXFLAGS += $(addprefix -D,$(DEF))
TARGET = rocksdb-fuse
LDFLAGS = $(shell pkg-config $(LIBS) --libs)
LDFLAGS += -lstdc++fs -lrocksdb
LDFLAGS += $(OPTFLAGS)
CC = g++
SHELL = bash
SOURCES = $(shell find -name "*.cpp" | sed 's/^\.\///g')
OBJS = $(addprefix $(OBJ_DIR)/,$(SOURCES:.cpp=.o))
.PHONY: all clean
sinclude $(DEPFILES)
all: $(TARGET)
$(OBJ_DIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@echo "[cc] $< ..."
@$(CC) -c $< -o $@ $(CXXFLAGS) $(INCLUDEDIR)
$(TARGET): $(OBJS)
@echo "Linking ..."
@$(CC) $(OBJS) -o $@ $(LDFLAGS)
@echo "done."
$(OBJ_DIR)/%.dep: %.cpp Makefile
@mkdir -p $(dir $@)
@echo "[dep] $< ..."
@$(CC) $(CXXFLAGS) -MM -MT "$(OBJ_DIR)/$(<:.cpp=.o) $(OBJ_DIR)/$(<:.cpp=.dep)" "$<" > "$@"
clean:
rm -rf ./$(TARGET) ./$(OBJ_DIR)