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