Commit | Line | Data |
---|---|---|
ad9f1fb6 | 1 | |
44b079f8 PG |
2 | LIBGL := -lGL -lGLU |
3 | LIBSDL := `sdl-config --libs` | |
4 | LIBS := ${LIBSDL} ${LIBGL} | |
5 | ||
6 | OPTFLAGS := -O2 | |
7 | DBGFLAGS := -ggdb | |
8 | PRFFLAGS := ${DBGFLAGS} -pg | |
44b079f8 | 9 | CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS} |
ad9f1fb6 | 10 | |
88e62c4f PG |
11 | VALFLAGS := --leak-check=full |
12 | ||
a4bb9ac2 | 13 | TARGET := ../run_physics |
ad9f1fb6 | 14 | |
a4bb9ac2 | 15 | SRCS := # simply to keep every line below the same |
0376f786 PG |
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}) | |
44b079f8 | 27 | |
f4b779e4 | 28 | OBJSDIR := ../objs/ |
44b079f8 | 29 | OBJS := ${SRCS:.cpp=.o} |
f4b779e4 PG |
30 | OBJS := $(addprefix ${OBJSDIR},${OBJS}) |
31 | ||
32 | DEPSDIR := ../deps/ | |
33 | DEPS := ${SRCS:.cpp=.d} | |
34 | DEPS := $(addprefix ${DEPSDIR},${DEPS}) | |
44b079f8 | 35 | |
a4bb9ac2 | 36 | HRDS := ${SRCS:.cpp=.h} |
5d5a6f3f | 37 | HRDS := $(filter-out main.h,$HRDS) # remove main.h |
a4bb9ac2 | 38 | HRDS += debug.h |
ec70635e | 39 | |
a4bb9ac2 PG |
40 | HRDS += graphics/colors.h |
41 | ||
42 | TARS := ${SRCS} ${HRDS} Makefile | |
ad9f1fb6 | 43 | |
ad9f1fb6 | 44 | |
393654cf PG |
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 | |
ad9f1fb6 | 58 | |
046b034c PG |
59 | .PHONY: all |
60 | all: ${TARGET} | |
ad9f1fb6 | 61 | |
046b034c | 62 | ${TARGET}: ${OBJS} |
393654cf | 63 | ${Q1}echo "${CXX}: $@" |
eb0c55e7 | 64 | ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS} |
ad9f1fb6 | 65 | |
a4bb9ac2 | 66 | # rule to make a depend file from a .cpp |
f4b779e4 | 67 | ${DEPSDIR}%.d: %.cpp |
393654cf | 68 | ${Q1}echo "DEP: $@" |
a68587cf | 69 | ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@ |
ad9f1fb6 | 70 | |
a4bb9ac2 | 71 | # rule to make an object file from a .cpp |
f4b779e4 | 72 | ${OBJSDIR}%.o: %.cpp |
393654cf PG |
73 | ${Q1}echo "${CXX}: $@" |
74 | ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< | |
054d658f | 75 | |
ad9f1fb6 | 76 | |
046b034c | 77 | .PHONY: clean |
ad9f1fb6 | 78 | clean: |
393654cf PG |
79 | ${Q1}echo "CLEAN: OBJS" |
80 | ${Q2}rm -f ${OBJS} | |
81 | ${Q1}echo "CLEAN: TARGET" | |
82 | ${Q2}rm -f ${TARGET} | |
ad9f1fb6 | 83 | |
046b034c | 84 | .PHONY: distclean |
ad9f1fb6 | 85 | distclean: clean |
f4b779e4 PG |
86 | ${Q1}echo "CLEAN: DEPS" |
87 | ${Q2}rm -f ${DEPS} | |
393654cf PG |
88 | ${Q1}echo "CLEAN: tags prof gmon.out" |
89 | ${Q2}rm -f tags prof gmon.out | |
ad9f1fb6 | 90 | |
d893cce2 PG |
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 | ||
046b034c PG |
101 | tags: ${SRCS} |
102 | ctags $^ | |
103 | ||
7adc59fe | 104 | .PHONY: tar |
8381f595 PG |
105 | tar: ../physics.tar.bz2 |
106 | ||
107 | .PHONY: ../physics.tar.bz2 | |
108 | ../physics.tar.bz2: | |
109 | @echo "git-archive: Warning, archives HEAD not current" | |
a4bb9ac2 PG |
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 |
114 | run: all | |
b26d04ae | 115 | cd ..; ./run_physics |
ad9f1fb6 | 116 | |
6aad402a PG |
117 | .PHONY: gdb |
118 | gdb: all | |
119 | gdb ${TARGET} | |
120 | ||
63a52c99 PG |
121 | .PHONY: val |
122 | val: all | |
e861d993 | 123 | valgrind ${VALFLAGS} ${TARGET} |
63a52c99 PG |
124 | |
125 | .PHONY: prof | |
126 | prof: all | |
127 | ${TARGET} | |
128 | gprof -b ${TARGET} > prof | |
129 | kprof -f prof | |
ad9f1fb6 | 130 | |
f4b779e4 | 131 | -include ${DEPS} |