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