added ball to ball collisions
[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
10 #CXX := g++
11 CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
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 += entityManager.cpp
24 SRCS += effectManager.cpp
25 SRCS += entityCreator.cpp
26 SRCS += collisionHandler.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/Screen.cpp
46
47 SRCS += input/inputManager.cpp
48
49 SRCS += graphics/graphics.cpp
50
51 OBJS := ${SRCS:.cpp=.o}
52 DEPENDS := ${SRCS:.cpp=.d}
53
54 HRDS := ${SRCS:.cpp=.h}
55 HRDS := ${HRDS:main.h=} # remove main.h
56 HRDS += debug.h
57
58 HRDS += graphics/colors.h
59
60 TARS := ${SRCS} ${HRDS} Makefile
61
62
63 VERBOSE := 0
64
65 ifeq (${VERBOSE},0)
66     # quiet the echo command
67     Q1 := @
68     # quiet the command that is `replaced' by an echo
69     Q2 := @
70 else
71     # EAT the echo command as if it was not there
72     Q1 := @true # NOTE: the space between @true and the # is VERY important!!
73     # do not quiet the command output
74     Q2 :=
75 endif
76
77 .PHONY: all
78 all: ${TARGET}
79
80 ${TARGET}: ${OBJS}
81         ${Q1}echo "${CXX}: $@"
82         ${Q2}${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
83
84 # rule to make a depend file from a .cpp
85 %.d: %.cpp
86         ${Q1}echo "DEP: $@"
87         ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
88
89 # rule to make an object file from a .cpp
90 %.o: %.cpp
91         ${Q1}echo "${CXX}: $@"
92         ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
93
94
95 .PHONY: clean
96 clean:
97         ${Q1}echo "CLEAN: OBJS"
98         ${Q2}rm -f ${OBJS}
99         ${Q1}echo "CLEAN: TARGET"
100         ${Q2}rm -f ${TARGET}
101
102 .PHONY: distclean
103 distclean: clean
104         ${Q1}echo "CLEAN: DEPENDS"
105         ${Q2}rm -f ${DEPENDS}
106         ${Q1}echo "CLEAN: tags prof gmon.out"
107         ${Q2}rm -f tags prof gmon.out
108
109 tags: ${SRCS}
110         ctags $^
111
112 .PHONY: tar
113 tar:
114         ${Q1}echo "tar: physics.tar.bz2"
115         ${Q2}rm -f physics.tar # prevents appending
116         ${Q2}for f in ${TARS}; do\
117                 tar -C ../.. -rf physics.tar "physics/src/$$f"; done
118         ${Q2}bzip2 physics.tar
119
120 .PHONY: git-tar
121 git-tar:
122         ${Q1}echo "git-archive: ../physics.tar.bz2"
123         ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
124
125 .PHONY: run
126 run: all
127         ${TARGET}
128
129 .PHONY: gdb
130 gdb: all
131         gdb ${TARGET}
132
133 .PHONY: val
134 val: all
135         valgrind --leak-check=full ${TARGET}
136
137 .PHONY: prof
138 prof: all
139         ${TARGET}
140         gprof -b ${TARGET} > prof
141         kprof -f prof
142
143 -include ${DEPENDS}