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