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}
59 PRNTFMT := printf "%-5s: %s\n"
64 # quiet the echo command
66 # quiet the command that is `replaced' by an echo
69 # EAT the echo command as if it was not there
70 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
71 # do not quiet the command output
76 all: ${TARGET} ${CFGS}
78 # how to link the main target
80 ${Q1}${PRNTFMT} "${CXX}" "$@"
81 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
83 # rule to copy tmp target to working directory
84 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
85 ${Q1}${PRNTFMT} "cp" "$@"
88 # how to make a directory
90 ${Q1}${PRNTFMT} "mkdir" "$@"
93 # cause the below directory rules to work out
96 # rule to make an object file from a .cpp
97 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@)
98 ${Q1}${PRNTFMT} "${CXX}" "$@"
99 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< -I "${INCDIRS}"
101 # rule to make a depend file from a .cpp
102 # be clever and escape the / chars in file paths
103 # DON'T simply use another sed delimiter or it can't appear in the file paths
104 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@)
105 ${Q1}${PRNTFMT} "DEP" "$@"
106 ${Q2}${CXX} -MM ${CXXFLAGS} $< -I "${INCDIRS}" | \
107 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
109 # rule to copy the config files into the working directory
110 ${DSTCFGDIR}%.cfg: ${SRCCFGDIR}%.cfg | $$(dir $$@)
111 ${Q1}${PRNTFMT} "cp" "$@"
116 ${Q1}${PRNTFMT} "ctags" "$@"
122 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
123 ${Q2}rm -rf ${OBJSDIR}
124 ${Q1}${PRNTFMT} "rm" "${TARGET} ${TARGETTMP}"
129 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
130 ${Q2}rm -rf ${DEPSDIR}
131 ${Q1}${PRNTFMT} "rm" "tags prof gmon.out"
132 ${Q2}rm -f tags prof gmon.out
136 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
141 ${Q1}${PRNTFMT} "git clean" "forcing"
147 .PHONY: physics.tar.bz2
149 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
150 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
151 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
155 cd ${WORKINGDIR}; ./${TARGETNAME}
159 cd ${WORKINGDIR}; gdb ${TARGETNAME}
163 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
167 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
171 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
172 cd ${WORKINGDIR}; kprof -f prof
175 MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \
176 "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \
177 "CXXFLAGS := ${OPTFLAGS}" \
178 "CXX := mingw32-g++" \
179 "OBJSDIR := objs-mingw32/" \
180 "WORKINGDIR := bin-mingw32/" \
181 "TARGETNAME := run_physics.exe"
185 ${Q1}${PRNTFMT} "make" "mingw32"
186 ${Q2}${MAKE} ${MINGMAKEARGS} clean all
188 FINALMAKEARGS := "CXXFLAGS := ${OPTFLAGS}" \
194 ${Q1}${PRNTFMT} "make" "final"
195 ${Q2}${MAKE} ${FINALMAKEARGS} clean all