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