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