created a VERBOSE mode for the Makefile
[physics.git] / src / Makefile
CommitLineData
ad9f1fb6 1
44b079f8
PG
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}
ad9f1fb6 12
ad9f1fb6 13
046b034c 14SRCS := entityManager.cpp
054d658f 15SRCS += entityCreator.cpp
046b034c 16SRCS += game.cpp
046b034c
PG
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
f7b3b2eb
PG
36SRCS += input/inputManager.cpp
37
44b079f8
PG
38SRCS += graphics/graphics.cpp
39
40OBJS := ${SRCS:.cpp=.o}
41
ad9f1fb6 42
44b079f8 43TARGET := ../run_physics
466ce08d 44DEPENDS := ${SRCS:.cpp=.d}
ad9f1fb6 45
393654cf
PG
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
ad9f1fb6 59
046b034c
PG
60.PHONY: all
61all: ${TARGET}
ad9f1fb6 62
046b034c 63${TARGET}: ${OBJS}
393654cf
PG
64 ${Q1}echo "${CXX}: $@"
65 ${Q2}${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
ad9f1fb6 66
466ce08d
PG
67# how to make a depend file from a source file
68%.d: %.cpp
393654cf
PG
69 ${Q1}echo "DEP: $@"
70 ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
466ce08d 71#@${CXX} -M ${CXXFLAGS} $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
ad9f1fb6 72
054d658f 73%.o: %.cpp
393654cf
PG
74 ${Q1}echo "${CXX}: $@"
75 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
054d658f 76
ad9f1fb6 77
046b034c 78.PHONY: clean
ad9f1fb6 79clean:
393654cf
PG
80 ${Q1}echo "CLEAN: OBJS"
81 ${Q2}rm -f ${OBJS}
82 ${Q1}echo "CLEAN: TARGET"
83 ${Q2}rm -f ${TARGET}
ad9f1fb6 84
046b034c 85.PHONY: distclean
ad9f1fb6 86distclean: clean
393654cf
PG
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
ad9f1fb6 91
046b034c
PG
92tags: ${SRCS}
93 ctags $^
94
ad9f1fb6 95tar: clean
63a52c99 96 cd ..; tar -cjf physics.tar.bz2 src/
ad9f1fb6
PG
97
98
046b034c
PG
99.PHONY: run
100run: all
27b74820 101 ${TARGET}
ad9f1fb6 102
63a52c99
PG
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
ad9f1fb6 112
466ce08d 113-include ${DEPENDS}