fixed depend mistake
[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
62${TARGET}: ${OBJS}
63 ${Q1}echo "${CXX}: $@"
64 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
65
66# rule to make a depend file from a .cpp
67${DEPSDIR}%.d: %.cpp
68 ${Q1}echo "DEP: $@"
69 ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@
70
71# rule to make an object file from a .cpp
72${OBJSDIR}%.o: %.cpp
73 ${Q1}echo "${CXX}: $@"
74 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
75
76
77.PHONY: clean
78clean:
79 ${Q1}echo "CLEAN: OBJS"
80 ${Q2}rm -f ${OBJS}
81 ${Q1}echo "CLEAN: TARGET"
82 ${Q2}rm -f ${TARGET}
83
84.PHONY: distclean
85distclean: clean
86 ${Q1}echo "CLEAN: DEPS"
87 ${Q2}rm -f ${DEPS}
88 ${Q1}echo "CLEAN: tags prof gmon.out"
89 ${Q2}rm -f tags prof gmon.out
90
91.PHONY: gitclean
92gitclean:
93 ${Q1}echo "git-clean: show, use gitcleanf to force"
94 ${Q2}cd ..; git clean -nxd
95
96.PHONY: gitcleanf
97gitcleanf:
98 ${Q1}echo "git-clean: forced"
99 ${Q2}cd ..; git clean -fxd
100
101tags: ${SRCS}
102 ctags $^
103
104.PHONY: tar
105tar: ../physics.tar.bz2
106
107.PHONY: ../physics.tar.bz2
108../physics.tar.bz2:
109 @echo "git-archive: Warning, archives HEAD not current"
110 ${Q1}echo "git-archive: ../physics.tar.bz2"
111 ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
112
113.PHONY: run
114run: all
115 cd ..; ./run_physics
116
117.PHONY: gdb
118gdb: all
119 gdb ${TARGET}
120
121.PHONY: val
122val: all
123 valgrind ${VALFLAGS} ${TARGET}
124
125.PHONY: prof
126prof: all
127 ${TARGET}
128 gprof -b ${TARGET} > prof
129 kprof -f prof
130
131-include ${DEPS}