small Makefile change
[physics.git] / src / Makefile
... / ...
CommitLineData
1
2LIBGL := -lGL -lGLU
3LIBSDL := `sdl-config --libs`
4LIBS := ${LIBSDL} ${LIBGL}
5
6OPTFLAGS := -O2
7DBGFLAGS := -ggdb
8PRFFLAGS := ${DBGFLAGS} -pg
9VALFLAGS := --leak-check=full
10
11#CXX := g++
12CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
13
14TARGET := ../run_physics
15
16SRCS := # simply to keep every line below the same
17SRCS += game.cpp
18SRCS += main.cpp
19SRCS += mathw.cpp
20SRCS += ticks.cpp
21SRCS += Vector2.cpp
22SRCS += handleSignal.cpp
23
24SRCS += entityManager.cpp
25SRCS += effectManager.cpp
26SRCS += entityCreator.cpp
27SRCS += collisionHandler.cpp
28SRCS += CollisionInfo.cpp
29
30SRCS += Entities/Ball.cpp
31SRCS += Entities/Entity.cpp
32SRCS += Entities/Line.cpp
33SRCS += Entities/Particle.cpp
34SRCS += Entities/PhysicsEntity.cpp
35SRCS += Entities/Point.cpp
36SRCS += Entities/Polygon.cpp
37SRCS += Entities/WindParticle.cpp
38
39SRCS += GameStates/CreatingPolygon.cpp
40SRCS += GameStates/GameState.cpp
41SRCS += GameStates/Paused.cpp
42SRCS += GameStates/Running.cpp
43
44SRCS += Effects/Effect.cpp
45SRCS += Effects/Gravity.cpp
46SRCS += Effects/Screen.cpp
47
48SRCS += input/inputManager.cpp
49
50SRCS += graphics/graphics.cpp
51
52OBJSDIR := ../objs/
53OBJS := ${SRCS:.cpp=.o}
54OBJS := $(addprefix ${OBJSDIR},${OBJS})
55
56DEPSDIR := ../deps/
57DEPS := ${SRCS:.cpp=.d}
58DEPS := $(addprefix ${DEPSDIR},${DEPS})
59
60HRDS := ${SRCS:.cpp=.h}
61HRDS := ${HRDS:main.h=} # remove main.h
62HRDS += debug.h
63
64HRDS += graphics/colors.h
65
66TARS := ${SRCS} ${HRDS} Makefile
67
68
69VERBOSE := 0
70
71ifeq (${VERBOSE},0)
72 # quiet the echo command
73 Q1 := @
74 # quiet the command that is `replaced' by an echo
75 Q2 := @
76else
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 :=
81endif
82
83.PHONY: all
84all: ${TARGET}
85
86${TARGET}: ${OBJS}
87 ${Q1}echo "${CXX}: $@"
88 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
89
90# rule to make a depend file from a .cpp
91${DEPSDIR}%.d: %.cpp
92 ${Q1}echo "DEP: $@"
93 ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
94
95# rule to make an object file from a .cpp
96${OBJSDIR}%.o: %.cpp
97 ${Q1}echo "${CXX}: $@"
98 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
99
100
101.PHONY: clean
102clean:
103 ${Q1}echo "CLEAN: OBJS"
104 ${Q2}rm -f ${OBJS}
105 ${Q1}echo "CLEAN: TARGET"
106 ${Q2}rm -f ${TARGET}
107
108.PHONY: distclean
109distclean: clean
110 ${Q1}echo "CLEAN: DEPS"
111 ${Q2}rm -f ${DEPS}
112 ${Q1}echo "CLEAN: tags prof gmon.out"
113 ${Q2}rm -f tags prof gmon.out
114
115tags: ${SRCS}
116 ctags $^
117
118.PHONY: tar
119tar:
120 ${Q1}echo "tar: physics.tar.bz2"
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
125
126.PHONY: git-tar
127git-tar:
128 ${Q1}echo "git-archive: ../physics.tar.bz2"
129 ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
130
131.PHONY: run
132run: all
133 ${TARGET}
134
135.PHONY: gdb
136gdb: all
137 gdb ${TARGET}
138
139.PHONY: val
140val: all
141 valgrind ${VALFLAGS} ${TARGET}
142
143.PHONY: prof
144prof: all
145 ${TARGET}
146 gprof -b ${TARGET} > prof
147 kprof -f prof
148
149-include ${DEPS}