a2702ebbac6d403adba755970ef590c397d9737e
[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
14 SRCS := entityManager.cpp
15 SRCS += entityCreator.cpp
16 SRCS += game.cpp
17 SRCS += main.cpp
18 SRCS += mathw.cpp
19 SRCS += ticks.cpp
20 SRCS += Vector2.cpp
21
22 SRCS += Entities/Ball.cpp
23 SRCS += Entities/Entity.cpp
24 SRCS += Entities/Line.cpp
25 SRCS += Entities/Particle.cpp
26 SRCS += Entities/PhysicsEntity.cpp
27 SRCS += Entities/Point.cpp
28 SRCS += Entities/Polygon.cpp
29 SRCS += Entities/WindParticle.cpp
30
31 SRCS += GameStates/CreatingPolygon.cpp
32 SRCS += GameStates/GameState.cpp
33 SRCS += GameStates/Paused.cpp
34 SRCS += GameStates/Running.cpp
35
36 SRCS += input/inputManager.cpp
37
38 SRCS += graphics/graphics.cpp
39
40 OBJS := ${SRCS:.cpp=.o}
41
42
43 TARGET := ../run_physics
44 DEPENDS := ${SRCS:.cpp=.d}
45
46 VERBOSE := 0
47
48 ifeq (${VERBOSE},0)
49     # quiet the echo command
50     Q1 := @
51     # quiet the command that is `replaced' by an echo
52     Q2 := @
53 else
54     # EAT the echo command as if it was not there
55     Q1 := @true # NOTE: the space between @true and the # is VERY important!!
56     # do not quiet the command output
57     Q2 :=
58 endif
59
60 .PHONY: all
61 all: ${TARGET}
62
63 ${TARGET}: ${OBJS}
64         ${Q1}echo "${CXX}: $@"
65         ${Q2}${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
66
67 # how to make a depend file from a source file
68 %.d: %.cpp
69         ${Q1}echo "DEP: $@"
70         ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
71 #@${CXX} -M ${CXXFLAGS} $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
72
73 %.o: %.cpp
74         ${Q1}echo "${CXX}: $@"
75         ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
76
77
78 .PHONY: clean
79 clean:
80         ${Q1}echo "CLEAN: OBJS"
81         ${Q2}rm -f ${OBJS}
82         ${Q1}echo "CLEAN: TARGET"
83         ${Q2}rm -f ${TARGET}
84
85 .PHONY: distclean
86 distclean: clean
87         ${Q1}echo "CLEAN: DEPENDS"
88         ${Q2}rm -f ${DEPENDS}
89         ${Q1}echo "CLEAN: tags prof gmon.out"
90         ${Q2}rm -f tags prof gmon.out
91
92 tags: ${SRCS}
93         ctags $^
94
95 tar: clean
96         cd ..; tar -cjf physics.tar.bz2 src/
97
98
99 .PHONY: run
100 run: all
101         ${TARGET}
102
103 .PHONY: val
104 val: all
105         valgrind ${TARGET}
106
107 .PHONY: prof
108 prof: all
109         ${TARGET}
110         gprof -b ${TARGET} > prof
111         kprof -f prof
112
113 -include ${DEPENDS}