effectManager created
[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
10 #CXX := g++
11 CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
12
13 TARGET := ../run_physics
14
15 SRCS := # simply to keep every line below the same
16 SRCS += entityManager.cpp
17 SRCS += effectManager.cpp
18 SRCS += entityCreator.cpp
19 SRCS += game.cpp
20 SRCS += main.cpp
21 SRCS += mathw.cpp
22 SRCS += ticks.cpp
23 SRCS += Vector2.cpp
24 SRCS += handleSignal.cpp
25
26 SRCS += Entities/Ball.cpp
27 SRCS += Entities/Entity.cpp
28 SRCS += Entities/Line.cpp
29 SRCS += Entities/Particle.cpp
30 SRCS += Entities/PhysicsEntity.cpp
31 SRCS += Entities/Point.cpp
32 SRCS += Entities/Polygon.cpp
33 SRCS += Entities/WindParticle.cpp
34
35 SRCS += GameStates/CreatingPolygon.cpp
36 SRCS += GameStates/GameState.cpp
37 SRCS += GameStates/Paused.cpp
38 SRCS += GameStates/Running.cpp
39
40 SRCS += Effects/Effect.cpp
41 SRCS += Effects/Gravity.cpp
42
43 SRCS += input/inputManager.cpp
44
45 SRCS += graphics/graphics.cpp
46
47 OBJS := ${SRCS:.cpp=.o}
48 DEPENDS := ${SRCS:.cpp=.d}
49
50 HRDS := ${SRCS:.cpp=.h}
51 HRDS := ${HRDS:main.h=} # remove main.h
52 HRDS += debug.h
53
54 HRDS += graphics/colors.h
55
56 TARS := ${SRCS} ${HRDS} Makefile
57
58
59 VERBOSE := 0
60
61 ifeq (${VERBOSE},0)
62     # quiet the echo command
63     Q1 := @
64     # quiet the command that is `replaced' by an echo
65     Q2 := @
66 else
67     # EAT the echo command as if it was not there
68     Q1 := @true # NOTE: the space between @true and the # is VERY important!!
69     # do not quiet the command output
70     Q2 :=
71 endif
72
73 .PHONY: all
74 all: ${TARGET}
75
76 ${TARGET}: ${OBJS}
77         ${Q1}echo "${CXX}: $@"
78         ${Q2}${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
79
80 # rule to make a depend file from a .cpp
81 %.d: %.cpp
82         ${Q1}echo "DEP: $@"
83         ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
84
85 # rule to make an object file from a .cpp
86 %.o: %.cpp
87         ${Q1}echo "${CXX}: $@"
88         ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
89
90
91 .PHONY: clean
92 clean:
93         ${Q1}echo "CLEAN: OBJS"
94         ${Q2}rm -f ${OBJS}
95         ${Q1}echo "CLEAN: TARGET"
96         ${Q2}rm -f ${TARGET}
97
98 .PHONY: distclean
99 distclean: clean
100         ${Q1}echo "CLEAN: DEPENDS"
101         ${Q2}rm -f ${DEPENDS}
102         ${Q1}echo "CLEAN: tags prof gmon.out"
103         ${Q2}rm -f tags prof gmon.out
104
105 tags: ${SRCS}
106         ctags $^
107
108 tar:
109         ${Q1}echo "tar: physics.tar.bz2"
110         ${Q2}rm -f physics.tar # prevents appending
111         ${Q2}for f in ${TARS}; do\
112                 tar -C ../.. -rf physics.tar "physics/src/$$f"; done
113         ${Q2}bzip2 physics.tar
114
115 git-tar:
116         ${Q1}echo "git-archive: ../physics.tar.bz2"
117         ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
118
119 .PHONY: run
120 run: all
121         ${TARGET}
122
123 .PHONY: gdb
124 gdb: all
125         gdb ${TARGET}
126
127 .PHONY: val
128 val: all
129         valgrind --leak-check=full ${TARGET}
130
131 .PHONY: prof
132 prof: all
133         ${TARGET}
134         gprof -b ${TARGET} > prof
135         kprof -f prof
136
137 -include ${DEPENDS}