Commit | Line | Data |
---|---|---|
ad9f1fb6 | 1 | |
44b079f8 PG |
2 | LIBGL := -lGL -lGLU |
3 | LIBSDL := `sdl-config --libs` | |
4 | LIBS := ${LIBSDL} ${LIBGL} | |
5 | ||
6 | OPTFLAGS := -O2 | |
7 | DBGFLAGS := -ggdb | |
8 | PRFFLAGS := ${DBGFLAGS} -pg | |
e861d993 | 9 | VALFLAGS := --leak-check=full |
44b079f8 PG |
10 | |
11 | #CXX := g++ | |
12 | CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS} | |
ad9f1fb6 | 13 | |
a4bb9ac2 | 14 | TARGET := ../run_physics |
ad9f1fb6 | 15 | |
a4bb9ac2 | 16 | SRCS := # simply to keep every line below the same |
046b034c | 17 | SRCS += game.cpp |
046b034c PG |
18 | SRCS += main.cpp |
19 | SRCS += mathw.cpp | |
20 | SRCS += ticks.cpp | |
21 | SRCS += Vector2.cpp | |
7cbd4505 | 22 | SRCS += handleSignal.cpp |
046b034c | 23 | |
54fe85c5 PG |
24 | SRCS += entityManager.cpp |
25 | SRCS += effectManager.cpp | |
26 | SRCS += entityCreator.cpp | |
27 | SRCS += collisionHandler.cpp | |
28 | SRCS += CollisionInfo.cpp | |
29 | ||
046b034c PG |
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 | ||
ec70635e PG |
44 | SRCS += Effects/Effect.cpp |
45 | SRCS += Effects/Gravity.cpp | |
2c18685d | 46 | SRCS += Effects/Screen.cpp |
ec70635e | 47 | |
f7b3b2eb PG |
48 | SRCS += input/inputManager.cpp |
49 | ||
44b079f8 PG |
50 | SRCS += graphics/graphics.cpp |
51 | ||
f4b779e4 | 52 | OBJSDIR := ../objs/ |
44b079f8 | 53 | OBJS := ${SRCS:.cpp=.o} |
f4b779e4 PG |
54 | OBJS := $(addprefix ${OBJSDIR},${OBJS}) |
55 | ||
56 | DEPSDIR := ../deps/ | |
57 | DEPS := ${SRCS:.cpp=.d} | |
58 | DEPS := $(addprefix ${DEPSDIR},${DEPS}) | |
44b079f8 | 59 | |
a4bb9ac2 PG |
60 | HRDS := ${SRCS:.cpp=.h} |
61 | HRDS := ${HRDS:main.h=} # remove main.h | |
62 | HRDS += debug.h | |
ec70635e | 63 | |
a4bb9ac2 PG |
64 | HRDS += graphics/colors.h |
65 | ||
66 | TARS := ${SRCS} ${HRDS} Makefile | |
ad9f1fb6 | 67 | |
ad9f1fb6 | 68 | |
393654cf PG |
69 | VERBOSE := 0 |
70 | ||
71 | ifeq (${VERBOSE},0) | |
72 | # quiet the echo command | |
73 | Q1 := @ | |
74 | # quiet the command that is `replaced' by an echo | |
75 | Q2 := @ | |
76 | else | |
77 | # EAT the echo command as if it was not there | |
78 | Q1 := @true # NOTE: the space between @true and the # is VERY important!! | |
79 | # do not quiet the command output | |
80 | Q2 := | |
81 | endif | |
ad9f1fb6 | 82 | |
046b034c PG |
83 | .PHONY: all |
84 | all: ${TARGET} | |
ad9f1fb6 | 85 | |
046b034c | 86 | ${TARGET}: ${OBJS} |
393654cf | 87 | ${Q1}echo "${CXX}: $@" |
eb0c55e7 | 88 | ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS} |
ad9f1fb6 | 89 | |
a4bb9ac2 | 90 | # rule to make a depend file from a .cpp |
f4b779e4 | 91 | ${DEPSDIR}%.d: %.cpp |
393654cf PG |
92 | ${Q1}echo "DEP: $@" |
93 | ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@ | |
ad9f1fb6 | 94 | |
a4bb9ac2 | 95 | # rule to make an object file from a .cpp |
f4b779e4 | 96 | ${OBJSDIR}%.o: %.cpp |
393654cf PG |
97 | ${Q1}echo "${CXX}: $@" |
98 | ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< | |
054d658f | 99 | |
ad9f1fb6 | 100 | |
046b034c | 101 | .PHONY: clean |
ad9f1fb6 | 102 | clean: |
393654cf PG |
103 | ${Q1}echo "CLEAN: OBJS" |
104 | ${Q2}rm -f ${OBJS} | |
105 | ${Q1}echo "CLEAN: TARGET" | |
106 | ${Q2}rm -f ${TARGET} | |
ad9f1fb6 | 107 | |
046b034c | 108 | .PHONY: distclean |
ad9f1fb6 | 109 | distclean: clean |
f4b779e4 PG |
110 | ${Q1}echo "CLEAN: DEPS" |
111 | ${Q2}rm -f ${DEPS} | |
393654cf PG |
112 | ${Q1}echo "CLEAN: tags prof gmon.out" |
113 | ${Q2}rm -f tags prof gmon.out | |
ad9f1fb6 | 114 | |
046b034c PG |
115 | tags: ${SRCS} |
116 | ctags $^ | |
117 | ||
7adc59fe | 118 | .PHONY: tar |
a4bb9ac2 | 119 | tar: |
7dd353d9 | 120 | ${Q1}echo "tar: physics.tar.bz2" |
a4bb9ac2 PG |
121 | ${Q2}rm -f physics.tar # prevents appending |
122 | ${Q2}for f in ${TARS}; do\ | |
123 | tar -C ../.. -rf physics.tar "physics/src/$$f"; done | |
124 | ${Q2}bzip2 physics.tar | |
ad9f1fb6 | 125 | |
7adc59fe | 126 | .PHONY: git-tar |
a4bb9ac2 PG |
127 | git-tar: |
128 | ${Q1}echo "git-archive: ../physics.tar.bz2" | |
129 | ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2 | |
ad9f1fb6 | 130 | |
046b034c PG |
131 | .PHONY: run |
132 | run: all | |
27b74820 | 133 | ${TARGET} |
ad9f1fb6 | 134 | |
6aad402a PG |
135 | .PHONY: gdb |
136 | gdb: all | |
137 | gdb ${TARGET} | |
138 | ||
63a52c99 PG |
139 | .PHONY: val |
140 | val: all | |
e861d993 | 141 | valgrind ${VALFLAGS} ${TARGET} |
63a52c99 PG |
142 | |
143 | .PHONY: prof | |
144 | prof: all | |
145 | ${TARGET} | |
146 | gprof -b ${TARGET} > prof | |
147 | kprof -f prof | |
ad9f1fb6 | 148 | |
f4b779e4 | 149 | -include ${DEPS} |