Commit | Line | Data |
---|---|---|
ad9f1fb6 | 1 | |
67b5017f | 2 | LIBGL := -lGL -lGLU |
44b079f8 | 3 | LIBSDL := `sdl-config --libs` |
67b5017f | 4 | LIBS := ${LIBSDL} ${LIBGL} |
44b079f8 PG |
5 | |
6 | OPTFLAGS := -O2 | |
7 | DBGFLAGS := -ggdb | |
8 | PRFFLAGS := ${DBGFLAGS} -pg | |
a5aefcc6 | 9 | MYFLAGS := -Wall -pedantic -ansi |
ad9f1fb6 | 10 | |
88e62c4f | 11 | VALFLAGS := --leak-check=full |
4e77f48b | 12 | CXXFLAGS := ${MYFLAGS} ${DBGFLAGS} |
88e62c4f | 13 | |
9d5863c5 | 14 | CXX := g++ |
ad9f1fb6 | 15 | |
0376f786 | 16 | DIRS := # := start |
e8deb7b6 PG |
17 | DIRS += ./ |
18 | DIRS += Entities/ | |
19 | DIRS += GameStates/ | |
20 | DIRS += Effects/ | |
21 | DIRS += config/ | |
22 | DIRS += input/ | |
23 | DIRS += graphics/ | |
3bccd1d7 | 24 | DIRS += locks/ |
0376f786 | 25 | |
869b3330 | 26 | SRCS := # := start |
0376f786 | 27 | include $(addsuffix /files.mk,${DIRS}) |
44b079f8 | 28 | |
4e77f48b | 29 | WORKINGDIR := ../bind/ |
869b3330 | 30 | |
4e77f48b | 31 | OBJSDIR := ../objsd/ |
67b5017f PG |
32 | OBJS := ${SRCS:.cpp=.o} |
33 | OBJS := $(addprefix ${OBJSDIR},${OBJS}) | |
f4b779e4 PG |
34 | |
35 | DEPSDIR := ../deps/ | |
67b5017f PG |
36 | DEPS := ${SRCS:.cpp=.d} |
37 | DEPS := $(addprefix ${DEPSDIR},${DEPS}) | |
ad9f1fb6 | 38 | |
869b3330 PG |
39 | CFGDIRNAME := configs/ |
40 | SRCCFGDIR := ../${CFGDIRNAME} | |
41 | DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME} | |
42 | ||
43 | CFGS := # := start | |
44 | CFGS += keys.cfg | |
45 | CFGS := $(addprefix ${DSTCFGDIR},${CFGS}) | |
46 | ||
9d5863c5 PG |
47 | TARGETNAME := run_physics |
48 | TARGETTMP := ${OBJSDIR}${TARGETNAME} | |
49 | TARGET := ${WORKINGDIR}${TARGETNAME} | |
50 | ||
ebea1138 PG |
51 | DEPSBLDDIRS := $(addprefix ${DEPSDIR},${DIRS}) |
52 | OBJSBLDDIRS := $(addprefix ${OBJSDIR},${DIRS}) | |
869b3330 | 53 | BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${DSTCFGDIR} |
42f62a75 | 54 | |
ad9f1fb6 | 55 | |
393654cf PG |
56 | VERBOSE := 0 |
57 | ||
58 | ifeq (${VERBOSE},0) | |
59 | # quiet the echo command | |
60 | Q1 := @ | |
61 | # quiet the command that is `replaced' by an echo | |
62 | Q2 := @ | |
63 | else | |
64 | # EAT the echo command as if it was not there | |
65 | Q1 := @true # NOTE: the space between @true and the # is VERY important!! | |
66 | # do not quiet the command output | |
67 | Q2 := | |
68 | endif | |
ad9f1fb6 | 69 | |
046b034c | 70 | .PHONY: all |
869b3330 | 71 | all: ${TARGET} ${CFGS} |
37a74d97 | 72 | |
869b3330 PG |
73 | # how to link the main target |
74 | ${TARGETTMP}: ${OBJS} | |
75 | ${Q1}echo "${CXX}: $@" | |
76 | ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS} | |
ad9f1fb6 | 77 | |
9d5863c5 | 78 | # rule to copy tmp target to working directory |
ebea1138 | 79 | ${TARGET}: ${TARGETTMP} | ${WORKINGDIR} |
9d5863c5 | 80 | ${Q1}echo "cp: $@" |
37a74d97 | 81 | ${Q2}cp $< $@ |
9d5863c5 | 82 | |
42f62a75 PG |
83 | # how to make a directory |
84 | ${BLDDIRS}: | |
85 | ${Q2}mkdir -p $@ | |
86 | ||
869b3330 PG |
87 | # rule to make an object file from a .cpp |
88 | ${OBJSDIR}%.o: %.cpp | ${OBJSBLDDIRS} | |
89 | ${Q1}echo "${CXX}: $@" | |
90 | ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< | |
91 | ||
a4bb9ac2 | 92 | # rule to make a depend file from a .cpp |
ebea1138 | 93 | ${DEPSDIR}%.d: %.cpp | ${DEPSBLDDIRS} |
393654cf | 94 | ${Q1}echo "DEP: $@" |
a68587cf | 95 | ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@ |
ad9f1fb6 | 96 | |
869b3330 PG |
97 | # rule to copy the config files into the working directory |
98 | ${DSTCFGDIR}%.cfg: ${SRCCFGDIR}%.cfg | ${DSTCFGDIR} | |
99 | ${Q1}echo "cp: $@" | |
100 | ${Q2}cp $< $@ | |
054d658f | 101 | |
ad9f1fb6 | 102 | |
67b5017f PG |
103 | tags: ${SRCS} |
104 | ${Q1}echo "ctags: $@" | |
105 | ${Q2}ctags $^ | |
106 | ||
107 | ||
046b034c | 108 | .PHONY: clean |
ad9f1fb6 | 109 | clean: |
393654cf PG |
110 | ${Q1}echo "CLEAN: OBJS" |
111 | ${Q2}rm -f ${OBJS} | |
112 | ${Q1}echo "CLEAN: TARGET" | |
113 | ${Q2}rm -f ${TARGET} | |
ad9f1fb6 | 114 | |
046b034c | 115 | .PHONY: distclean |
ad9f1fb6 | 116 | distclean: clean |
f4b779e4 PG |
117 | ${Q1}echo "CLEAN: DEPS" |
118 | ${Q2}rm -f ${DEPS} | |
393654cf PG |
119 | ${Q1}echo "CLEAN: tags prof gmon.out" |
120 | ${Q2}rm -f tags prof gmon.out | |
ad9f1fb6 | 121 | |
d893cce2 PG |
122 | .PHONY: gitclean |
123 | gitclean: | |
124 | ${Q1}echo "git-clean: show, use gitcleanf to force" | |
125 | ${Q2}cd ..; git clean -nxd | |
126 | ||
127 | .PHONY: gitcleanf | |
128 | gitcleanf: | |
129 | ${Q1}echo "git-clean: forced" | |
130 | ${Q2}cd ..; git clean -fxd | |
131 | ||
7adc59fe | 132 | .PHONY: tar |
8381f595 PG |
133 | tar: ../physics.tar.bz2 |
134 | ||
135 | .PHONY: ../physics.tar.bz2 | |
136 | ../physics.tar.bz2: | |
137 | @echo "git-archive: Warning, archives HEAD not current" | |
a4bb9ac2 PG |
138 | ${Q1}echo "git-archive: ../physics.tar.bz2" |
139 | ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2 | |
ad9f1fb6 | 140 | |
046b034c PG |
141 | .PHONY: run |
142 | run: all | |
67b5017f | 143 | cd ${WORKINGDIR}; ./${TARGETNAME} |
ad9f1fb6 | 144 | |
6aad402a PG |
145 | .PHONY: gdb |
146 | gdb: all | |
67b5017f PG |
147 | cd ${WORKINGDIR}; gdb ${TARGETNAME} |
148 | ||
149 | .PHONY: cgdb | |
150 | cgdb: all | |
151 | cd ${WORKINGDIR}; cgdb ${TARGETNAME} | |
6aad402a | 152 | |
63a52c99 PG |
153 | .PHONY: val |
154 | val: all | |
823da4ea | 155 | cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME} |
63a52c99 PG |
156 | |
157 | .PHONY: prof | |
67b5017f PG |
158 | prof: run |
159 | cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > src/prof | |
63a52c99 | 160 | kprof -f prof |
ad9f1fb6 | 161 | |
4e77f48b | 162 | |
9d5863c5 PG |
163 | MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \ |
164 | "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \ | |
165 | "CXXFLAGS := ${OPTFLAGS}" \ | |
166 | "CXX := mingw32-g++" \ | |
167 | "OBJSDIR := ../objs-mingw32/" \ | |
e8deb7b6 | 168 | "WORKINGDIR := ../bin-mingw32/" \ |
9d5863c5 PG |
169 | "TARGETNAME := run_physics.exe" |
170 | ||
171 | .PHONY: mingw32 | |
172 | mingw32: | |
173 | ${Q1}echo "make: mingw32" | |
174 | ${Q2}${MAKE} ${MINGMAKEARGS} clean all | |
175 | ||
4e77f48b PG |
176 | FINALMAKEARGS := "CXXFLAGS := ${OPTFLAGS}" \ |
177 | "OBJSDIR := ../objs/" \ | |
178 | "WORKINGDIR := ../bin/" | |
179 | ||
180 | .PHONY: final | |
181 | final: | |
182 | ${Q1}echo "make: final" | |
183 | ${Q2}${MAKE} ${FINALMAKEARGS} clean all | |
184 | ||
f4b779e4 | 185 | -include ${DEPS} |