change tar system, basic would fail as it does not include needed directories or...
[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 OBJSDIR := ../objs/
53 OBJS := ${SRCS:.cpp=.o}
54 OBJS := $(addprefix ${OBJSDIR},${OBJS})
55
56 DEPSDIR := ../deps/
57 DEPS := ${SRCS:.cpp=.d}
58 DEPS := $(addprefix ${DEPSDIR},${DEPS})
59
60 HRDS := ${SRCS:.cpp=.h}
61 HRDS := ${HRDS:main.h=} # remove main.h
62 HRDS += debug.h
63
64 HRDS += graphics/colors.h
65
66 TARS := ${SRCS} ${HRDS} Makefile
67
68
69 VERBOSE := 0
70
71 ifeq (${VERBOSE},0)
72     # quiet the echo command
73     Q1 := @
74     # quiet the command that is `replaced' by an echo
75     Q2 := @
76 else
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 :=
81 endif
82
83 .PHONY: all
84 all: ${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
102 clean:
103         ${Q1}echo "CLEAN: OBJS"
104         ${Q2}rm -f ${OBJS}
105         ${Q1}echo "CLEAN: TARGET"
106         ${Q2}rm -f ${TARGET}
107
108 .PHONY: distclean
109 distclean: 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
115 tags: ${SRCS}
116         ctags $^
117
118 .PHONY: tar
119 tar: ../physics.tar.bz2
120
121 .PHONY: ../physics.tar.bz2
122 ../physics.tar.bz2:
123         @echo "git-archive: Warning, archives HEAD not current"
124         ${Q1}echo "git-archive: ../physics.tar.bz2"
125         ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
126
127 .PHONY: run
128 run: all
129         ${TARGET}
130
131 .PHONY: gdb
132 gdb: all
133         gdb ${TARGET}
134
135 .PHONY: val
136 val: all
137         valgrind ${VALFLAGS} ${TARGET}
138
139 .PHONY: prof
140 prof: all
141         ${TARGET}
142         gprof -b ${TARGET} > prof
143         kprof -f prof
144
145 -include ${DEPS}