2 # set this on the command line to get a WIN32 or a FINAL build
7 LIBGL := -lopengl32 -lglu32
8 LIBSDL := `/usr/mingw32/bin/sdl-config --libs`
11 LIBSDL := `sdl-config --libs`
14 LIBS := ${LIBSDL} ${LIBGL} ${LIBMY}
18 PRFFLAGS := ${DBGFLAGS} -pg
19 MYFLAGS := -Wall -pedantic -ansi
23 VALFLAGS := --leak-check=full
24 LNKFLAGS := -Wl,-rpath,${RPATH}
27 CXXFLAGS := ${MYFLAGS} ${OPTFLAGS}
30 CXXFLAGS := ${MYFLAGS} ${OPTFLAGS}
32 CXXFLAGS := ${MYFLAGS} ${DBGFLAGS}
48 OBJSDIR := objs-mingw32/
61 # include all of the dir.mk
63 include ${SRCSDIR}${DIRMK}
66 WORKINGDIR := bin-mingw32/
75 CFGDIRNAME := configs/
76 SRCCFGDIR := ${CFGDIRNAME}
77 DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME}
81 CFGS := $(addprefix ${DSTCFGDIR},${CFGS})
84 SRCLIBSDIR := ${LIBSDIRNAME}
86 DSTLIBSDIR := ${WORKINGDIR}
88 DSTLIBSDIR := ${WORKINGDIR}${LIBSDIRNAME}
92 LIBSTXT += COPYING-SDL
94 LIBSTXT += VERSION-SDL
95 LIBSTXT := $(addprefix ${DSTLIBSDIR},${LIBSTXT})
102 LIBSCPY += libSDL-1.2.so.0
103 LIBSCPY += libbear.so.0
105 LIBSCPY := $(addprefix ${DSTLIBSDIR},${LIBSCPY})
108 DSTTXTDIR := ${WORKINGDIR}
112 TXT := $(addprefix ${DSTTXTDIR},${TXT})
114 ifeq (${BUILD},WIN32)
115 TARGETNAME := run_physics.exe
117 TARGETNAME := run_physics
119 TARGETTMP := ${OBJSDIR}${TARGETNAME}
120 TARGET := ${WORKINGDIR}${TARGETNAME}
122 DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS})
123 OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS})
125 BLDDIRS := # := start
126 BLDDIRS += ${OBJSBLDDIRS}
127 BLDDIRS += ${DEPSBLDDIRS}
128 BLDDIRS += ${WORKINGDIR}
129 BLDDIRS += ${DSTCFGDIR}
130 BLDDIRS += ${DSTLIBSDIR}
131 BLDDIRS := $(sort ${BLDDIRS}) # remove possible duplicates
133 INCDIRS := ${SRCSDIR}
134 INCFLAGS := $(addprefix -I, ${INCDIRS})
137 ifeq (${BUILD},WIN32)
138 PRNTFMT := printf "%-12s: %s\n"
140 PRNTFMT := printf "%-8s: %s\n"
146 # quiet the printf command
148 # quiet the command that is `replaced' by an echo
151 # EAT the printf command as if it was not there
152 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
153 # do not quiet the command output
158 all: ${TARGET} ${CFGS} ${LIBSTXT} ${LIBSCPY} ${TXT}
160 # cause the fancy $$ directory rules to work out
163 # how to link the main target
164 ${TARGETTMP}: ${OBJS}
165 ${Q1}${PRNTFMT} "${CXX}" "$@"
166 ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS}
168 # rule to copy tmp target to working directory
169 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
170 ${Q1}${PRNTFMT} "cp" "$@"
173 # rule to copy the config files into the working directory
174 ${DSTCFGDIR}%: ${SRCCFGDIR}% | $$(dir $$@)
175 ${Q1}${PRNTFMT} "cp" "$@"
178 # rule to copy the library files into the working directory
179 ${DSTLIBSDIR}%: ${SRCLIBSDIR}% | $$(dir $$@)
180 ${Q1}${PRNTFMT} "cp" "$@"
183 # rule to copy the library files into the working directory
184 ${DSTTXTDIR}%: ${SRCTXTDIR}% | $$(dir $$@)
185 ${Q1}${PRNTFMT} "cp" "$@"
188 # how to make a directory
190 ${Q1}${PRNTFMT} "mkdir" "$@"
193 # rule to make an object file from a .cpp
194 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@)
195 ${Q1}${PRNTFMT} "${CXX}" "$@"
196 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< ${INCFLAGS}
198 # rule to make a depend file from a .cpp
199 # be clever and escape the / chars in file paths
200 # DON'T simply use another sed delimiter or it can't appear in the file paths
201 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@)
202 ${Q1}${PRNTFMT} "DEP" "$@"
203 ${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | \
204 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
206 CLEANCMDS := cleanbin cleanobjs cleandeps clean cleanall
210 ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
211 ${Q2}rm -rf ${WORKINGDIR}
215 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
216 ${Q2}rm -rf ${OBJSDIR}
220 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
221 ${Q2}rm -rf ${DEPSDIR}
225 ${Q1}${PRNTFMT} "rm" "${TARGET}"
226 ${Q2}rm -rf ${TARGET}
229 cleanall: clean cleanbin cleandeps
233 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
238 ${Q1}${PRNTFMT} "git clean" "forcing"
244 .PHONY: physics.tar.bz2
246 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
247 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
248 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
253 cd ${WORKINGDIR}; wine ${TARGETNAME}
255 cd ${WORKINGDIR}; ./${TARGETNAME}
260 cd ${WORKINGDIR}; gdb ${TARGETNAME}
264 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
268 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
272 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
273 cd ${WORKINGDIR}; kprof -f prof
276 # Do not include deps files when doing a _single_ clean operation
277 ifeq ($(findstring ${MAKECMDGOALS},${CLEANCMDS}),)