-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (35 loc) · 1.09 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
CC=g++
CFLAGS=-c -Wall -ggdb -I.
LDFLAGS=
SOURCES=main.cpp Game.cpp
EXECUTABLE=a.out
TESTS = GameTest.h
OBJECTS=$(SOURCES:.cpp=.o)
OBJECTSTEST=Game.o
FLAGS = -Iinclude
all: $(SOURCES) $(EXECUTABLE)
# These next lines do a bit of magic found from http://stackoverflow.com/questions/2394609/makefile-header-dependencies
# Essentially it asks the compiler to read the .cpp files and generate the needed .h dependencies.
# This way if any .h file changes the correct .cpp files will be recompiled
depend: .depend
.depend: $(SOURCES)
rm -f ./.depend
$(CC) $(CFLAGS) -MM $^ >> ./.depend;
include .depend
# End .h file magic
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
$(CC) $(CFLAGS) $< -o $@
clean:
-rm -rf *o $(EXECUTABLE)
-rm -f testrunner testrunner.cpp
-rm -f ./.depend
# CXX Testing
CXXTESTGEN=./cxxtest/bin/cxxtestgen
test: testrunner
./testrunner
testrunner: testrunner.cpp $(OBJECTSTEST)
g++ -I. -I./cxxtest/ -o testrunner $(OBJECTSTEST) testrunner.cpp
testrunner.cpp: $(HEADERS) $(SOURCES) $(TESTS)
$(CXXTESTGEN) --error-printer -o testrunner.cpp $(TESTS)