3 LIBSDL := `sdl-config --libs`
4 LIBS := ${LIBSDL} ${LIBGL}
8 PRFFLAGS := ${DBGFLAGS} -pg
9 MYFLAGS := -Wall -pedantic -ansi
11 VALFLAGS := --leak-check=full
12 CXXFLAGS := ${MYFLAGS} ${DBGFLAGS}
27 # include all of the dir.mk
29 include ${SRCSDIR}${DIRMK}
33 CFGDIRNAME := configs/
34 SRCCFGDIR := ${CFGDIRNAME}
35 DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME}
39 CFGS := $(addprefix ${DSTCFGDIR},${CFGS})
42 DSTLIBSDIR := ${WORKINGDIR}
45 LIBSTXT += COPYING-SDL
47 LIBSTXT += VERSION-SDL
48 LIBSTXT := $(addprefix ${DSTLIBSDIR},${LIBSTXT})
52 LIBSCPY := $(addprefix ${DSTLIBSDIR},${LIBSCPY})
55 DSTTXTDIR := ${WORKINGDIR}
59 TXT := $(addprefix ${DSTTXTDIR},${TXT})
61 TARGETNAME := run_physics
62 TARGETTMP := ${OBJSDIR}${TARGETNAME}
63 TARGET := ${WORKINGDIR}${TARGETNAME}
65 DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS})
66 OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS})
67 BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${DSTCFGDIR}
72 PRNTFMT := printf "%-5s: %s\n"
77 # quiet the printf command
79 # quiet the command that is `replaced' by an echo
82 # EAT the printf command as if it was not there
83 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
84 # do not quiet the command output
89 all: ${TARGET} ${CFGS} ${LIBSTXT} ${LIBSCPY} ${TXT}
91 # cause the fancy $$ directory rules to work out
94 # how to link the main target
96 ${Q1}${PRNTFMT} "${CXX}" "$@"
97 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
99 # rule to copy tmp target to working directory
100 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
101 ${Q1}${PRNTFMT} "cp" "$@"
104 # rule to copy the config files into the working directory
105 ${DSTCFGDIR}%: ${SRCCFGDIR}% | $$(dir $$@)
106 ${Q1}${PRNTFMT} "cp" "$@"
109 # rule to copy the library files into the working directory
110 ${DSTLIBSDIR}%: ${SRCLIBSDIR}% | $$(dir $$@)
111 ${Q1}${PRNTFMT} "cp" "$@"
114 # rule to copy the library files into the working directory
115 ${DSTTXTDIR}%: ${SRCTXTDIR}% | $$(dir $$@)
116 ${Q1}${PRNTFMT} "cp" "$@"
119 # how to make a directory
121 ${Q1}${PRNTFMT} "mkdir" "$@"
124 # rule to make an object file from a .cpp
125 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@)
126 ${Q1}${PRNTFMT} "${CXX}" "$@"
127 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< -I "${INCDIRS}"
129 # rule to make a depend file from a .cpp
130 # be clever and escape the / chars in file paths
131 # DON'T simply use another sed delimiter or it can't appear in the file paths
132 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@)
133 ${Q1}${PRNTFMT} "DEP" "$@"
134 ${Q2}${CXX} -MM ${CXXFLAGS} $< -I "${INCDIRS}" | \
135 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
139 ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
140 ${Q2}rm -rf ${WORKINGDIR}
144 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
145 ${Q2}rm -rf ${OBJSDIR}
149 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
150 ${Q2}rm -rf ${DEPSDIR}
156 cleanall: clean cleanbin cleandeps
160 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
165 ${Q1}${PRNTFMT} "git clean" "forcing"
171 .PHONY: physics.tar.bz2
173 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
174 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
175 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
179 cd ${WORKINGDIR}; ./${TARGETNAME}
183 cd ${WORKINGDIR}; gdb ${TARGETNAME}
187 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
191 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
195 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
196 cd ${WORKINGDIR}; kprof -f prof
199 MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \
200 "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \
201 "LIBSCPY := $(addprefix bin-mingw32/,SDL.dll)" \
202 "CXXFLAGS := ${OPTFLAGS}" \
203 "CXX := mingw32-g++" \
204 "OBJSDIR := objs-mingw32/" \
205 "WORKINGDIR := bin-mingw32/" \
206 "TARGETNAME := run_physics.exe"
210 ${Q1}${PRNTFMT} "make" "mingw32"
211 ${Q2}${MAKE} ${MINGMAKEARGS} cleanbin cleanobjs
212 ${Q2}${MAKE} ${MINGMAKEARGS} all
214 FINALMAKEARGS := "CXXFLAGS := ${OPTFLAGS}" \
220 ${Q1}${PRNTFMT} "make" "final"
221 ${Q2}${MAKE} ${FINALMAKEARGS} cleanbin cleanobjs
222 ${Q2}${MAKE} ${FINALMAKEARGS} all