-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (42 loc) · 1.24 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
56
57
CC := g++
CFLAGS := -Wall -std=c++11 -I/usr/include/SDL2
TEST_CFLAGS := -Wall -std=c++11 -I/usr/include/SDL2 -Isrc/
LDFLAGS := -lSDL2 -lSDL2_image
SRC_DIR := src
BUILD_DIR := build
BIN_DIR := bin
TEST_DIR := test
STABLE_DIR := stable
SRC := $(wildcard $(SRC_DIR)/*.cpp)
OBJ := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SRC))
EXE_NAME := game.chess
EXECUTABLE := $(BIN_DIR)/$(EXE_NAME)
STABLE_EXE := $(STABLE_DIR)/$(EXE_NAME)
TEST_SRC := $(wildcard $(TEST_DIR)/*.cpp)
TEST_OBJ := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(TEST_SRC))
TEST_EXECUTABLE := $(BIN_DIR)/test.runner
.PHONY: all clean run test ship stable unplug
all: clean $(EXECUTABLE)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
$(EXECUTABLE): $(OBJ)
$(CC) $^ -o $@ $(LDFLAGS)
test: $(TEST_EXECUTABLE)
./$(TEST_EXECUTABLE)
$(BUILD_DIR)/%.o: $(TEST_DIR)/%.cpp
@mkdir -p $(@D)
$(CC) $(TEST_CFLAGS) -c $< -o $@
$(TEST_EXECUTABLE): $(TEST_OBJ) $(filter-out $(BUILD_DIR)/main.o, $(OBJ))
$(CC) $^ -o $@ $(LDFLAGS)
clean:
rm -f $(BUILD_DIR)/*.o $(BIN_DIR)/*
run: $(EXECUTABLE)
./$(EXECUTABLE)
ship: $(EXECUTABLE)
@mkdir -p $(STABLE_DIR)
cp $(EXECUTABLE) $(STABLE_DIR)/
stable: $(STABLE_EXE)
./$(STABLE_EXE)
unplug:
rm -f $(STABLE_DIR)/*