-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (56 loc) · 1.65 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
58
59
60
61
62
63
64
65
66
67
68
# Makefile template for compiling C++ projects.
#
# USAGE:
# make [target]
#
# TARGETS:
# release Release build
# debug Debug build
# clean Clean up the object files
#
# Author: Andrei Purcarus
# Configuration Settings
TARGET := agent.exe
CXXFLAGS := -std=c++1y -Wall -Wextra -pedantic -Isrc -pthread
LIBFLAGS :=
SRCS := main.cpp game/game.cpp game/state.cpp game/drawboard.cpp
DIRECTORIES := game game/heuristics search util
CXX_RELEASE := g++
CXXFLAGS_RELEASE := $(CXXFLAGS) -O3
CXX_DEBUG := g++
CXXFLAGS_DEBUG := $(CXXFLAGS) -g
BUILD_DIR := ./build
RELEASE_DIR := $(BUILD_DIR)/release
RELEASE_DIRS := $(DIRECTORIES:%=$(RELEASE_DIR)/%)
DEBUG_DIR := $(BUILD_DIR)/debug
DEBUG_DIRS := $(DIRECTORIES:%=$(DEBUG_DIR)/%)
SRC_DIR := ./src
OBJS_RELEASE := $(SRCS:%.cpp=$(RELEASE_DIR)/%.o)
DEPS_RELEASE := $(OBJS_RELEASE:.o=.d)
OBJS_DEBUG := $(SRCS:%.cpp=$(DEBUG_DIR)/%.o)
DEPS_DEBUG := $(OBJS_DEBUG:.o=.d)
all: release
cp $(RELEASE_DIR)/$(TARGET) $(TARGET)
.PHONY: release debug clean
release: $(RELEASE_DIR) $(RELEASE_DIRS) $(RELEASE_DIR)/$(TARGET)
debug: $(DEBUG_DIR) $(DEBUG_DIRS) $(DEBUG_DIR)/$(TARGET)
clean:
rm -rf $(BUILD_DIR) $(TARGET)
$(RELEASE_DIR):
mkdir -p $@
$(RELEASE_DIRS):
mkdir -p $@
$(RELEASE_DIR)/$(TARGET): $(OBJS_RELEASE)
$(CXX_RELEASE) $(CXXFLAGS_RELEASE) $^ -o $@ $(LIBFLAGS)
-include $(DEPS_RELEASE)
$(RELEASE_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX_RELEASE) $(CXXFLAGS_RELEASE) -MMD -c $< -o $@
$(DEBUG_DIR):
mkdir -p $@
$(DEBUG_DIRS):
mkdir -p $@
$(DEBUG_DIR)/$(TARGET): $(OBJS_DEBUG)
$(CXX_DEBUG) $(CXXFLAGS_DEBUG) $^ -o $@ $(LIBFLAGS)
-include $(DEPS_DEBUG)
$(DEBUG_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX_DEBUG) $(CXXFLAGS_DEBUG) -MMD -c $< -o $@