2 # set this on the command line to 1 to get a windows 32 build
5 # set this on the command line to 1 to get a final (none debug) build
10 LIBGL := -lopengl32 -lglu32
11 LIBSDL := `/usr/mingw32/bin/sdl-config --libs`
14 LIBSDL := `sdl-config --libs`
17 LIBS := ${LIBSDL} ${LIBGL} ${LIBMY}
21 PRFFLAGS := ${DBGFLAGS} -pg
22 MYFLAGS := -Wall -pedantic -ansi
26 VALFLAGS := --leak-check=full
27 LNKFLAGS := -Wl,-rpath,${RPATH}
30 CXXFLAGS := ${OPTFLAGS}
33 CXXFLAGS := ${OPTFLAGS}
35 CXXFLAGS := ${MYFLAGS} ${DBGFLAGS}
51 OBJSDIR := objs-mingw32/
64 # include all of the dir.mk
66 include ${SRCSDIR}${DIRMK}
69 WORKINGDIR := bin-mingw32/
78 CFGDIRNAME := configs/
79 SRCCFGDIR := ${CFGDIRNAME}
80 DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME}
84 CFGS := $(addprefix ${DSTCFGDIR},${CFGS})
87 SRCLIBSDIR := ${LIBSDIRNAME}
89 DSTLIBSDIR := ${WORKINGDIR}
91 DSTLIBSDIR := ${WORKINGDIR}${LIBSDIRNAME}
95 LIBSTXT += COPYING-SDL
97 LIBSTXT += VERSION-SDL
98 LIBSTXT := $(addprefix ${DSTLIBSDIR},${LIBSTXT})
100 LIBSCPY := # := start
105 LIBSCPY += libSDL-1.2.so.0
106 LIBSCPY += libpg.so.0
108 LIBSCPY := $(addprefix ${DSTLIBSDIR},${LIBSCPY})
111 DSTTXTDIR := ${WORKINGDIR}
115 TXT := $(addprefix ${DSTTXTDIR},${TXT})
118 TARGETNAME := run_physics.exe
120 TARGETNAME := run_physics
122 TARGETTMP := ${OBJSDIR}${TARGETNAME}
123 TARGET := ${WORKINGDIR}${TARGETNAME}
125 DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS})
126 OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS})
128 BLDDIRS := # := start
129 BLDDIRS += ${OBJSBLDDIRS}
130 BLDDIRS += ${DEPSBLDDIRS}
131 BLDDIRS += ${WORKINGDIR}
132 BLDDIRS += ${DSTCFGDIR}
133 BLDDIRS += ${DSTLIBSDIR}
134 BLDDIRS := $(sort ${BLDDIRS}) # remove possible duplicates
136 INCDIRS := ${SRCSDIR}
137 INCFLAGS := $(addprefix -I, ${INCDIRS})
141 PRNTFMT := printf "%-12s: %s\n"
143 PRNTFMT := printf "%-8s: %s\n"
149 # quiet the printf command
151 # quiet the command that is `replaced' by an echo
154 # EAT the printf command as if it was not there
155 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
156 # do not quiet the command output
161 all: ${TARGET} ${CFGS} ${LIBSTXT} ${LIBSCPY} ${TXT}
163 # cause the fancy $$ directory rules to work out
166 # how to link the main target
167 ${TARGETTMP}: ${OBJS}
168 ${Q1}${PRNTFMT} "${CXX}" "$@"
169 ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS}
171 # rule to copy tmp target to working directory
172 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
173 ${Q1}${PRNTFMT} "cp" "$@"
176 # rule to copy the config files into the working directory
177 ${DSTCFGDIR}%: ${SRCCFGDIR}% | $$(dir $$@)
178 ${Q1}${PRNTFMT} "cp" "$@"
181 # rule to copy the library files into the working directory
182 ${DSTLIBSDIR}%: ${SRCLIBSDIR}% | $$(dir $$@)
183 ${Q1}${PRNTFMT} "cp" "$@"
186 # rule to copy the library files into the working directory
187 ${DSTTXTDIR}%: ${SRCTXTDIR}% | $$(dir $$@)
188 ${Q1}${PRNTFMT} "cp" "$@"
191 # how to make a directory
193 ${Q1}${PRNTFMT} "mkdir" "$@"
196 # rule to make an object file from a .cpp
197 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@)
198 ${Q1}${PRNTFMT} "${CXX}" "$@"
199 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< ${INCFLAGS}
201 # rule to make a depend file from a .cpp
202 # be clever and escape the / chars in file paths
203 # DON'T simply use another sed delimiter or it can't appear in the file paths
204 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@)
205 ${Q1}${PRNTFMT} "DEP" "$@"
206 ${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | \
207 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
209 CLEANCMDS := cleanbin cleanobjs cleandeps clean cleanall
213 ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
214 ${Q2}rm -rf ${WORKINGDIR}
218 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
219 ${Q2}rm -rf ${OBJSDIR}
223 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
224 ${Q2}rm -rf ${DEPSDIR}
228 ${Q1}${PRNTFMT} "rm" "${TARGET}"
229 ${Q2}rm -rf ${TARGET}
232 cleanall: clean cleanbin cleandeps
236 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
241 ${Q1}${PRNTFMT} "git clean" "forcing"
247 .PHONY: physics.tar.bz2
249 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
250 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
251 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
256 cd ${WORKINGDIR}; wine ${TARGETNAME}
258 cd ${WORKINGDIR}; ./${TARGETNAME}
263 cd ${WORKINGDIR}; gdb ${TARGETNAME}
267 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
271 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
275 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
276 cd ${WORKINGDIR}; kprof -f prof
279 # Do not include deps files when doing a _single_ clean operation
280 ifeq ($(findstring ${MAKECMDGOALS},${CLEANCMDS}),)