more Makefile cleaning
[physics.git] / src / Makefile
CommitLineData
ad9f1fb6 1
44b079f8
PG
2LIBGL := -lGL -lGLU
3LIBSDL := `sdl-config --libs`
4LIBS := ${LIBSDL} ${LIBGL}
5
6OPTFLAGS := -O2
7DBGFLAGS := -ggdb
8PRFFLAGS := ${DBGFLAGS} -pg
9
10#CXX := g++
11CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
ad9f1fb6 12
a4bb9ac2 13TARGET := ../run_physics
ad9f1fb6 14
a4bb9ac2
PG
15SRCS := # simply to keep every line below the same
16SRCS += entityManager.cpp
054d658f 17SRCS += entityCreator.cpp
046b034c 18SRCS += game.cpp
046b034c
PG
19SRCS += main.cpp
20SRCS += mathw.cpp
21SRCS += ticks.cpp
22SRCS += Vector2.cpp
23
24SRCS += Entities/Ball.cpp
25SRCS += Entities/Entity.cpp
26SRCS += Entities/Line.cpp
27SRCS += Entities/Particle.cpp
28SRCS += Entities/PhysicsEntity.cpp
29SRCS += Entities/Point.cpp
30SRCS += Entities/Polygon.cpp
31SRCS += Entities/WindParticle.cpp
32
33SRCS += GameStates/CreatingPolygon.cpp
34SRCS += GameStates/GameState.cpp
35SRCS += GameStates/Paused.cpp
36SRCS += GameStates/Running.cpp
37
f7b3b2eb
PG
38SRCS += input/inputManager.cpp
39
44b079f8
PG
40SRCS += graphics/graphics.cpp
41
42OBJS := ${SRCS:.cpp=.o}
a4bb9ac2 43DEPENDS := ${SRCS:.cpp=.d}
44b079f8 44
a4bb9ac2
PG
45HRDS := ${SRCS:.cpp=.h}
46HRDS := ${HRDS:main.h=} # remove main.h
47HRDS += debug.h
48HRDS += graphics/colors.h
49
50TARS := ${SRCS} ${HRDS} Makefile
ad9f1fb6 51
ad9f1fb6 52
393654cf
PG
53VERBOSE := 0
54
55ifeq (${VERBOSE},0)
56 # quiet the echo command
57 Q1 := @
58 # quiet the command that is `replaced' by an echo
59 Q2 := @
60else
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 :=
65endif
ad9f1fb6 66
046b034c
PG
67.PHONY: all
68all: ${TARGET}
ad9f1fb6 69
046b034c 70${TARGET}: ${OBJS}
393654cf
PG
71 ${Q1}echo "${CXX}: $@"
72 ${Q2}${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
ad9f1fb6 73
a4bb9ac2 74# rule to make a depend file from a .cpp
466ce08d 75%.d: %.cpp
393654cf
PG
76 ${Q1}echo "DEP: $@"
77 ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
ad9f1fb6 78
a4bb9ac2 79# rule to make an object file from a .cpp
054d658f 80%.o: %.cpp
393654cf
PG
81 ${Q1}echo "${CXX}: $@"
82 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
054d658f 83
ad9f1fb6 84
046b034c 85.PHONY: clean
ad9f1fb6 86clean:
393654cf
PG
87 ${Q1}echo "CLEAN: OBJS"
88 ${Q2}rm -f ${OBJS}
89 ${Q1}echo "CLEAN: TARGET"
90 ${Q2}rm -f ${TARGET}
ad9f1fb6 91
046b034c 92.PHONY: distclean
ad9f1fb6 93distclean: clean
393654cf
PG
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
ad9f1fb6 98
046b034c
PG
99tags: ${SRCS}
100 ctags $^
101
a4bb9ac2
PG
102tar:
103 ${Q1}echo "tar: physics.tar"
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
ad9f1fb6 108
a4bb9ac2
PG
109git-tar:
110 ${Q1}echo "git-archive: ../physics.tar.bz2"
111 ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
ad9f1fb6 112
046b034c
PG
113.PHONY: run
114run: all
27b74820 115 ${TARGET}
ad9f1fb6 116
63a52c99
PG
117.PHONY: val
118val: all
119 valgrind ${TARGET}
120
121.PHONY: prof
122prof: all
123 ${TARGET}
124 gprof -b ${TARGET} > prof
125 kprof -f prof
ad9f1fb6 126
466ce08d 127-include ${DEPENDS}