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