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}
88 DSTLIBSDIR := ${WORKINGDIR}${LIBSDIRNAME}
91 LIBSTXT += COPYING-SDL
93 LIBSTXT += VERSION-SDL
94 LIBSTXT := $(addprefix ${DSTLIBSDIR},${LIBSTXT})
100 LIBSCPY += libSDL-1.2.so.0
101 LIBSCPY += libpg.so.0
103 LIBSCPY := $(addprefix ${DSTLIBSDIR},${LIBSCPY})
106 DSTTXTDIR := ${WORKINGDIR}
110 TXT := $(addprefix ${DSTTXTDIR},${TXT})
113 TARGETNAME := run_physics.exe
115 TARGETNAME := run_physics
117 TARGETTMP := ${OBJSDIR}${TARGETNAME}
118 TARGET := ${WORKINGDIR}${TARGETNAME}
120 DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS})
121 OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS})
123 BLDDIRS := # := start
124 BLDDIRS += ${OBJSBLDDIRS}
125 BLDDIRS += ${DEPSBLDDIRS}
126 BLDDIRS += ${WORKINGDIR}
127 BLDDIRS += ${DSTCFGDIR}
128 BLDDIRS += ${DSTLIBSDIR}
130 INCDIRS := ${SRCSDIR}
131 INCFLAGS := $(addprefix -I, ${INCDIRS})
134 PRNTFMT := printf "%-5s: %s\n"
139 # quiet the printf command
141 # quiet the command that is `replaced' by an echo
144 # EAT the printf command as if it was not there
145 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
146 # do not quiet the command output
151 all: ${TARGET} ${CFGS} ${LIBSTXT} ${LIBSCPY} ${TXT}
153 # cause the fancy $$ directory rules to work out
156 # how to link the main target
157 ${TARGETTMP}: ${OBJS}
158 ${Q1}${PRNTFMT} "${CXX}" "$@"
159 ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS}
161 # rule to copy tmp target to working directory
162 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
163 ${Q1}${PRNTFMT} "cp" "$@"
166 # rule to copy the config files into the working directory
167 ${DSTCFGDIR}%: ${SRCCFGDIR}% | $$(dir $$@)
168 ${Q1}${PRNTFMT} "cp" "$@"
171 # rule to copy the library files into the working directory
172 ${DSTLIBSDIR}%: ${SRCLIBSDIR}% | $$(dir $$@)
173 ${Q1}${PRNTFMT} "cp" "$@"
176 # rule to copy the library files into the working directory
177 ${DSTTXTDIR}%: ${SRCTXTDIR}% | $$(dir $$@)
178 ${Q1}${PRNTFMT} "cp" "$@"
181 # how to make a directory
183 ${Q1}${PRNTFMT} "mkdir" "$@"
186 # rule to make an object file from a .cpp
187 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@)
188 ${Q1}${PRNTFMT} "${CXX}" "$@"
189 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< ${INCFLAGS}
191 # rule to make a depend file from a .cpp
192 # be clever and escape the / chars in file paths
193 # DON'T simply use another sed delimiter or it can't appear in the file paths
194 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@)
195 ${Q1}${PRNTFMT} "DEP" "$@"
196 ${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | \
197 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
199 CLEANCMDS := cleanbin cleanobjs cleandeps clean cleanall
203 ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
204 ${Q2}rm -rf ${WORKINGDIR}
208 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
209 ${Q2}rm -rf ${OBJSDIR}
213 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
214 ${Q2}rm -rf ${DEPSDIR}
218 ${Q1}${PRNTFMT} "rm" "${TARGET}"
219 ${Q2}rm -rf ${TARGET}
222 cleanall: clean cleanbin cleandeps
226 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
231 ${Q1}${PRNTFMT} "git clean" "forcing"
237 .PHONY: physics.tar.bz2
239 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
240 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
241 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
246 cd ${WORKINGDIR}; wine ${TARGETNAME}
248 cd ${WORKINGDIR}; ./${TARGETNAME}
253 cd ${WORKINGDIR}; gdb ${TARGETNAME}
257 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
261 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
265 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
266 cd ${WORKINGDIR}; kprof -f prof
269 # Do not include deps files when doing a _single_ clean operation
270 ifeq ($(findstring ${MAKECMDGOALS},${CLEANCMDS}),)