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