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