created locks abstraction
[physics.git] / src / Makefile
CommitLineData
ad9f1fb6 1
67b5017f 2LIBGL := -lGL -lGLU
44b079f8 3LIBSDL := `sdl-config --libs`
67b5017f 4LIBS := ${LIBSDL} ${LIBGL}
44b079f8
PG
5
6OPTFLAGS := -O2
7DBGFLAGS := -ggdb
8PRFFLAGS := ${DBGFLAGS} -pg
a5aefcc6 9MYFLAGS := -Wall -pedantic -ansi
ad9f1fb6 10
88e62c4f 11VALFLAGS := --leak-check=full
4e77f48b 12CXXFLAGS := ${MYFLAGS} ${DBGFLAGS}
88e62c4f 13
9d5863c5 14CXX := g++
ad9f1fb6 15
0376f786 16DIRS := # := start
e8deb7b6
PG
17DIRS += ./
18DIRS += Entities/
19DIRS += GameStates/
20DIRS += Effects/
21DIRS += config/
22DIRS += input/
23DIRS += graphics/
3bccd1d7 24DIRS += locks/
0376f786 25
869b3330 26SRCS := # := start
0376f786 27include $(addsuffix /files.mk,${DIRS})
44b079f8 28
4e77f48b 29WORKINGDIR := ../bind/
869b3330 30
4e77f48b 31OBJSDIR := ../objsd/
67b5017f
PG
32OBJS := ${SRCS:.cpp=.o}
33OBJS := $(addprefix ${OBJSDIR},${OBJS})
f4b779e4
PG
34
35DEPSDIR := ../deps/
67b5017f
PG
36DEPS := ${SRCS:.cpp=.d}
37DEPS := $(addprefix ${DEPSDIR},${DEPS})
ad9f1fb6 38
869b3330
PG
39CFGDIRNAME := configs/
40SRCCFGDIR := ../${CFGDIRNAME}
41DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME}
42
43CFGS := # := start
44CFGS += keys.cfg
45CFGS := $(addprefix ${DSTCFGDIR},${CFGS})
46
9d5863c5
PG
47TARGETNAME := run_physics
48TARGETTMP := ${OBJSDIR}${TARGETNAME}
49TARGET := ${WORKINGDIR}${TARGETNAME}
50
ebea1138
PG
51DEPSBLDDIRS := $(addprefix ${DEPSDIR},${DIRS})
52OBJSBLDDIRS := $(addprefix ${OBJSDIR},${DIRS})
869b3330 53BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${DSTCFGDIR}
42f62a75 54
ad9f1fb6 55
393654cf
PG
56VERBOSE := 0
57
58ifeq (${VERBOSE},0)
59 # quiet the echo command
60 Q1 := @
61 # quiet the command that is `replaced' by an echo
62 Q2 := @
63else
64 # EAT the echo command as if it was not there
65 Q1 := @true # NOTE: the space between @true and the # is VERY important!!
66 # do not quiet the command output
67 Q2 :=
68endif
ad9f1fb6 69
046b034c 70.PHONY: all
869b3330 71all: ${TARGET} ${CFGS}
37a74d97 72
869b3330
PG
73# how to link the main target
74${TARGETTMP}: ${OBJS}
75 ${Q1}echo "${CXX}: $@"
76 ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
ad9f1fb6 77
9d5863c5 78# rule to copy tmp target to working directory
ebea1138 79${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
9d5863c5 80 ${Q1}echo "cp: $@"
37a74d97 81 ${Q2}cp $< $@
9d5863c5 82
42f62a75
PG
83# how to make a directory
84${BLDDIRS}:
85 ${Q2}mkdir -p $@
86
869b3330
PG
87# rule to make an object file from a .cpp
88${OBJSDIR}%.o: %.cpp | ${OBJSBLDDIRS}
89 ${Q1}echo "${CXX}: $@"
90 ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
91
a4bb9ac2 92# rule to make a depend file from a .cpp
ebea1138 93${DEPSDIR}%.d: %.cpp | ${DEPSBLDDIRS}
393654cf 94 ${Q1}echo "DEP: $@"
a68587cf 95 ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@
ad9f1fb6 96
869b3330
PG
97# rule to copy the config files into the working directory
98${DSTCFGDIR}%.cfg: ${SRCCFGDIR}%.cfg | ${DSTCFGDIR}
99 ${Q1}echo "cp: $@"
100 ${Q2}cp $< $@
054d658f 101
ad9f1fb6 102
67b5017f
PG
103tags: ${SRCS}
104 ${Q1}echo "ctags: $@"
105 ${Q2}ctags $^
106
107
046b034c 108.PHONY: clean
ad9f1fb6 109clean:
393654cf
PG
110 ${Q1}echo "CLEAN: OBJS"
111 ${Q2}rm -f ${OBJS}
112 ${Q1}echo "CLEAN: TARGET"
113 ${Q2}rm -f ${TARGET}
ad9f1fb6 114
046b034c 115.PHONY: distclean
ad9f1fb6 116distclean: clean
f4b779e4
PG
117 ${Q1}echo "CLEAN: DEPS"
118 ${Q2}rm -f ${DEPS}
393654cf
PG
119 ${Q1}echo "CLEAN: tags prof gmon.out"
120 ${Q2}rm -f tags prof gmon.out
ad9f1fb6 121
d893cce2
PG
122.PHONY: gitclean
123gitclean:
124 ${Q1}echo "git-clean: show, use gitcleanf to force"
125 ${Q2}cd ..; git clean -nxd
126
127.PHONY: gitcleanf
128gitcleanf:
129 ${Q1}echo "git-clean: forced"
130 ${Q2}cd ..; git clean -fxd
131
7adc59fe 132.PHONY: tar
8381f595
PG
133tar: ../physics.tar.bz2
134
135.PHONY: ../physics.tar.bz2
136../physics.tar.bz2:
137 @echo "git-archive: Warning, archives HEAD not current"
a4bb9ac2
PG
138 ${Q1}echo "git-archive: ../physics.tar.bz2"
139 ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
ad9f1fb6 140
046b034c
PG
141.PHONY: run
142run: all
67b5017f 143 cd ${WORKINGDIR}; ./${TARGETNAME}
ad9f1fb6 144
6aad402a
PG
145.PHONY: gdb
146gdb: all
67b5017f
PG
147 cd ${WORKINGDIR}; gdb ${TARGETNAME}
148
149.PHONY: cgdb
150cgdb: all
151 cd ${WORKINGDIR}; cgdb ${TARGETNAME}
6aad402a 152
63a52c99
PG
153.PHONY: val
154val: all
823da4ea 155 cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME}
63a52c99
PG
156
157.PHONY: prof
67b5017f
PG
158prof: run
159 cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > src/prof
63a52c99 160 kprof -f prof
ad9f1fb6 161
4e77f48b 162
9d5863c5
PG
163MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \
164 "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \
165 "CXXFLAGS := ${OPTFLAGS}" \
166 "CXX := mingw32-g++" \
167 "OBJSDIR := ../objs-mingw32/" \
e8deb7b6 168 "WORKINGDIR := ../bin-mingw32/" \
9d5863c5
PG
169 "TARGETNAME := run_physics.exe"
170
171.PHONY: mingw32
172mingw32:
173 ${Q1}echo "make: mingw32"
174 ${Q2}${MAKE} ${MINGMAKEARGS} clean all
175
4e77f48b
PG
176FINALMAKEARGS := "CXXFLAGS := ${OPTFLAGS}" \
177 "OBJSDIR := ../objs/" \
178 "WORKINGDIR := ../bin/"
179
180.PHONY: final
181final:
182 ${Q1}echo "make: final"
183 ${Q2}${MAKE} ${FINALMAKEARGS} clean all
184
f4b779e4 185-include ${DEPS}