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})
41 TARGETNAME := run_physics
42 TARGETTMP := ${OBJSDIR}${TARGETNAME}
43 TARGET := ${WORKINGDIR}${TARGETNAME}
45 DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS})
46 OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS})
47 BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${DSTCFGDIR}
52 PRNTFMT := printf "%-5s: %s\n"
57 # quiet the printf command
59 # quiet the command that is `replaced' by an echo
62 # EAT the printf command as if it was not there
63 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
64 # do not quiet the command output
69 all: ${TARGET} ${CFGS}
71 # how to link the main target
73 ${Q1}${PRNTFMT} "${CXX}" "$@"
74 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
76 # rule to copy tmp target to working directory
77 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
78 ${Q1}${PRNTFMT} "cp" "$@"
81 # how to make a directory
83 ${Q1}${PRNTFMT} "mkdir" "$@"
86 #${SRCSDIR}%.cpp: ${SRCSDIR}%.h
88 # cause the below directory rules to work out
91 # rule to make an object file from a .cpp
92 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@)
93 ${Q1}${PRNTFMT} "${CXX}" "$@"
94 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< -I "${INCDIRS}"
96 # rule to make a depend file from a .cpp
97 # be clever and escape the / chars in file paths
98 # DON'T simply use another sed delimiter or it can't appear in the file paths
99 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@)
100 ${Q1}${PRNTFMT} "DEP" "$@"
101 ${Q2}${CXX} -MM ${CXXFLAGS} $< -I "${INCDIRS}" | \
102 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
104 # rule to copy the config files into the working directory
105 ${DSTCFGDIR}%.cfg: ${SRCCFGDIR}%.cfg | $$(dir $$@)
106 ${Q1}${PRNTFMT} "cp" "$@"
111 ${Q1}${PRNTFMT} "rm" "${TARGET} ${TARGETTMP}"
116 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
117 ${Q2}rm -rf ${OBJSDIR}
121 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
122 ${Q2}rm -rf ${DEPSDIR}
125 clean: cleantargets cleanobjs
128 cleanall: clean cleandeps
132 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
137 ${Q1}${PRNTFMT} "git clean" "forcing"
143 .PHONY: physics.tar.bz2
145 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
146 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
147 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
151 cd ${WORKINGDIR}; ./${TARGETNAME}
155 cd ${WORKINGDIR}; gdb ${TARGETNAME}
159 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
163 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
167 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
168 cd ${WORKINGDIR}; kprof -f prof
171 MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \
172 "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \
173 "CXXFLAGS := ${OPTFLAGS}" \
174 "CXX := mingw32-g++" \
175 "OBJSDIR := objs-mingw32/" \
176 "WORKINGDIR := bin-mingw32/" \
177 "TARGETNAME := run_physics.exe"
181 ${Q1}${PRNTFMT} "make" "mingw32"
182 ${Q2}${MAKE} ${MINGMAKEARGS} clean all
184 FINALMAKEARGS := "CXXFLAGS := ${OPTFLAGS}" \
190 ${Q1}${PRNTFMT} "make" "final"
191 ${Q2}${MAKE} ${FINALMAKEARGS} clean all