added gitclean and gitcleanf to Makefile, insures local copy matches what is being...
[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
54fe85c5
PG
23SRCS += entityManager.cpp
24SRCS += effectManager.cpp
25SRCS += entityCreator.cpp
26SRCS += collisionHandler.cpp
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
8f8b6693 49
f7b3b2eb
PG
50SRCS += input/inputManager.cpp
51
44b079f8
PG
52SRCS += graphics/graphics.cpp
53
f4b779e4 54OBJSDIR := ../objs/
44b079f8 55OBJS := ${SRCS:.cpp=.o}
f4b779e4
PG
56OBJS := $(addprefix ${OBJSDIR},${OBJS})
57
58DEPSDIR := ../deps/
59DEPS := ${SRCS:.cpp=.d}
60DEPS := $(addprefix ${DEPSDIR},${DEPS})
44b079f8 61
a4bb9ac2 62HRDS := ${SRCS:.cpp=.h}
5d5a6f3f 63HRDS := $(filter-out main.h,$HRDS) # remove main.h
a4bb9ac2 64HRDS += debug.h
ec70635e 65
a4bb9ac2
PG
66HRDS += graphics/colors.h
67
68TARS := ${SRCS} ${HRDS} Makefile
ad9f1fb6 69
ad9f1fb6 70
393654cf
PG
71VERBOSE := 0
72
73ifeq (${VERBOSE},0)
74 # quiet the echo command
75 Q1 := @
76 # quiet the command that is `replaced' by an echo
77 Q2 := @
78else
79 # EAT the echo command as if it was not there
80 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
81 # do not quiet the command output
82 Q2 :=
83endif
ad9f1fb6 84
046b034c
PG
85.PHONY: all
86all: ${TARGET}
ad9f1fb6 87
046b034c 88${TARGET}: ${OBJS}
393654cf 89 ${Q1}echo "${CXX}: $@"
eb0c55e7 90 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
ad9f1fb6 91
a4bb9ac2 92# rule to make a depend file from a .cpp
f4b779e4 93${DEPSDIR}%.d: %.cpp
393654cf
PG
94 ${Q1}echo "DEP: $@"
95 ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
ad9f1fb6 96
a4bb9ac2 97# rule to make an object file from a .cpp
f4b779e4 98${OBJSDIR}%.o: %.cpp
393654cf
PG
99 ${Q1}echo "${CXX}: $@"
100 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
054d658f 101
ad9f1fb6 102
046b034c 103.PHONY: clean
ad9f1fb6 104clean:
393654cf
PG
105 ${Q1}echo "CLEAN: OBJS"
106 ${Q2}rm -f ${OBJS}
107 ${Q1}echo "CLEAN: TARGET"
108 ${Q2}rm -f ${TARGET}
ad9f1fb6 109
046b034c 110.PHONY: distclean
ad9f1fb6 111distclean: clean
f4b779e4
PG
112 ${Q1}echo "CLEAN: DEPS"
113 ${Q2}rm -f ${DEPS}
393654cf
PG
114 ${Q1}echo "CLEAN: tags prof gmon.out"
115 ${Q2}rm -f tags prof gmon.out
ad9f1fb6 116
d893cce2
PG
117.PHONY: gitclean
118gitclean:
119 ${Q1}echo "git-clean: show, use gitcleanf to force"
120 ${Q2}cd ..; git clean -nxd
121
122.PHONY: gitcleanf
123gitcleanf:
124 ${Q1}echo "git-clean: forced"
125 ${Q2}cd ..; git clean -fxd
126
046b034c
PG
127tags: ${SRCS}
128 ctags $^
129
7adc59fe 130.PHONY: tar
8381f595
PG
131tar: ../physics.tar.bz2
132
133.PHONY: ../physics.tar.bz2
134../physics.tar.bz2:
135 @echo "git-archive: Warning, archives HEAD not current"
a4bb9ac2
PG
136 ${Q1}echo "git-archive: ../physics.tar.bz2"
137 ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
ad9f1fb6 138
046b034c
PG
139.PHONY: run
140run: all
27b74820 141 ${TARGET}
ad9f1fb6 142
6aad402a
PG
143.PHONY: gdb
144gdb: all
145 gdb ${TARGET}
146
63a52c99
PG
147.PHONY: val
148val: all
e861d993 149 valgrind ${VALFLAGS} ${TARGET}
63a52c99
PG
150
151.PHONY: prof
152prof: all
153 ${TARGET}
154 gprof -b ${TARGET} > prof
155 kprof -f prof
ad9f1fb6 156
f4b779e4 157-include ${DEPS}