3 LIBSDL := `sdl-config --libs`
4 LIBS := ${LIBSDL} ${LIBGL} -lpg
8 PRFFLAGS := ${DBGFLAGS} -pg
9 MYFLAGS := -Wall -pedantic -ansi
13 VALFLAGS := --leak-check=full
14 CXXFLAGS := ${MYFLAGS} ${DBGFLAGS}
15 LNKFLAGS := -Wl,-rpath,${RPATH}
30 # include all of the dir.mk
32 include ${SRCSDIR}${DIRMK}
36 CFGDIRNAME := configs/
37 SRCCFGDIR := ${CFGDIRNAME}
38 DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME}
42 CFGS := $(addprefix ${DSTCFGDIR},${CFGS})
45 SRCLIBSDIR := ${LIBSDIRNAME}
46 DSTLIBSDIR := ${WORKINGDIR}${LIBSDIRNAME}
49 LIBSTXT += COPYING-SDL
51 LIBSTXT += VERSION-SDL
52 LIBSTXT := $(addprefix ${DSTLIBSDIR},${LIBSTXT})
55 LIBSCPY += libSDL-1.2.so.0
57 LIBSCPY := $(addprefix ${DSTLIBSDIR},${LIBSCPY})
60 DSTTXTDIR := ${WORKINGDIR}
64 TXT := $(addprefix ${DSTTXTDIR},${TXT})
66 TARGETNAME := run_physics
67 TARGETTMP := ${OBJSDIR}${TARGETNAME}
68 TARGET := ${WORKINGDIR}${TARGETNAME}
70 DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS})
71 OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS})
74 BLDDIRS += ${OBJSBLDDIRS}
75 BLDDIRS += ${DEPSBLDDIRS}
76 BLDDIRS += ${WORKINGDIR}
77 BLDDIRS += ${DSTCFGDIR}
78 BLDDIRS += ${DSTLIBSDIR}
81 INCFLAGS := $(addprefix -I, ${INCDIRS})
84 PRNTFMT := printf "%-5s: %s\n"
89 # quiet the printf command
91 # quiet the command that is `replaced' by an echo
94 # EAT the printf command as if it was not there
95 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
96 # do not quiet the command output
101 all: ${TARGET} ${CFGS} ${LIBSTXT} ${LIBSCPY} ${TXT}
103 # cause the fancy $$ directory rules to work out
106 # how to link the main target
107 ${TARGETTMP}: ${OBJS}
108 ${Q1}${PRNTFMT} "${CXX}" "$@"
109 ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS}
111 # rule to copy tmp target to working directory
112 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
113 ${Q1}${PRNTFMT} "cp" "$@"
116 # rule to copy the config files into the working directory
117 ${DSTCFGDIR}%: ${SRCCFGDIR}% | $$(dir $$@)
118 ${Q1}${PRNTFMT} "cp" "$@"
121 # rule to copy the library files into the working directory
122 ${DSTLIBSDIR}%: ${SRCLIBSDIR}% | $$(dir $$@)
123 ${Q1}${PRNTFMT} "cp" "$@"
126 # rule to copy the library files into the working directory
127 ${DSTTXTDIR}%: ${SRCTXTDIR}% | $$(dir $$@)
128 ${Q1}${PRNTFMT} "cp" "$@"
131 # how to make a directory
133 ${Q1}${PRNTFMT} "mkdir" "$@"
136 # rule to make an object file from a .cpp
137 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@)
138 ${Q1}${PRNTFMT} "${CXX}" "$@"
139 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< ${INCFLAGS}
141 # rule to make a depend file from a .cpp
142 # be clever and escape the / chars in file paths
143 # DON'T simply use another sed delimiter or it can't appear in the file paths
144 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@)
145 ${Q1}${PRNTFMT} "DEP" "$@"
146 ${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | \
147 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
151 ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
152 ${Q2}rm -rf ${WORKINGDIR}
156 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
157 ${Q2}rm -rf ${OBJSDIR}
161 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
162 ${Q2}rm -rf ${DEPSDIR}
168 cleanall: clean cleanbin cleandeps
172 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
177 ${Q1}${PRNTFMT} "git clean" "forcing"
183 .PHONY: physics.tar.bz2
185 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
186 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
187 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
191 cd ${WORKINGDIR}; ./${TARGETNAME}
195 cd ${WORKINGDIR}; gdb ${TARGETNAME}
199 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
203 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
207 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
208 cd ${WORKINGDIR}; kprof -f prof
211 MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \
212 "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \
213 "LIBSCPY := $(addprefix bin-mingw32/,SDL.dll)" \
214 "CXXFLAGS := ${OPTFLAGS}" \
215 "CXX := mingw32-g++" \
216 "OBJSDIR := objs-mingw32/" \
217 "WORKINGDIR := bin-mingw32/" \
218 "TARGETNAME := run_physics.exe"
222 ${Q1}${PRNTFMT} "make" "mingw32"
223 ${Q2}${MAKE} ${MINGMAKEARGS} cleanbin cleanobjs
224 ${Q2}${MAKE} ${MINGMAKEARGS} all
226 FINALMAKEARGS := "CXXFLAGS := ${OPTFLAGS}" \
232 ${Q1}${PRNTFMT} "make" "final"
233 ${Q2}${MAKE} ${FINALMAKEARGS} cleanbin cleanobjs
234 ${Q2}${MAKE} ${FINALMAKEARGS} all