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}
35 # include all of the dir.mk
36 include $(addprefix ${SRCSDIR},$(addsuffix dir.mk,${DIRS}))
40 CFGDIRNAME := configs/
41 SRCCFGDIR := ${CFGDIRNAME}
42 DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME}
46 CFGS := $(addprefix ${DSTCFGDIR},${CFGS})
48 TARGETNAME := run_physics
49 TARGETTMP := ${OBJSDIR}${TARGETNAME}
50 TARGET := ${WORKINGDIR}${TARGETNAME}
52 DEPSBLDDIRS := $(addprefix ${DEPSDIR},${DIRS})
53 OBJSBLDDIRS := $(addprefix ${OBJSDIR},${DIRS})
54 BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${DSTCFGDIR}
57 PRNTFMT := printf "%-5s: %s\n"
62 # quiet the echo command
64 # quiet the command that is `replaced' by an echo
67 # EAT the echo command as if it was not there
68 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
69 # do not quiet the command output
74 all: ${TARGET} ${CFGS}
76 # how to link the main target
78 ${Q1}${PRNTFMT} "${CXX}" "$@"
79 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
81 # rule to copy tmp target to working directory
82 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
83 ${Q1}${PRNTFMT} "cp" "$@"
86 # how to make a directory
90 # rule to make an object file from a .cpp
91 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | ${OBJSBLDDIRS}
92 ${Q1}${PRNTFMT} "${CXX}" "$@"
93 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
95 # rule to make a depend file from a .cpp
96 # be clever and escape the / chars in file paths
97 # DON'T simply use another sed delimiter or it can't appear in the file paths
98 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | ${DEPSBLDDIRS}
99 ${Q1}${PRNTFMT} "DEP" "$@"
100 ${Q2}${CXX} -MM ${CXXFLAGS} $< | \
101 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
103 # rule to copy the config files into the working directory
104 ${DSTCFGDIR}%.cfg: ${SRCCFGDIR}%.cfg | ${DSTCFGDIR}
105 ${Q1}${PRNTFMT} "cp" "$@"
110 ${Q1}${PRNTFMT} "ctags" "$@"
116 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
117 ${Q2}rm -rf ${OBJSDIR}
118 ${Q1}${PRNTFMT} "rm" "${TARGET} ${TARGETTMP}"
123 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
124 ${Q2}rm -rf ${DEPSDIR}
125 ${Q1}${PRNTFMT} "rm" "tags prof gmon.out"
126 ${Q2}rm -f tags prof gmon.out
130 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
135 ${Q1}${PRNTFMT} "git clean" "forcing"
141 .PHONY: physics.tar.bz2
143 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
144 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
145 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
149 cd ${WORKINGDIR}; ./${TARGETNAME}
153 cd ${WORKINGDIR}; gdb ${TARGETNAME}
157 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
161 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
165 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
166 cd ${WORKINGDIR}; kprof -f prof
169 MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \
170 "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \
171 "CXXFLAGS := ${OPTFLAGS}" \
172 "CXX := mingw32-g++" \
173 "OBJSDIR := objs-mingw32/" \
174 "WORKINGDIR := bin-mingw32/" \
175 "TARGETNAME := run_physics.exe"
179 ${Q1}${PRNTFMT} "make" "mingw32"
180 ${Q2}${MAKE} ${MINGMAKEARGS} clean all
182 FINALMAKEARGS := "CXXFLAGS := ${OPTFLAGS}" \
188 ${Q1}${PRNTFMT} "make" "final"
189 ${Q2}${MAKE} ${FINALMAKEARGS} clean all