Merge branch 'master' into effects
[physics.git] / src / Makefile
... / ...
CommitLineData
1
2LIBGL := -lGL -lGLU
3LIBSDL := `sdl-config --libs`
4LIBS := ${LIBSDL} ${LIBGL}
5
6OPTFLAGS := -O2
7DBGFLAGS := -ggdb
8PRFFLAGS := ${DBGFLAGS} -pg
9
10#CXX := g++
11CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
12
13TARGET := ../run_physics
14
15SRCS := # simply to keep every line below the same
16SRCS += entityManager.cpp
17SRCS += entityCreator.cpp
18SRCS += game.cpp
19SRCS += main.cpp
20SRCS += mathw.cpp
21SRCS += ticks.cpp
22SRCS += Vector2.cpp
23SRCS += handleSignal.cpp
24
25SRCS += Entities/Ball.cpp
26SRCS += Entities/Entity.cpp
27SRCS += Entities/Line.cpp
28SRCS += Entities/Particle.cpp
29SRCS += Entities/PhysicsEntity.cpp
30SRCS += Entities/Point.cpp
31SRCS += Entities/Polygon.cpp
32SRCS += Entities/WindParticle.cpp
33
34SRCS += GameStates/CreatingPolygon.cpp
35SRCS += GameStates/GameState.cpp
36SRCS += GameStates/Paused.cpp
37SRCS += GameStates/Running.cpp
38
39SRCS += input/inputManager.cpp
40
41SRCS += graphics/graphics.cpp
42
43OBJS := ${SRCS:.cpp=.o}
44DEPENDS := ${SRCS:.cpp=.d}
45
46HRDS := ${SRCS:.cpp=.h}
47HRDS := ${HRDS:main.h=} # remove main.h
48HRDS += debug.h
49HRDS += graphics/colors.h
50
51TARS := ${SRCS} ${HRDS} Makefile
52
53
54VERBOSE := 0
55
56ifeq (${VERBOSE},0)
57 # quiet the echo command
58 Q1 := @
59 # quiet the command that is `replaced' by an echo
60 Q2 := @
61else
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 :=
66endif
67
68.PHONY: all
69all: ${TARGET}
70
71${TARGET}: ${OBJS}
72 ${Q1}echo "${CXX}: $@"
73 ${Q2}${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
74
75# rule to make a depend file from a .cpp
76%.d: %.cpp
77 ${Q1}echo "DEP: $@"
78 ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
79
80# rule to make an object file from a .cpp
81%.o: %.cpp
82 ${Q1}echo "${CXX}: $@"
83 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
84
85
86.PHONY: clean
87clean:
88 ${Q1}echo "CLEAN: OBJS"
89 ${Q2}rm -f ${OBJS}
90 ${Q1}echo "CLEAN: TARGET"
91 ${Q2}rm -f ${TARGET}
92
93.PHONY: distclean
94distclean: clean
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
99
100tags: ${SRCS}
101 ctags $^
102
103tar:
104 ${Q1}echo "tar: physics.tar.bz2"
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
109
110git-tar:
111 ${Q1}echo "git-archive: ../physics.tar.bz2"
112 ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
113
114.PHONY: run
115run: all
116 ${TARGET}
117
118.PHONY: val
119val: all
120 valgrind --leak-check=full ${TARGET}
121
122.PHONY: prof
123prof: all
124 ${TARGET}
125 gprof -b ${TARGET} > prof
126 kprof -f prof
127
128-include ${DEPENDS}