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" "$@"
112 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
113 ${Q2}rm -rf ${OBJSDIR}
114 ${Q1}${PRNTFMT} "rm" "${TARGET} ${TARGETTMP}"
119 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
120 ${Q2}rm -rf ${DEPSDIR}
121 ${Q1}${PRNTFMT} "rm" "tags prof gmon.out"
122 ${Q2}rm -f tags prof gmon.out
126 ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
131 ${Q1}${PRNTFMT} "git clean" "forcing"
137 .PHONY: physics.tar.bz2
139 @${PRNTFMT} "git archive" "Warning, archives HEAD not current"
140 ${Q1}${PRNTFMT} "git archive" "physics.tar.bz2"
141 ${Q2}git archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
145 cd ${WORKINGDIR}; ./${TARGETNAME}
149 cd ${WORKINGDIR}; gdb ${TARGETNAME}
153 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
157 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
161 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
162 cd ${WORKINGDIR}; kprof -f prof
165 MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \
166 "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \
167 "CXXFLAGS := ${OPTFLAGS}" \
168 "CXX := mingw32-g++" \
169 "OBJSDIR := objs-mingw32/" \
170 "WORKINGDIR := bin-mingw32/" \
171 "TARGETNAME := run_physics.exe"
175 ${Q1}${PRNTFMT} "make" "mingw32"
176 ${Q2}${MAKE} ${MINGMAKEARGS} clean all
178 FINALMAKEARGS := "CXXFLAGS := ${OPTFLAGS}" \
184 ${Q1}${PRNTFMT} "make" "final"
185 ${Q2}${MAKE} ${FINALMAKEARGS} clean all