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