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 # cause the below directory rules to work out
89 # rule to make an object file from a .cpp
90 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@)
91 ${Q1}${PRNTFMT} "${CXX}" "$@"
92 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< -I "${INCDIRS}"
94 # rule to make a depend file from a .cpp
95 # be clever and escape the / chars in file paths
96 # DON'T simply use another sed delimiter or it can't appear in the file paths
97 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@)
98 ${Q1}${PRNTFMT} "DEP" "$@"
99 ${Q2}${CXX} -MM ${CXXFLAGS} $< -I "${INCDIRS}" | \
100 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
102 # rule to copy the config files into the working directory
103 ${DSTCFGDIR}%.cfg: ${SRCCFGDIR}%.cfg | $$(dir $$@)
104 ${Q1}${PRNTFMT} "cp" "$@"
109 ${Q1}${PRNTFMT} "ctags" "$@"
115 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
116 ${Q2}rm -rf ${OBJSDIR}
117 ${Q1}${PRNTFMT} "rm" "${TARGET} ${TARGETTMP}"
122 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
123 ${Q2}rm -rf ${DEPSDIR}
124 ${Q1}${PRNTFMT} "rm" "tags prof gmon.out"
125 ${Q2}rm -f tags prof gmon.out
129 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
134 ${Q1}${PRNTFMT} "git clean" "forcing"
140 .PHONY: physics.tar.bz2
142 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
143 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
144 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
148 cd ${WORKINGDIR}; ./${TARGETNAME}
152 cd ${WORKINGDIR}; gdb ${TARGETNAME}
156 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
160 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
164 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
165 cd ${WORKINGDIR}; kprof -f prof
168 MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \
169 "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \
170 "CXXFLAGS := ${OPTFLAGS}" \
171 "CXX := mingw32-g++" \
172 "OBJSDIR := objs-mingw32/" \
173 "WORKINGDIR := bin-mingw32/" \
174 "TARGETNAME := run_physics.exe"
178 ${Q1}${PRNTFMT} "make" "mingw32"
179 ${Q2}${MAKE} ${MINGMAKEARGS} clean all
181 FINALMAKEARGS := "CXXFLAGS := ${OPTFLAGS}" \
187 ${Q1}${PRNTFMT} "make" "final"
188 ${Q2}${MAKE} ${FINALMAKEARGS} clean all