fixed depend mistake
[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 CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
10
11 VALFLAGS := --leak-check=full
12
13 TARGET := ../run_physics
14
15 SRCS := # simply to keep every line below the same
16
17 DIRS := # := start
18 DIRS += .
19 DIRS += Entities
20 DIRS += GameStates
21 DIRS += Effects
22 DIRS += config
23 DIRS += input
24 DIRS += graphics
25
26 include $(addsuffix /files.mk,${DIRS})
27
28 OBJSDIR := ../objs/
29 OBJS := ${SRCS:.cpp=.o}
30 OBJS := $(addprefix ${OBJSDIR},${OBJS})
31
32 DEPSDIR := ../deps/
33 DEPS := ${SRCS:.cpp=.d}
34 DEPS := $(addprefix ${DEPSDIR},${DEPS})
35
36 HRDS := ${SRCS:.cpp=.h}
37 HRDS := $(filter-out main.h,$HRDS) # remove main.h
38 HRDS += debug.h
39
40 HRDS += graphics/colors.h
41
42 TARS := ${SRCS} ${HRDS} Makefile
43
44
45 VERBOSE := 0
46
47 ifeq (${VERBOSE},0)
48     # quiet the echo command
49     Q1 := @
50     # quiet the command that is `replaced' by an echo
51     Q2 := @
52 else
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 :=
57 endif
58
59 .PHONY: all
60 all: ${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
78 clean:
79         ${Q1}echo "CLEAN: OBJS"
80         ${Q2}rm -f ${OBJS}
81         ${Q1}echo "CLEAN: TARGET"
82         ${Q2}rm -f ${TARGET}
83
84 .PHONY: distclean
85 distclean: 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
92 gitclean:
93         ${Q1}echo "git-clean: show, use gitcleanf to force"
94         ${Q2}cd ..; git clean -nxd
95
96 .PHONY: gitcleanf
97 gitcleanf:
98         ${Q1}echo "git-clean: forced"
99         ${Q2}cd ..; git clean -fxd
100
101 tags: ${SRCS}
102         ctags $^
103
104 .PHONY: tar
105 tar: ../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
114 run: all
115         cd ..; ./run_physics
116
117 .PHONY: gdb
118 gdb: all
119         gdb ${TARGET}
120
121 .PHONY: val
122 val: all
123         valgrind ${VALFLAGS} ${TARGET}
124
125 .PHONY: prof
126 prof: all
127         ${TARGET}
128         gprof -b ${TARGET} > prof
129         kprof -f prof
130
131 -include ${DEPS}