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 | |
44b079f8 | 9 | CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS} |
ad9f1fb6 | 10 | |
88e62c4f PG |
11 | VALFLAGS := --leak-check=full |
12 | ||
67b5017f PG |
13 | WORKINGDIR := .. |
14 | TARGETNAME := run_physics | |
15 | TARGET := ${WORKINGDIR}/${TARGETNAME} | |
ad9f1fb6 | 16 | |
a4bb9ac2 | 17 | SRCS := # simply to keep every line below the same |
0376f786 PG |
18 | |
19 | DIRS := # := start | |
20 | DIRS += . | |
21 | DIRS += Entities | |
22 | DIRS += GameStates | |
23 | DIRS += Effects | |
24 | DIRS += config | |
25 | DIRS += input | |
26 | DIRS += graphics | |
27 | ||
28 | include $(addsuffix /files.mk,${DIRS}) | |
44b079f8 | 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 | |
42f62a75 PG |
38 | BLDDIRS := $(addprefix ${DEPSDIR},${DIRS}) $(addprefix ${OBJSDIR},${DIRS}) |
39 | BLDDIRS := $(addsuffix /,${BLDDIRS}) | |
40 | ||
ad9f1fb6 | 41 | |
393654cf PG |
42 | VERBOSE := 0 |
43 | ||
44 | ifeq (${VERBOSE},0) | |
45 | # quiet the echo command | |
46 | Q1 := @ | |
47 | # quiet the command that is `replaced' by an echo | |
48 | Q2 := @ | |
49 | else | |
50 | # EAT the echo command as if it was not there | |
51 | Q1 := @true # NOTE: the space between @true and the # is VERY important!! | |
52 | # do not quiet the command output | |
53 | Q2 := | |
54 | endif | |
ad9f1fb6 | 55 | |
046b034c PG |
56 | .PHONY: all |
57 | all: ${TARGET} | |
ad9f1fb6 | 58 | |
42f62a75 | 59 | # how to link the main target |
046b034c | 60 | ${TARGET}: ${OBJS} |
393654cf | 61 | ${Q1}echo "${CXX}: $@" |
eb0c55e7 | 62 | ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS} |
ad9f1fb6 | 63 | |
42f62a75 PG |
64 | # how to make a directory |
65 | ${BLDDIRS}: | |
66 | ${Q2}mkdir -p $@ | |
67 | ||
a4bb9ac2 | 68 | # rule to make a depend file from a .cpp |
42f62a75 | 69 | ${DEPSDIR}%.d: %.cpp | ${BLDDIRS} |
393654cf | 70 | ${Q1}echo "DEP: $@" |
a68587cf | 71 | ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@ |
ad9f1fb6 | 72 | |
a4bb9ac2 | 73 | # rule to make an object file from a .cpp |
42f62a75 | 74 | ${OBJSDIR}%.o: %.cpp | ${BLDDIRS} |
393654cf PG |
75 | ${Q1}echo "${CXX}: $@" |
76 | ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< | |
054d658f | 77 | |
ad9f1fb6 | 78 | |
67b5017f PG |
79 | tags: ${SRCS} |
80 | ${Q1}echo "ctags: $@" | |
81 | ${Q2}ctags $^ | |
82 | ||
83 | ||
046b034c | 84 | .PHONY: clean |
ad9f1fb6 | 85 | clean: |
393654cf PG |
86 | ${Q1}echo "CLEAN: OBJS" |
87 | ${Q2}rm -f ${OBJS} | |
88 | ${Q1}echo "CLEAN: TARGET" | |
89 | ${Q2}rm -f ${TARGET} | |
ad9f1fb6 | 90 | |
046b034c | 91 | .PHONY: distclean |
ad9f1fb6 | 92 | distclean: clean |
f4b779e4 PG |
93 | ${Q1}echo "CLEAN: DEPS" |
94 | ${Q2}rm -f ${DEPS} | |
393654cf PG |
95 | ${Q1}echo "CLEAN: tags prof gmon.out" |
96 | ${Q2}rm -f tags prof gmon.out | |
ad9f1fb6 | 97 | |
d893cce2 PG |
98 | .PHONY: gitclean |
99 | gitclean: | |
100 | ${Q1}echo "git-clean: show, use gitcleanf to force" | |
101 | ${Q2}cd ..; git clean -nxd | |
102 | ||
103 | .PHONY: gitcleanf | |
104 | gitcleanf: | |
105 | ${Q1}echo "git-clean: forced" | |
106 | ${Q2}cd ..; git clean -fxd | |
107 | ||
7adc59fe | 108 | .PHONY: tar |
8381f595 PG |
109 | tar: ../physics.tar.bz2 |
110 | ||
111 | .PHONY: ../physics.tar.bz2 | |
112 | ../physics.tar.bz2: | |
113 | @echo "git-archive: Warning, archives HEAD not current" | |
a4bb9ac2 PG |
114 | ${Q1}echo "git-archive: ../physics.tar.bz2" |
115 | ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2 | |
ad9f1fb6 | 116 | |
046b034c PG |
117 | .PHONY: run |
118 | run: all | |
67b5017f | 119 | cd ${WORKINGDIR}; ./${TARGETNAME} |
ad9f1fb6 | 120 | |
6aad402a PG |
121 | .PHONY: gdb |
122 | gdb: all | |
67b5017f PG |
123 | cd ${WORKINGDIR}; gdb ${TARGETNAME} |
124 | ||
125 | .PHONY: cgdb | |
126 | cgdb: all | |
127 | cd ${WORKINGDIR}; cgdb ${TARGETNAME} | |
6aad402a | 128 | |
63a52c99 PG |
129 | .PHONY: val |
130 | val: all | |
67b5017f | 131 | cd ${WORKINGDIR}; valgrind ${VALFLAGS} ${TARGETNAME} |
63a52c99 PG |
132 | |
133 | .PHONY: prof | |
67b5017f PG |
134 | prof: run |
135 | cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > src/prof | |
63a52c99 | 136 | kprof -f prof |
ad9f1fb6 | 137 | |
f4b779e4 | 138 | -include ${DEPS} |