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 files.mk
30 include $(addprefix ${SRCSDIR},$(addsuffix files.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}
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}echo "${CXX}: $@"
79 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
81 # rule to copy tmp target to working directory
82 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
86 # how to make a directory
90 # rule to make an object file from a .cpp
91 ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | ${OBJSBLDDIRS}
92 ${Q1}echo "${CXX}: $@"
93 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
95 # rule to make a depend file from a .cpp
96 ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | ${DEPSBLDDIRS}
98 ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@
100 # rule to copy the config files into the working directory
101 ${DSTCFGDIR}%.cfg: ${SRCCFGDIR}%.cfg | ${DSTCFGDIR}
107 ${Q1}echo "ctags: $@"
113 ${Q1}echo "CLEAN: OBJS"
115 ${Q1}echo "CLEAN: TARGET"
120 ${Q1}echo "CLEAN: DEPS"
122 ${Q1}echo "CLEAN: tags prof gmon.out"
123 ${Q2}rm -f tags prof gmon.out
127 ${Q1}echo "git-clean: show, use gitcleanf to force"
128 ${Q2}cd ..; git clean -nxd
132 ${Q1}echo "git-clean: forced"
133 ${Q2}cd ..; git clean -fxd
136 tar: ../physics.tar.bz2
138 .PHONY: ../physics.tar.bz2
140 @echo "git-archive: Warning, archives HEAD not current"
141 ${Q1}echo "git-archive: ../physics.tar.bz2"
142 ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
146 cd ${WORKINGDIR}; ./${TARGETNAME}
150 cd ${WORKINGDIR}; gdb ${TARGETNAME}
154 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
158 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
162 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > src/prof
166 MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \
167 "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \
168 "CXXFLAGS := ${OPTFLAGS}" \
169 "CXX := mingw32-g++" \
170 "OBJSDIR := ../objs-mingw32/" \
171 "WORKINGDIR := ../bin-mingw32/" \
172 "TARGETNAME := run_physics.exe"
176 ${Q1}echo "make: mingw32"
177 ${Q2}${MAKE} ${MINGMAKEARGS} clean all
179 FINALMAKEARGS := "CXXFLAGS := ${OPTFLAGS}" \
180 "OBJSDIR := ../objs/" \
181 "WORKINGDIR := ../bin/"
185 ${Q1}echo "make: final"
186 ${Q2}${MAKE} ${FINALMAKEARGS} clean all