started smart includes
[physics.git] / src / Makefile
... / ...
CommitLineData
1
2LIBGL := -lGL -lGLU
3LIBSDL := `sdl-config --libs`
4LIBS := ${LIBSDL} ${LIBGL}
5
6OPTFLAGS := -O2
7DBGFLAGS := -ggdb
8PRFFLAGS := ${DBGFLAGS} -pg
9CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
10
11VALFLAGS := --leak-check=full
12
13TARGET := ../run_physics
14
15SRCS := # simply to keep every line below the same
16
17DIRS := # := start
18DIRS += .
19DIRS += Entities
20DIRS += GameStates
21DIRS += Effects
22DIRS += config
23DIRS += input
24DIRS += graphics
25
26include $(addsuffix /files.mk,${DIRS})
27
28OBJSDIR := ../objs/
29OBJS := ${SRCS:.cpp=.o}
30OBJS := $(addprefix ${OBJSDIR},${OBJS})
31
32DEPSDIR := ../deps/
33DEPS := ${SRCS:.cpp=.d}
34DEPS := $(addprefix ${DEPSDIR},${DEPS})
35
36HRDS := ${SRCS:.cpp=.h}
37HRDS := $(filter-out main.h,$HRDS) # remove main.h
38HRDS += debug.h
39
40HRDS += graphics/colors.h
41
42TARS := ${SRCS} ${HRDS} Makefile
43
44
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
58
59.PHONY: all
60all: ${TARGET}
61 echo "${SRCS}"
62 echo "${FILES}"
63
64${TARGET}: ${OBJS}
65 ${Q1}echo "${CXX}: $@"
66 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
67
68# rule to make a depend file from a .cpp
69${DEPSDIR}%.d: %.cpp
70 ${Q1}echo "DEP: $@"
71 ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
72
73# rule to make an object file from a .cpp
74${OBJSDIR}%.o: %.cpp
75 ${Q1}echo "${CXX}: $@"
76 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
77
78
79.PHONY: clean
80clean:
81 ${Q1}echo "CLEAN: OBJS"
82 ${Q2}rm -f ${OBJS}
83 ${Q1}echo "CLEAN: TARGET"
84 ${Q2}rm -f ${TARGET}
85
86.PHONY: distclean
87distclean: clean
88 ${Q1}echo "CLEAN: DEPS"
89 ${Q2}rm -f ${DEPS}
90 ${Q1}echo "CLEAN: tags prof gmon.out"
91 ${Q2}rm -f tags prof gmon.out
92
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
103tags: ${SRCS}
104 ctags $^
105
106.PHONY: tar
107tar: ../physics.tar.bz2
108
109.PHONY: ../physics.tar.bz2
110../physics.tar.bz2:
111 @echo "git-archive: Warning, archives HEAD not current"
112 ${Q1}echo "git-archive: ../physics.tar.bz2"
113 ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
114
115.PHONY: run
116run: all
117 cd ..; ./run_physics
118
119.PHONY: gdb
120gdb: all
121 gdb ${TARGET}
122
123.PHONY: val
124val: all
125 valgrind ${VALFLAGS} ${TARGET}
126
127.PHONY: prof
128prof: all
129 ${TARGET}
130 gprof -b ${TARGET} > prof
131 kprof -f prof
132
133-include ${DEPS}