-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
37 lines (27 loc) · 784 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
CC = g++ -std=c++11
ALL_FLAGS = -c
CFLAGS = -Wall -Wextra -O4 -Os
TARGET = ccdump
OBJS_DIR = build
INCLUDE = -I./include
SOURCES = $(wildcard ./src/*.cpp)
OBJECTS = $(SOURCES:./src/%.cpp=./$(OBJS_DIR)/%.o)
HEADERS = $(wildcard ./include/*.h)
.PHONY: all
all: objs_dir $(TARGET)
.PHONY: objs_dir
objs_dir:
mkdir -p $(OBJS_DIR)
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
$(OBJS_DIR)/%.o: src/%.cpp
$(CC) $(ALL_FLAGS) $(VARS) $(CFLAGS) $(INCLUDE) $< -o $@
.PHONY: clean
clean:
rm -rfv $(TARGET) $(OBJS_DIR) 2>/dev/null || true
.PHONY: dep
dep: $(OBJS_DIR)/.depend
$(OBJS_DIR)/.depend: $(SOURCES)
mkdir -p $(OBJS_DIR)
$(CC) $(ALL_FLAGS) $(CFLAGS) $(INCLUDE) -MM $(SOURCES) | sed -e 's/.*:/$(OBJS_DIR)\/&/' > $(OBJS_DIR)/.depend
-include $(OBJS_DIR)/.depend