started smart includes
[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
44b079f8 9CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
ad9f1fb6 10
88e62c4f
PG
11VALFLAGS := --leak-check=full
12
a4bb9ac2 13TARGET := ../run_physics
ad9f1fb6 14
a4bb9ac2 15SRCS := # simply to keep every line below the same
0376f786
PG
16
17DIRS := # := start
18DIRS += .
19DIRS += Entities
20DIRS += GameStates
21DIRS += Effects
22DIRS += config
23DIRS += input
24DIRS += graphics
25
26include $(addsuffix /files.mk,${DIRS})
44b079f8 27
f4b779e4 28OBJSDIR := ../objs/
44b079f8 29OBJS := ${SRCS:.cpp=.o}
f4b779e4
PG
30OBJS := $(addprefix ${OBJSDIR},${OBJS})
31
32DEPSDIR := ../deps/
33DEPS := ${SRCS:.cpp=.d}
34DEPS := $(addprefix ${DEPSDIR},${DEPS})
44b079f8 35
a4bb9ac2 36HRDS := ${SRCS:.cpp=.h}
5d5a6f3f 37HRDS := $(filter-out main.h,$HRDS) # remove main.h
a4bb9ac2 38HRDS += debug.h
ec70635e 39
a4bb9ac2
PG
40HRDS += graphics/colors.h
41
42TARS := ${SRCS} ${HRDS} Makefile
ad9f1fb6 43
ad9f1fb6 44
393654cf
PG
45VERBOSE := 0
46
47ifeq (${VERBOSE},0)
48 # quiet the echo command
49 Q1 := @
50 # quiet the command that is `replaced' by an echo
51 Q2 := @
52else
53 # EAT the echo command as if it was not there
54 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
55 # do not quiet the command output
56 Q2 :=
57endif
ad9f1fb6 58
046b034c
PG
59.PHONY: all
60all: ${TARGET}
0376f786
PG
61 echo "${SRCS}"
62 echo "${FILES}"
ad9f1fb6 63
046b034c 64${TARGET}: ${OBJS}
393654cf 65 ${Q1}echo "${CXX}: $@"
eb0c55e7 66 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
ad9f1fb6 67
a4bb9ac2 68# rule to make a depend file from a .cpp
f4b779e4 69${DEPSDIR}%.d: %.cpp
393654cf 70 ${Q1}echo "DEP: $@"
0376f786 71 ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
ad9f1fb6 72
a4bb9ac2 73# rule to make an object file from a .cpp
f4b779e4 74${OBJSDIR}%.o: %.cpp
393654cf
PG
75 ${Q1}echo "${CXX}: $@"
76 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
054d658f 77
ad9f1fb6 78
046b034c 79.PHONY: clean
ad9f1fb6 80clean:
393654cf
PG
81 ${Q1}echo "CLEAN: OBJS"
82 ${Q2}rm -f ${OBJS}
83 ${Q1}echo "CLEAN: TARGET"
84 ${Q2}rm -f ${TARGET}
ad9f1fb6 85
046b034c 86.PHONY: distclean
ad9f1fb6 87distclean: clean
f4b779e4
PG
88 ${Q1}echo "CLEAN: DEPS"
89 ${Q2}rm -f ${DEPS}
393654cf
PG
90 ${Q1}echo "CLEAN: tags prof gmon.out"
91 ${Q2}rm -f tags prof gmon.out
ad9f1fb6 92
d893cce2
PG
93.PHONY: gitclean
94gitclean:
95 ${Q1}echo "git-clean: show, use gitcleanf to force"
96 ${Q2}cd ..; git clean -nxd
97
98.PHONY: gitcleanf
99gitcleanf:
100 ${Q1}echo "git-clean: forced"
101 ${Q2}cd ..; git clean -fxd
102
046b034c
PG
103tags: ${SRCS}
104 ctags $^
105
7adc59fe 106.PHONY: tar
8381f595
PG
107tar: ../physics.tar.bz2
108
109.PHONY: ../physics.tar.bz2
110../physics.tar.bz2:
111 @echo "git-archive: Warning, archives HEAD not current"
a4bb9ac2
PG
112 ${Q1}echo "git-archive: ../physics.tar.bz2"
113 ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
ad9f1fb6 114
046b034c
PG
115.PHONY: run
116run: all
b26d04ae 117 cd ..; ./run_physics
ad9f1fb6 118
6aad402a
PG
119.PHONY: gdb
120gdb: all
121 gdb ${TARGET}
122
63a52c99
PG
123.PHONY: val
124val: all
e861d993 125 valgrind ${VALFLAGS} ${TARGET}
63a52c99
PG
126
127.PHONY: prof
128prof: all
129 ${TARGET}
130 gprof -b ${TARGET} > prof
131 kprof -f prof
ad9f1fb6 132
f4b779e4 133-include ${DEPS}