-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (36 loc) · 978 Bytes
/
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
CC = g++
CFLAGS = -Wall -I$(IDIR) -std=c++14 -O3
IDIR = include
LDIR = lib
ODIR = obj
SRCDIR = src
TESTDIR = tests
BINDIR = bin
LIBS = -fopenmp
SRCFILES = $(wildcard $(SRCDIR)/*.cpp)
OBJFILES = $(patsubst $(SRCDIR)/%.cpp,$(ODIR)/%.o,$(SRCFILES))
MAINFILE = main
EXEC_NAME = CTron
GAMES_TO_RUN = 5
all: $(BINDIR)/$(EXEC_NAME)
run: $(BINDIR)/$(EXEC_NAME)
@$(BINDIR)/./$(EXEC_NAME) $(GAMES_TO_RUN)
%Test: $(ODIR)/%Test.o $(OBJFILES)
mkdir -p $(BINDIR)/$(TESTDIR)
$(CC) -o $(BINDIR)/$(TESTDIR)/$@ $(filter-out $(ODIR)/$(MAINFILE).o, $^) $(CFLAGS) $(LIBS)
@echo "Start of tests...\n"
@$(BINDIR)/$(TESTDIR)/./$@
@echo "\nTests successful!"
$(BINDIR)/$(EXEC_NAME): $(OBJFILES)
mkdir -p $(BINDIR)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
$(ODIR)/%Test.o: $(TESTDIR)/%Test.cpp
mkdir -p $(ODIR)
$(CC) -c -o $@ $< $(CFLAGS)
.PRECIOUS: $(ODIR)/%Test.o
$(ODIR)/%.o: $(SRCDIR)/%.cpp
mkdir -p $(ODIR)
$(CC) -c -o $@ $< $(CFLAGS)
.PHONY: clean
clean:
rm -rf $(ODIR) $(BINDIR)