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