-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
47 lines (36 loc) · 988 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
BIN = ./tankX.bin
INPUT = cat test_input.txt
#ARGS = input.txt
SRCDIR = ./src
INCDIR = ./inc
OBJDIR = ./obj
OBJS = obj/main.o obj/mat4.o obj/vec4.o obj/mesh.o obj/game_object.o
SRCS = $(wildcard $(SRCDIR)/*.cpp)
INCS = $(wildcard $(INCDIR)/*.h*) $(wildcard $(INCDIR)/*.hpp)
OGLLIBS ?= -lGL -lglut -lGLU
INCLUDES= -I$(INCDIR)/
CXX ?= c++
CXXFLAGS = -ansi -pedantic -g -Wall $(INCLUDES)
.PHONY : run bin test clean memcheck
run : $(BIN)
@ echo "Testing executable"
$(BIN) $(ARGS)
bin : $(BIN)
test : clean memcheck
clean :
@ echo "Removing generated files"
rm -f $(BIN)
rm -rf $(OBJDIR)
memcheck : $(BIN)
@ echo "Running valgrind to check for memory leaks"
valgrind --tool=memcheck --leak-check=yes --max-stackframe=5000000 \
--show-reachable=yes $(BIN) $(ARGS)
@ echo
$(BIN) : $(OBJS) $(INCS)
@ echo "Compiling binary"
$(CXX) -o $(BIN) $(OBJS) $(INCLUDES) $(OGLLIBS)
@ echo
obj/%.o : src/%.cpp $(INCS)
@- mkdir -p $(OBJDIR)
$(CXX) -c -o $@ $< $(CXXFLAGS)
@ echo