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 | |
9 | ||
10 | #CXX := g++ | |
11 | CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS} | |
ad9f1fb6 | 12 | |
a4bb9ac2 | 13 | TARGET := ../run_physics |
ad9f1fb6 | 14 | |
a4bb9ac2 PG |
15 | SRCS := # simply to keep every line below the same |
16 | SRCS += entityManager.cpp | |
054d658f | 17 | SRCS += entityCreator.cpp |
046b034c | 18 | SRCS += game.cpp |
046b034c PG |
19 | SRCS += main.cpp |
20 | SRCS += mathw.cpp | |
21 | SRCS += ticks.cpp | |
22 | SRCS += Vector2.cpp | |
7cbd4505 | 23 | SRCS += handleSignal.cpp |
046b034c PG |
24 | |
25 | SRCS += Entities/Ball.cpp | |
26 | SRCS += Entities/Entity.cpp | |
27 | SRCS += Entities/Line.cpp | |
28 | SRCS += Entities/Particle.cpp | |
29 | SRCS += Entities/PhysicsEntity.cpp | |
30 | SRCS += Entities/Point.cpp | |
31 | SRCS += Entities/Polygon.cpp | |
32 | SRCS += Entities/WindParticle.cpp | |
33 | ||
34 | SRCS += GameStates/CreatingPolygon.cpp | |
35 | SRCS += GameStates/GameState.cpp | |
36 | SRCS += GameStates/Paused.cpp | |
37 | SRCS += GameStates/Running.cpp | |
38 | ||
f7b3b2eb PG |
39 | SRCS += input/inputManager.cpp |
40 | ||
44b079f8 PG |
41 | SRCS += graphics/graphics.cpp |
42 | ||
43 | OBJS := ${SRCS:.cpp=.o} | |
a4bb9ac2 | 44 | DEPENDS := ${SRCS:.cpp=.d} |
44b079f8 | 45 | |
a4bb9ac2 PG |
46 | HRDS := ${SRCS:.cpp=.h} |
47 | HRDS := ${HRDS:main.h=} # remove main.h | |
48 | HRDS += debug.h | |
49 | HRDS += graphics/colors.h | |
50 | ||
51 | TARS := ${SRCS} ${HRDS} Makefile | |
ad9f1fb6 | 52 | |
ad9f1fb6 | 53 | |
393654cf PG |
54 | VERBOSE := 0 |
55 | ||
56 | ifeq (${VERBOSE},0) | |
57 | # quiet the echo command | |
58 | Q1 := @ | |
59 | # quiet the command that is `replaced' by an echo | |
60 | Q2 := @ | |
61 | else | |
62 | # EAT the echo command as if it was not there | |
63 | Q1 := @true # NOTE: the space between @true and the # is VERY important!! | |
64 | # do not quiet the command output | |
65 | Q2 := | |
66 | endif | |
ad9f1fb6 | 67 | |
046b034c PG |
68 | .PHONY: all |
69 | all: ${TARGET} | |
ad9f1fb6 | 70 | |
046b034c | 71 | ${TARGET}: ${OBJS} |
393654cf PG |
72 | ${Q1}echo "${CXX}: $@" |
73 | ${Q2}${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS} | |
ad9f1fb6 | 74 | |
a4bb9ac2 | 75 | # rule to make a depend file from a .cpp |
466ce08d | 76 | %.d: %.cpp |
393654cf PG |
77 | ${Q1}echo "DEP: $@" |
78 | ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@ | |
ad9f1fb6 | 79 | |
a4bb9ac2 | 80 | # rule to make an object file from a .cpp |
054d658f | 81 | %.o: %.cpp |
393654cf PG |
82 | ${Q1}echo "${CXX}: $@" |
83 | ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< | |
054d658f | 84 | |
ad9f1fb6 | 85 | |
046b034c | 86 | .PHONY: clean |
ad9f1fb6 | 87 | clean: |
393654cf PG |
88 | ${Q1}echo "CLEAN: OBJS" |
89 | ${Q2}rm -f ${OBJS} | |
90 | ${Q1}echo "CLEAN: TARGET" | |
91 | ${Q2}rm -f ${TARGET} | |
ad9f1fb6 | 92 | |
046b034c | 93 | .PHONY: distclean |
ad9f1fb6 | 94 | distclean: clean |
393654cf PG |
95 | ${Q1}echo "CLEAN: DEPENDS" |
96 | ${Q2}rm -f ${DEPENDS} | |
97 | ${Q1}echo "CLEAN: tags prof gmon.out" | |
98 | ${Q2}rm -f tags prof gmon.out | |
ad9f1fb6 | 99 | |
046b034c PG |
100 | tags: ${SRCS} |
101 | ctags $^ | |
102 | ||
a4bb9ac2 | 103 | tar: |
7dd353d9 | 104 | ${Q1}echo "tar: physics.tar.bz2" |
a4bb9ac2 PG |
105 | ${Q2}rm -f physics.tar # prevents appending |
106 | ${Q2}for f in ${TARS}; do\ | |
107 | tar -C ../.. -rf physics.tar "physics/src/$$f"; done | |
108 | ${Q2}bzip2 physics.tar | |
ad9f1fb6 | 109 | |
a4bb9ac2 PG |
110 | git-tar: |
111 | ${Q1}echo "git-archive: ../physics.tar.bz2" | |
112 | ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2 | |
ad9f1fb6 | 113 | |
046b034c PG |
114 | .PHONY: run |
115 | run: all | |
27b74820 | 116 | ${TARGET} |
ad9f1fb6 | 117 | |
63a52c99 PG |
118 | .PHONY: val |
119 | val: all | |
f72f4a59 | 120 | valgrind --leak-check=full ${TARGET} |
63a52c99 PG |
121 | |
122 | .PHONY: prof | |
123 | prof: all | |
124 | ${TARGET} | |
125 | gprof -b ${TARGET} > prof | |
126 | kprof -f prof | |
ad9f1fb6 | 127 | |
466ce08d | 128 | -include ${DEPENDS} |