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 PG |
9 | MYFLAGS := -Wall -pedantic -ansi |
10 | CXXFLAGS := ${MYFLAGS} ${DBGFLAGS} | |
ad9f1fb6 | 11 | |
88e62c4f PG |
12 | VALFLAGS := --leak-check=full |
13 | ||
9d5863c5 | 14 | CXX := g++ |
ad9f1fb6 | 15 | |
cf116802 | 16 | SRCS := # := start |
0376f786 PG |
17 | |
18 | DIRS := # := start | |
e8deb7b6 PG |
19 | DIRS += ./ |
20 | DIRS += Entities/ | |
21 | DIRS += GameStates/ | |
22 | DIRS += Effects/ | |
23 | DIRS += config/ | |
24 | DIRS += input/ | |
25 | DIRS += graphics/ | |
0376f786 PG |
26 | |
27 | include $(addsuffix /files.mk,${DIRS}) | |
44b079f8 | 28 | |
f4b779e4 | 29 | OBJSDIR := ../objs/ |
67b5017f PG |
30 | OBJS := ${SRCS:.cpp=.o} |
31 | OBJS := $(addprefix ${OBJSDIR},${OBJS}) | |
f4b779e4 PG |
32 | |
33 | DEPSDIR := ../deps/ | |
67b5017f PG |
34 | DEPS := ${SRCS:.cpp=.d} |
35 | DEPS := $(addprefix ${DEPSDIR},${DEPS}) | |
ad9f1fb6 | 36 | |
9d5863c5 PG |
37 | WORKINGDIR := ../bin/ |
38 | TARGETNAME := run_physics | |
39 | TARGETTMP := ${OBJSDIR}${TARGETNAME} | |
40 | TARGET := ${WORKINGDIR}${TARGETNAME} | |
41 | ||
37a74d97 PG |
42 | CONFIGDIRNAME := configs/ |
43 | CONFIGDIR := ../${CONFIGDIRNAME} | |
44 | CONFIGDEST := ${WORKINGDIR}${CONFIGDIRNAME} | |
45 | ||
46 | CONFIGS := # := start | |
47 | CONFIGS += keys.cfg | |
48 | CONFIGS := $(addprefix ${CONFIGDEST},${CONFIGS}) | |
49 | ||
ebea1138 PG |
50 | DEPSBLDDIRS := $(addprefix ${DEPSDIR},${DIRS}) |
51 | OBJSBLDDIRS := $(addprefix ${OBJSDIR},${DIRS}) | |
37a74d97 | 52 | BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${CONFIGDEST} |
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 |
37a74d97 PG |
70 | all: ${TARGET} ${CONFIGS} |
71 | ||
72 | # rule to copy the config files into the working directory | |
79f36535 | 73 | ${CONFIGDEST}%.cfg: ${CONFIGDIR}%.cfg | ${CONFIGDEST} ${WORKINGDIR} |
37a74d97 | 74 | ${Q1}echo "cp: $@" |
79f36535 | 75 | ${Q2}cp $< $@ |
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 | 82 | # how to link the main target |
9d5863c5 | 83 | ${TARGETTMP}: ${OBJS} |
393654cf | 84 | ${Q1}echo "${CXX}: $@" |
eb0c55e7 | 85 | ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS} |
ad9f1fb6 | 86 | |
42f62a75 PG |
87 | # how to make a directory |
88 | ${BLDDIRS}: | |
89 | ${Q2}mkdir -p $@ | |
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 | |
a4bb9ac2 | 96 | # rule to make an object file from a .cpp |
ebea1138 | 97 | ${OBJSDIR}%.o: %.cpp | ${OBJSBLDDIRS} |
393654cf PG |
98 | ${Q1}echo "${CXX}: $@" |
99 | ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< | |
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} |