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 | ||
ebea1138 PG |
42 | DEPSBLDDIRS := $(addprefix ${DEPSDIR},${DIRS}) |
43 | OBJSBLDDIRS := $(addprefix ${OBJSDIR},${DIRS}) | |
44 | BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} | |
42f62a75 | 45 | |
ad9f1fb6 | 46 | |
393654cf PG |
47 | VERBOSE := 0 |
48 | ||
49 | ifeq (${VERBOSE},0) | |
50 | # quiet the echo command | |
51 | Q1 := @ | |
52 | # quiet the command that is `replaced' by an echo | |
53 | Q2 := @ | |
54 | else | |
55 | # EAT the echo command as if it was not there | |
56 | Q1 := @true # NOTE: the space between @true and the # is VERY important!! | |
57 | # do not quiet the command output | |
58 | Q2 := | |
59 | endif | |
ad9f1fb6 | 60 | |
046b034c PG |
61 | .PHONY: all |
62 | all: ${TARGET} | |
ad9f1fb6 | 63 | |
9d5863c5 | 64 | # rule to copy tmp target to working directory |
ebea1138 | 65 | ${TARGET}: ${TARGETTMP} | ${WORKINGDIR} |
9d5863c5 PG |
66 | ${Q1}echo "cp: $@" |
67 | ${Q2}cp $^ $@ | |
68 | ||
42f62a75 | 69 | # how to link the main target |
9d5863c5 | 70 | ${TARGETTMP}: ${OBJS} |
393654cf | 71 | ${Q1}echo "${CXX}: $@" |
eb0c55e7 | 72 | ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS} |
ad9f1fb6 | 73 | |
42f62a75 PG |
74 | # how to make a directory |
75 | ${BLDDIRS}: | |
76 | ${Q2}mkdir -p $@ | |
77 | ||
a4bb9ac2 | 78 | # rule to make a depend file from a .cpp |
ebea1138 | 79 | ${DEPSDIR}%.d: %.cpp | ${DEPSBLDDIRS} |
393654cf | 80 | ${Q1}echo "DEP: $@" |
a68587cf | 81 | ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@ |
ad9f1fb6 | 82 | |
a4bb9ac2 | 83 | # rule to make an object file from a .cpp |
ebea1138 | 84 | ${OBJSDIR}%.o: %.cpp | ${OBJSBLDDIRS} |
393654cf PG |
85 | ${Q1}echo "${CXX}: $@" |
86 | ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< | |
054d658f | 87 | |
ad9f1fb6 | 88 | |
67b5017f PG |
89 | tags: ${SRCS} |
90 | ${Q1}echo "ctags: $@" | |
91 | ${Q2}ctags $^ | |
92 | ||
93 | ||
046b034c | 94 | .PHONY: clean |
ad9f1fb6 | 95 | clean: |
393654cf PG |
96 | ${Q1}echo "CLEAN: OBJS" |
97 | ${Q2}rm -f ${OBJS} | |
98 | ${Q1}echo "CLEAN: TARGET" | |
99 | ${Q2}rm -f ${TARGET} | |
ad9f1fb6 | 100 | |
046b034c | 101 | .PHONY: distclean |
ad9f1fb6 | 102 | distclean: clean |
f4b779e4 PG |
103 | ${Q1}echo "CLEAN: DEPS" |
104 | ${Q2}rm -f ${DEPS} | |
393654cf PG |
105 | ${Q1}echo "CLEAN: tags prof gmon.out" |
106 | ${Q2}rm -f tags prof gmon.out | |
ad9f1fb6 | 107 | |
d893cce2 PG |
108 | .PHONY: gitclean |
109 | gitclean: | |
110 | ${Q1}echo "git-clean: show, use gitcleanf to force" | |
111 | ${Q2}cd ..; git clean -nxd | |
112 | ||
113 | .PHONY: gitcleanf | |
114 | gitcleanf: | |
115 | ${Q1}echo "git-clean: forced" | |
116 | ${Q2}cd ..; git clean -fxd | |
117 | ||
7adc59fe | 118 | .PHONY: tar |
8381f595 PG |
119 | tar: ../physics.tar.bz2 |
120 | ||
121 | .PHONY: ../physics.tar.bz2 | |
122 | ../physics.tar.bz2: | |
123 | @echo "git-archive: Warning, archives HEAD not current" | |
a4bb9ac2 PG |
124 | ${Q1}echo "git-archive: ../physics.tar.bz2" |
125 | ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2 | |
ad9f1fb6 | 126 | |
046b034c PG |
127 | .PHONY: run |
128 | run: all | |
67b5017f | 129 | cd ${WORKINGDIR}; ./${TARGETNAME} |
ad9f1fb6 | 130 | |
6aad402a PG |
131 | .PHONY: gdb |
132 | gdb: all | |
67b5017f PG |
133 | cd ${WORKINGDIR}; gdb ${TARGETNAME} |
134 | ||
135 | .PHONY: cgdb | |
136 | cgdb: all | |
137 | cd ${WORKINGDIR}; cgdb ${TARGETNAME} | |
6aad402a | 138 | |
63a52c99 PG |
139 | .PHONY: val |
140 | val: all | |
823da4ea | 141 | cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME} |
63a52c99 PG |
142 | |
143 | .PHONY: prof | |
67b5017f PG |
144 | prof: run |
145 | cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > src/prof | |
63a52c99 | 146 | kprof -f prof |
ad9f1fb6 | 147 | |
9d5863c5 PG |
148 | MINGMAKEARGS := "LIBGL := -lopengl32 -lglu32" \ |
149 | "LIBSDL := `/usr/mingw32/bin/sdl-config --libs`" \ | |
150 | "CXXFLAGS := ${OPTFLAGS}" \ | |
151 | "CXX := mingw32-g++" \ | |
152 | "OBJSDIR := ../objs-mingw32/" \ | |
e8deb7b6 | 153 | "WORKINGDIR := ../bin-mingw32/" \ |
9d5863c5 PG |
154 | "TARGETNAME := run_physics.exe" |
155 | ||
156 | .PHONY: mingw32 | |
157 | mingw32: | |
158 | ${Q1}echo "make: mingw32" | |
159 | ${Q2}${MAKE} ${MINGMAKEARGS} clean all | |
160 | ||
f4b779e4 | 161 | -include ${DEPS} |