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}
29 # include all of the dir.mk
30 include $(addprefix ${SRCSDIR},$(addsuffix dir.mk,${DIRS}))
35 OBJS := ${SRCS:.cpp=.o}
36 OBJS := $(addprefix ${OBJSDIR},${OBJS})
39 DEPS := ${SRCS:.cpp=.d}
40 DEPS := $(addprefix ${DEPSDIR},${DEPS})
42 CFGDIRNAME := configs/
43 SRCCFGDIR := ${CFGDIRNAME}
44 DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME}
48 CFGS := $(addprefix ${DSTCFGDIR},${CFGS})
50 TARGETNAME := run_physics
51 TARGETTMP := ${OBJSDIR}${TARGETNAME}
52 TARGET := ${WORKINGDIR}${TARGETNAME}
54 DEPSBLDDIRS := $(addprefix ${DEPSDIR},${DIRS})
55 OBJSBLDDIRS := $(addprefix ${OBJSDIR},${DIRS})
56 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
92 # rule to make an object file from a .cpp
93 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | ${OBJSBLDDIRS}
94 ${Q1}${PRNTFMT} "${CXX}" "$@"
95 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
97 # rule to make a depend file from a .cpp
98 # be clever and escape the / chars in file paths
99 # DON'T simply use another sed delimiter or it can't appear in the file paths
100 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | ${DEPSBLDDIRS}
101 ${Q1}${PRNTFMT} "DEP" "$@"
102 ${Q2}${CXX} -MM ${CXXFLAGS} $< | \
103 sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
105 # rule to copy the config files into the working directory
106 ${DSTCFGDIR}%.cfg: ${SRCCFGDIR}%.cfg | ${DSTCFGDIR}
107 ${Q1}${PRNTFMT} "cp" "$@"
112 ${Q1}${PRNTFMT} "ctags" "$@"
118 ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
119 ${Q2}rm -rf ${OBJSDIR}
120 ${Q1}${PRNTFMT} "rm" "${TARGET} ${TARGETTMP}"
125 ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
126 ${Q2}rm -rf ${DEPSDIR}
127 ${Q1}${PRNTFMT} "rm" "tags prof gmon.out"
128 ${Q2}rm -f tags prof gmon.out
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} > src/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