-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
56 lines (41 loc) · 1.03 KB
/
makefile
File metadata and controls
56 lines (41 loc) · 1.03 KB
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
56
TARGET = garbageboy
BUILD_DIR = build
DEBUG = 1
OPT = -O2
CC = g++ -std=c++11
CP = objcopy
SZ = size
CPP_SOURCES = $(wildcard src/*.cpp)
CPP_INCLUDES = -I ./inc
CPP_INCLUDES += -I /opt/homebrew/include
CPP_FLAGS = $(CPP_INCLUDES) $(OPT) -Wall -MMD -MP -MF"$(@:%.o=%.d)"
LD_FLAGS = -l boost_program_options -l SDL2
LD_FLAGS += -L /opt/homebrew/opt/boost/lib -L /opt/homebrew/opt/sdl2/lib
ifeq ($(DEBUG), 1)
CPP_FLAGS += -ggdb
endif
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
all: $(BUILD_DIR)/$(TARGET)
.PHONY: run
run: all
@echo "running $(BUILD_DIR)/$(TARGET)..."
@echo ""
@./build/$(TARGET)
.PHONY: test_cpu
test_cpu: all
@python3 ./run_tests.py
$(BUILD_DIR)/%.o: %.cpp | $(BUILD_DIR)
$(CC) -c $(CPP_FLAGS) $< -o $@
$(BUILD_DIR)/$(TARGET): $(OBJECTS)
@echo ""
$(CC) $(OBJECTS) $(LD_FLAGS) -o $@
@echo ""
@$(SZ) $@
@echo ""
$(BUILD_DIR):
mkdir $@
@echo ""
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)