-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (32 loc) · 1 KB
/
Makefile
File metadata and controls
41 lines (32 loc) · 1 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
# Compiler settings
CXX ?= g++
CXXFLAGS := -std=c++14 -O3 -g -Wall -Wextra -Werror -pedantic -Wshadow -Wunreachable-code -fstack-protector-all
# Directories
SRC := src
OBJ := obj
BINDIR := bin
BOARDS := boards
# Targets and files
BIN := $(BINDIR)/xDama
SRCS := $(wildcard $(SRC)/*.cpp)
OBJS := $(patsubst $(SRC)/%.cpp, $(OBJ)/%.o, $(SRCS))
.PHONY: all clean run valgrind
# Default target just builds the binary
all: $(BIN)
# Link the binary (and create bin/ and boards/ dirs if missing)
$(BIN): $(OBJS)
@mkdir -p $(BINDIR) $(BOARDS)
$(CXX) $(CXXFLAGS) $^ -o $@
# Compile objects (and create obj/ dir if missing)
$(OBJ)/%.o: $(SRC)/%.cpp
@mkdir -p $(OBJ)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Run the compiled program
run: $(BIN)
./$(BIN) 1
# Run with memory checks
valgrind: $(BIN)
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --log-file=valgrind-out.txt ./$(BIN) 1
# Clean everything generated by make
clean:
rm -rf $(OBJ) $(BINDIR) $(BOARDS) valgrind-out.txt