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}
31 else ifeq (${FINAL},1)
32 CXXFLAGS := ${OPTFLAGS}
34 CXXFLAGS := ${MYFLAGS} ${DBGFLAGS}
49 OBJSDIR := objs-mingw32/
50 else ifeq (${FINAL},1)
60 # include all of the dir.mk
62 include ${SRCSDIR}${DIRMK}
65 WORKINGDIR := bin-mingw32/
66 else ifeq (${FINAL},1)
72 CFGDIRNAME := configs/
73 SRCCFGDIR := ${CFGDIRNAME}
74 DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME}
78 CFGS := $(addprefix ${DSTCFGDIR},${CFGS})
81 SRCLIBSDIR := ${LIBSDIRNAME}
82 DSTLIBSDIR := ${WORKINGDIR}${LIBSDIRNAME}
85 LIBSTXT += COPYING-SDL
87 LIBSTXT += VERSION-SDL
88 LIBSTXT := $(addprefix ${DSTLIBSDIR},${LIBSTXT})
94 LIBSCPY += libSDL-1.2.so.0
97 LIBSCPY := $(addprefix ${DSTLIBSDIR},${LIBSCPY})
100 DSTTXTDIR := ${WORKINGDIR}
104 TXT := $(addprefix ${DSTTXTDIR},${TXT})
107 TARGETNAME := run_physics.exe
109 TARGETNAME := run_physics
111 TARGETTMP := ${OBJSDIR}${TARGETNAME}
112 TARGET := ${WORKINGDIR}${TARGETNAME}
114 DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS})
115 OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS})
117 BLDDIRS := # := start
118 BLDDIRS += ${OBJSBLDDIRS}
119 BLDDIRS += ${DEPSBLDDIRS}
120 BLDDIRS += ${WORKINGDIR}
121 BLDDIRS += ${DSTCFGDIR}
122 BLDDIRS += ${DSTLIBSDIR}
124 INCDIRS := ${SRCSDIR}
125 INCFLAGS := $(addprefix -I, ${INCDIRS})
128 PRNTFMT := printf "%-5s: %s\n"
133 # quiet the printf command
135 # quiet the command that is `replaced' by an echo
138 # EAT the printf command as if it was not there
139 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
140 # do not quiet the command output
145 all: ${TARGET} ${CFGS} ${LIBSTXT} ${LIBSCPY} ${TXT}
147 # cause the fancy $$ directory rules to work out
150 # how to link the main target
151 ${TARGETTMP}: ${OBJS}
152 ${Q1}${PRNTFMT} "${CXX}" "$@"
153 ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS}
155 # rule to copy tmp target to working directory
156 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
157 ${Q1}${PRNTFMT} "cp" "$@"
160 # rule to copy the config files into the working directory
161 ${DSTCFGDIR}%: ${SRCCFGDIR}% | $$(dir $$@)
162 ${Q1}${PRNTFMT} "cp" "$@"
165 # rule to copy the library files into the working directory
166 ${DSTLIBSDIR}%: ${SRCLIBSDIR}% | $$(dir $$@)
167 ${Q1}${PRNTFMT} "cp" "$@"
170 # rule to copy the library files into the working directory
171 ${DSTTXTDIR}%: ${SRCTXTDIR}% | $$(dir $$@)
172 ${Q1}${PRNTFMT} "cp" "$@"
175 # how to make a directory
177 ${Q1}${PRNTFMT} "mkdir" "$@"
180 # rule to make an object file from a .cpp
181 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@)
182 ${Q1}${PRNTFMT} "${CXX}" "$@"
183 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< ${INCFLAGS}
185 # rule to make a depend file from a .cpp
186 # be clever and escape the / chars in file paths
187 # DON'T simply use another sed delimiter or it can't appear in the file paths
188 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@)
189 ${Q1}${PRNTFMT} "DEP" "$@"
190 ${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | \
191 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
193 CLEANCMDS := cleanbin cleanobjs cleandeps clean cleanall
197 ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
198 ${Q2}rm -rf ${WORKINGDIR}
202 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
203 ${Q2}rm -rf ${OBJSDIR}
207 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
208 ${Q2}rm -rf ${DEPSDIR}
212 ${Q1}${PRNTFMT} "rm" "${TARGET}"
213 ${Q2}rm -rf ${TARGET}
216 cleanall: clean cleanbin cleandeps
220 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
225 ${Q1}${PRNTFMT} "git clean" "forcing"
231 .PHONY: physics.tar.bz2
233 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
234 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
235 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
240 cd ${WORKINGDIR}; wine ${TARGETNAME}
242 cd ${WORKINGDIR}; ./${TARGETNAME}
247 cd ${WORKINGDIR}; gdb ${TARGETNAME}
251 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
255 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
259 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
260 cd ${WORKINGDIR}; kprof -f prof
263 # Do not include deps files when doing a _single_ clean operation
264 ifeq ($(findstring ${MAKECMDGOALS},${CLEANCMDS}),)