10f3f93ce4dca8239b83c175eb36dd1d3174788c
[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
47 .PHONY: all
48 all: ${TARGET}
49
50 ${TARGET}: ${OBJS}
51         @echo "${CXX}: $@"
52         @${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
53
54 # how to make a depend file from a source file
55 %.d: %.cpp
56         @echo "DEP: $@"
57         @${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
58 #@${CXX} -M ${CXXFLAGS} $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
59
60 %.o: %.cpp
61         @echo "${CXX}: $@"
62         @${CXX} ${CXXFLAGS} -c -o $@ $<
63
64
65 .PHONY: clean
66 clean:
67         rm -f ${OBJS} ${TARGET}
68
69 .PHONY: distclean
70 distclean: clean
71         rm -f ${DEPENDS} tags prof gmon.out
72
73 tags: ${SRCS}
74         ctags $^
75
76 tar: clean
77         cd ..; tar -cjf physics.tar.bz2 src/
78
79
80 .PHONY: run
81 run: all
82         ${TARGET}
83
84 .PHONY: val
85 val: all
86         valgrind ${TARGET}
87
88 .PHONY: prof
89 prof: all
90         ${TARGET}
91         gprof -b ${TARGET} > prof
92         kprof -f prof
93
94 -include ${DEPENDS}