added VALFLAGS varible
[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
e861d993 9VALFLAGS := --leak-check=full
44b079f8
PG
10
11#CXX := g++
12CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
ad9f1fb6 13
a4bb9ac2 14TARGET := ../run_physics
ad9f1fb6 15
a4bb9ac2 16SRCS := # simply to keep every line below the same
046b034c 17SRCS += game.cpp
046b034c
PG
18SRCS += main.cpp
19SRCS += mathw.cpp
20SRCS += ticks.cpp
21SRCS += Vector2.cpp
7cbd4505 22SRCS += handleSignal.cpp
046b034c 23
54fe85c5
PG
24SRCS += entityManager.cpp
25SRCS += effectManager.cpp
26SRCS += entityCreator.cpp
27SRCS += collisionHandler.cpp
28SRCS += CollisionInfo.cpp
29
046b034c
PG
30SRCS += Entities/Ball.cpp
31SRCS += Entities/Entity.cpp
32SRCS += Entities/Line.cpp
33SRCS += Entities/Particle.cpp
34SRCS += Entities/PhysicsEntity.cpp
35SRCS += Entities/Point.cpp
36SRCS += Entities/Polygon.cpp
37SRCS += Entities/WindParticle.cpp
38
39SRCS += GameStates/CreatingPolygon.cpp
40SRCS += GameStates/GameState.cpp
41SRCS += GameStates/Paused.cpp
42SRCS += GameStates/Running.cpp
43
ec70635e
PG
44SRCS += Effects/Effect.cpp
45SRCS += Effects/Gravity.cpp
2c18685d 46SRCS += Effects/Screen.cpp
ec70635e 47
f7b3b2eb
PG
48SRCS += input/inputManager.cpp
49
44b079f8
PG
50SRCS += graphics/graphics.cpp
51
52OBJS := ${SRCS:.cpp=.o}
a4bb9ac2 53DEPENDS := ${SRCS:.cpp=.d}
44b079f8 54
a4bb9ac2
PG
55HRDS := ${SRCS:.cpp=.h}
56HRDS := ${HRDS:main.h=} # remove main.h
57HRDS += debug.h
ec70635e 58
a4bb9ac2
PG
59HRDS += graphics/colors.h
60
61TARS := ${SRCS} ${HRDS} Makefile
ad9f1fb6 62
ad9f1fb6 63
393654cf
PG
64VERBOSE := 0
65
66ifeq (${VERBOSE},0)
67 # quiet the echo command
68 Q1 := @
69 # quiet the command that is `replaced' by an echo
70 Q2 := @
71else
72 # EAT the echo command as if it was not there
73 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
74 # do not quiet the command output
75 Q2 :=
76endif
ad9f1fb6 77
046b034c
PG
78.PHONY: all
79all: ${TARGET}
ad9f1fb6 80
046b034c 81${TARGET}: ${OBJS}
393654cf
PG
82 ${Q1}echo "${CXX}: $@"
83 ${Q2}${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
ad9f1fb6 84
a4bb9ac2 85# rule to make a depend file from a .cpp
466ce08d 86%.d: %.cpp
393654cf
PG
87 ${Q1}echo "DEP: $@"
88 ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
ad9f1fb6 89
a4bb9ac2 90# rule to make an object file from a .cpp
054d658f 91%.o: %.cpp
393654cf
PG
92 ${Q1}echo "${CXX}: $@"
93 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
054d658f 94
ad9f1fb6 95
046b034c 96.PHONY: clean
ad9f1fb6 97clean:
393654cf
PG
98 ${Q1}echo "CLEAN: OBJS"
99 ${Q2}rm -f ${OBJS}
100 ${Q1}echo "CLEAN: TARGET"
101 ${Q2}rm -f ${TARGET}
ad9f1fb6 102
046b034c 103.PHONY: distclean
ad9f1fb6 104distclean: clean
393654cf
PG
105 ${Q1}echo "CLEAN: DEPENDS"
106 ${Q2}rm -f ${DEPENDS}
107 ${Q1}echo "CLEAN: tags prof gmon.out"
108 ${Q2}rm -f tags prof gmon.out
ad9f1fb6 109
046b034c
PG
110tags: ${SRCS}
111 ctags $^
112
7adc59fe 113.PHONY: tar
a4bb9ac2 114tar:
7dd353d9 115 ${Q1}echo "tar: physics.tar.bz2"
a4bb9ac2
PG
116 ${Q2}rm -f physics.tar # prevents appending
117 ${Q2}for f in ${TARS}; do\
118 tar -C ../.. -rf physics.tar "physics/src/$$f"; done
119 ${Q2}bzip2 physics.tar
ad9f1fb6 120
7adc59fe 121.PHONY: git-tar
a4bb9ac2
PG
122git-tar:
123 ${Q1}echo "git-archive: ../physics.tar.bz2"
124 ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
ad9f1fb6 125
046b034c
PG
126.PHONY: run
127run: all
27b74820 128 ${TARGET}
ad9f1fb6 129
6aad402a
PG
130.PHONY: gdb
131gdb: all
132 gdb ${TARGET}
133
63a52c99
PG
134.PHONY: val
135val: all
e861d993 136 valgrind ${VALFLAGS} ${TARGET}
63a52c99
PG
137
138.PHONY: prof
139prof: all
140 ${TARGET}
141 gprof -b ${TARGET} > prof
142 kprof -f prof
ad9f1fb6 143
466ce08d 144-include ${DEPENDS}