-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (43 loc) · 1.77 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
CXX = g++
CXXFLAGS = --std=c++2a -Wall -Wextra -O3
SOURCES_DIR = src
UNITTEST_DIR = unittest
BUILD_DIR = build
SOURCES = $(wildcard $(SOURCES_DIR)/*.cpp)
MAIN = $(SOURCES_DIR)/main.cpp
PLAYERS = $(wildcard $(SOURCES_DIR)/player/*.cpp)
UNITTESTS = $(wildcard $(UNITTEST_DIR)/*.cpp)
STATE_SOURCE = $(SOURCES_DIR)/state/state.cpp
POLICY_DIR = $(SOURCES_DIR)/policy
TARGET_PLAYER = $(PLAYERS:$(SOURCES_DIR)/player/%.cpp=%)
TARGET_MAIN = main
TARGET_OTHER = selfplay benchmark
TARGET_UNITTEST = $(UNITTESTS:$(UNITTEST_DIR)/%.cpp=%)
OTHER = action state gamelog.txt
.PHONY: all clean
all: |$(BUILD_DIR) $(TARGET_MAIN) $(TARGET_PLAYER) $(TARGET_UNITTEST)
player: |$(BUILD_DIR) $(TARGET_PLAYER)
# make build dir if it doesn't exist
$(BUILD_DIR):
mkdir "$(BUILD_DIR)"
mkdir "$(UNITTEST_DIR)/build"
# build target
ifeq ($(OS), Windows_NT)
$(TARGET_PLAYER): % : $(SOURCES_DIR)/player/%.cpp
$(CXX) $(CXXFLAGS) -o $(BUILD_DIR)/player_$@.exe $(STATE_SOURCE) $(POLICY_DIR)/$@.cpp $<
$(TARGET_MAIN): % : $(SOURCES_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -o $(BUILD_DIR)/$@.exe $<
$(TARGET_OTHER): %: $(SOURCES_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -o $(BUILD_DIR)/$@.exe $(STATE_SOURCE) $(POLICY_DIR)/*.cpp $<
$(TARGET_UNITTEST): %: $(UNITTEST_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -o $(UNITTEST_DIR)/build/$@.exe $(STATE_SOURCE) $(POLICY_DIR)/*.cpp $<
else
$(TARGET_PLAYER): % : $(SOURCES_DIR)/player/%.cpp
$(CXX) $(CXXFLAGS) -o $(BUILD_DIR)/player_$@ $(STATE_SOURCE) $(POLICY_DIR)/$@.cpp $<
$(TARGET_MAIN): % : $(SOURCES_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -o $(BUILD_DIR)/$@ $<
$(TARGET_OTHER): %: $(SOURCES_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -o $(BUILD_DIR)/$@ $(STATE_SOURCE) $(POLICY_DIR)/*.cpp $<
$(TARGET_UNITTEST): %: $(UNITTEST_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -o $(UNITTEST_DIR)/build/$@ $(STATE_SOURCE) $(POLICY_DIR)/*.cpp $<
endif