-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (42 loc) · 1.34 KB
/
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
47
48
49
50
51
52
53
54
55
CXX ?= g++
CXXFLAGS ?= -std=c++17 -Wall -Wextra -pedantic -Iinclude -g
LDFLAGS ?= -lclang -lsqlite3
DEBUG_FLAG ?= -D_DEBUG_
RELEASE_FLAGS ?= -O2
TARGET = build/demo
SRC_DIR = src
OBJ_DIR = build/obj
INCLUDE_DIR = include
SRCS = $(wildcard $(SRC_DIR)/*.cc \
$(SRC_DIR)/interface/*.cc \
$(SRC_DIR)/util/*.cc \
$(SRC_DIR)/db/*.cc \
$(SRC_DIR)/core/*.cc \
$(SRC_DIR)/core/processor/*.cc \
$(SRC_DIR)/model/*/*.cc)
OBJS = $(patsubst $(SRC_DIR)/%.cc, $(OBJ_DIR)/%.o, $(SRCS))
all: $(TARGET)
$(TARGET): $(OBJS)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cc
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
-include $(OBJS:.o=.d)
debug: CXXFLAGS += $(DEBUG_FLAG)
debug: all
release: CXXFLAGS += $(RELEASE_FLAGS)
release: all
clean:
rm -rf $(OBJ_DIR) $(TARGET)
run: CXXFLAGS += $(DEBUG_FLAG)
run: $(TARGET)
./$(TARGET) -c config.example.toml -s tests/slight-case.cc -o tests/ast.db
help:
@echo "Usage:"
@echo " make # Build"
@echo " make debug # Build with debug flags"
@echo " make release # Build with release flags"
@echo " make run # Build and run to show testing output"
@echo " make clean # Clean up all build files"
.PHONY: all clean help run debug release