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`
16 LIBS := ${LIBSDL} ${LIBGL}
21 PRFFLAGS := ${DBGFLAGS} -pg
22 MYFLAGS := -Wall -pedantic -ansi
24 VALFLAGS := --leak-check=full
26 CXXFLAGS := ${OPTFLAGS}
27 else ifeq (${FINAL},1)
28 CXXFLAGS := ${OPTFLAGS}
30 CXXFLAGS := ${MYFLAGS} ${DBGFLAGS}
45 OBJSDIR := objs-mingw32/
46 else ifeq (${FINAL},1)
56 # include all of the dir.mk
58 include ${SRCSDIR}${DIRMK}
61 WORKINGDIR := bin-mingw32/
62 else ifeq (${FINAL},1)
68 CFGDIRNAME := configs/
69 SRCCFGDIR := ${CFGDIRNAME}
70 DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME}
74 CFGS := $(addprefix ${DSTCFGDIR},${CFGS})
77 DSTLIBSDIR := ${WORKINGDIR}
80 LIBSTXT += COPYING-SDL
82 LIBSTXT += VERSION-SDL
83 LIBSTXT := $(addprefix ${DSTLIBSDIR},${LIBSTXT})
91 LIBSCPY := $(addprefix ${DSTLIBSDIR},${LIBSCPY})
94 DSTTXTDIR := ${WORKINGDIR}
98 TXT := $(addprefix ${DSTTXTDIR},${TXT})
101 TARGETNAME := run_physics.exe
103 TARGETNAME := run_physics
105 TARGETTMP := ${OBJSDIR}${TARGETNAME}
106 TARGET := ${WORKINGDIR}${TARGETNAME}
108 DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS})
109 OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS})
110 BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${DSTCFGDIR}
112 INCDIRS := ${SRCSDIR}
115 PRNTFMT := printf "%-5s: %s\n"
120 # quiet the printf command
122 # quiet the command that is `replaced' by an echo
125 # EAT the printf command as if it was not there
126 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
127 # do not quiet the command output
132 all: ${TARGET} ${CFGS} ${LIBSTXT} ${LIBSCPY} ${TXT}
134 # cause the fancy $$ directory rules to work out
137 # how to link the main target
138 ${TARGETTMP}: ${OBJS}
139 ${Q1}${PRNTFMT} "${CXX}" "$@"
140 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
142 # rule to copy tmp target to working directory
143 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
144 ${Q1}${PRNTFMT} "cp" "$@"
147 # rule to copy the config files into the working directory
148 ${DSTCFGDIR}%: ${SRCCFGDIR}% | $$(dir $$@)
149 ${Q1}${PRNTFMT} "cp" "$@"
152 # rule to copy the library files into the working directory
153 ${DSTLIBSDIR}%: ${SRCLIBSDIR}% | $$(dir $$@)
154 ${Q1}${PRNTFMT} "cp" "$@"
157 # rule to copy the library files into the working directory
158 ${DSTTXTDIR}%: ${SRCTXTDIR}% | $$(dir $$@)
159 ${Q1}${PRNTFMT} "cp" "$@"
162 # how to make a directory
164 ${Q1}${PRNTFMT} "mkdir" "$@"
167 # rule to make an object file from a .cpp
168 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@)
169 ${Q1}${PRNTFMT} "${CXX}" "$@"
170 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< -I "${INCDIRS}"
172 # rule to make a depend file from a .cpp
173 # be clever and escape the / chars in file paths
174 # DON'T simply use another sed delimiter or it can't appear in the file paths
175 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@)
176 ${Q1}${PRNTFMT} "DEP" "$@"
177 ${Q2}${CXX} -MM ${CXXFLAGS} $< -I "${INCDIRS}" | \
178 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
180 CLEANCMDS := cleanbin cleanobjs cleandeps clean cleanall
184 ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
185 ${Q2}rm -rf ${WORKINGDIR}
189 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
190 ${Q2}rm -rf ${OBJSDIR}
194 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
195 ${Q2}rm -rf ${DEPSDIR}
199 ${Q1}${PRNTFMT} "rm" "${TARGET}"
200 ${Q2}rm -rf ${TARGET}
203 cleanall: clean cleanbin cleandeps
207 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
212 ${Q1}${PRNTFMT} "git clean" "forcing"
218 .PHONY: physics.tar.bz2
220 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
221 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
222 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
227 cd ${WORKINGDIR}; wine ${TARGETNAME}
229 cd ${WORKINGDIR}; ./${TARGETNAME}
234 cd ${WORKINGDIR}; gdb ${TARGETNAME}
238 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
242 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
246 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
247 cd ${WORKINGDIR}; kprof -f prof
250 # Do not include deps files when doing a _single_ clean operation
251 ifeq ($(findstring ${MAKECMDGOALS},${CLEANCMDS}),)