created a VERBOSE mode for the Makefile
[physics.git] / src / Makefile
... / ...
CommitLineData
1
2LIBGL := -lGL -lGLU
3LIBSDL := `sdl-config --libs`
4LIBS := ${LIBSDL} ${LIBGL}
5
6OPTFLAGS := -O2
7DBGFLAGS := -ggdb
8PRFFLAGS := ${DBGFLAGS} -pg
9
10#CXX := g++
11CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
12
13
14SRCS := entityManager.cpp
15SRCS += entityCreator.cpp
16SRCS += game.cpp
17SRCS += main.cpp
18SRCS += mathw.cpp
19SRCS += ticks.cpp
20SRCS += Vector2.cpp
21
22SRCS += Entities/Ball.cpp
23SRCS += Entities/Entity.cpp
24SRCS += Entities/Line.cpp
25SRCS += Entities/Particle.cpp
26SRCS += Entities/PhysicsEntity.cpp
27SRCS += Entities/Point.cpp
28SRCS += Entities/Polygon.cpp
29SRCS += Entities/WindParticle.cpp
30
31SRCS += GameStates/CreatingPolygon.cpp
32SRCS += GameStates/GameState.cpp
33SRCS += GameStates/Paused.cpp
34SRCS += GameStates/Running.cpp
35
36SRCS += input/inputManager.cpp
37
38SRCS += graphics/graphics.cpp
39
40OBJS := ${SRCS:.cpp=.o}
41
42
43TARGET := ../run_physics
44DEPENDS := ${SRCS:.cpp=.d}
45
46VERBOSE := 0
47
48ifeq (${VERBOSE},0)
49 # quiet the echo command
50 Q1 := @
51 # quiet the command that is `replaced' by an echo
52 Q2 := @
53else
54 # EAT the echo command as if it was not there
55 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
56 # do not quiet the command output
57 Q2 :=
58endif
59
60.PHONY: all
61all: ${TARGET}
62
63${TARGET}: ${OBJS}
64 ${Q1}echo "${CXX}: $@"
65 ${Q2}${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
66
67# how to make a depend file from a source file
68%.d: %.cpp
69 ${Q1}echo "DEP: $@"
70 ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
71#@${CXX} -M ${CXXFLAGS} $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
72
73%.o: %.cpp
74 ${Q1}echo "${CXX}: $@"
75 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
76
77
78.PHONY: clean
79clean:
80 ${Q1}echo "CLEAN: OBJS"
81 ${Q2}rm -f ${OBJS}
82 ${Q1}echo "CLEAN: TARGET"
83 ${Q2}rm -f ${TARGET}
84
85.PHONY: distclean
86distclean: clean
87 ${Q1}echo "CLEAN: DEPENDS"
88 ${Q2}rm -f ${DEPENDS}
89 ${Q1}echo "CLEAN: tags prof gmon.out"
90 ${Q2}rm -f tags prof gmon.out
91
92tags: ${SRCS}
93 ctags $^
94
95tar: clean
96 cd ..; tar -cjf physics.tar.bz2 src/
97
98
99.PHONY: run
100run: all
101 ${TARGET}
102
103.PHONY: val
104val: all
105 valgrind ${TARGET}
106
107.PHONY: prof
108prof: all
109 ${TARGET}
110 gprof -b ${TARGET} > prof
111 kprof -f prof
112
113-include ${DEPENDS}