added gitclean and gitcleanf to Makefile, insures local copy matches what is being...
[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 CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
10
11 VALFLAGS := --leak-check=full
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/GravityWell.cpp
46 SRCS += Effects/Screen.cpp
47
48 SRCS += config/config.cpp
49
50 SRCS += input/inputManager.cpp
51
52 SRCS += graphics/graphics.cpp
53
54 OBJSDIR := ../objs/
55 OBJS := ${SRCS:.cpp=.o}
56 OBJS := $(addprefix ${OBJSDIR},${OBJS})
57
58 DEPSDIR := ../deps/
59 DEPS := ${SRCS:.cpp=.d}
60 DEPS := $(addprefix ${DEPSDIR},${DEPS})
61
62 HRDS := ${SRCS:.cpp=.h}
63 HRDS := $(filter-out main.h,$HRDS) # remove main.h
64 HRDS += debug.h
65
66 HRDS += graphics/colors.h
67
68 TARS := ${SRCS} ${HRDS} Makefile
69
70
71 VERBOSE := 0
72
73 ifeq (${VERBOSE},0)
74     # quiet the echo command
75     Q1 := @
76     # quiet the command that is `replaced' by an echo
77     Q2 := @
78 else
79     # EAT the echo command as if it was not there
80     Q1 := @true # NOTE: the space between @true and the # is VERY important!!
81     # do not quiet the command output
82     Q2 :=
83 endif
84
85 .PHONY: all
86 all: ${TARGET}
87
88 ${TARGET}: ${OBJS}
89         ${Q1}echo "${CXX}: $@"
90         ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
91
92 # rule to make a depend file from a .cpp
93 ${DEPSDIR}%.d: %.cpp
94         ${Q1}echo "DEP: $@"
95         ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
96
97 # rule to make an object file from a .cpp
98 ${OBJSDIR}%.o: %.cpp
99         ${Q1}echo "${CXX}: $@"
100         ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
101
102
103 .PHONY: clean
104 clean:
105         ${Q1}echo "CLEAN: OBJS"
106         ${Q2}rm -f ${OBJS}
107         ${Q1}echo "CLEAN: TARGET"
108         ${Q2}rm -f ${TARGET}
109
110 .PHONY: distclean
111 distclean: clean
112         ${Q1}echo "CLEAN: DEPS"
113         ${Q2}rm -f ${DEPS}
114         ${Q1}echo "CLEAN: tags prof gmon.out"
115         ${Q2}rm -f tags prof gmon.out
116
117 .PHONY: gitclean
118 gitclean:
119         ${Q1}echo "git-clean: show, use gitcleanf to force"
120         ${Q2}cd ..; git clean -nxd
121
122 .PHONY: gitcleanf
123 gitcleanf:
124         ${Q1}echo "git-clean: forced"
125         ${Q2}cd ..; git clean -fxd
126
127 tags: ${SRCS}
128         ctags $^
129
130 .PHONY: tar
131 tar: ../physics.tar.bz2
132
133 .PHONY: ../physics.tar.bz2
134 ../physics.tar.bz2:
135         @echo "git-archive: Warning, archives HEAD not current"
136         ${Q1}echo "git-archive: ../physics.tar.bz2"
137         ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
138
139 .PHONY: run
140 run: all
141         ${TARGET}
142
143 .PHONY: gdb
144 gdb: all
145         gdb ${TARGET}
146
147 .PHONY: val
148 val: all
149         valgrind ${VALFLAGS} ${TARGET}
150
151 .PHONY: prof
152 prof: all
153         ${TARGET}
154         gprof -b ${TARGET} > prof
155         kprof -f prof
156
157 -include ${DEPS}