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