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