Commit | Line | Data |
---|---|---|
3c3c195d PG |
1 | |
2 | LIBGL := -lopengl32 -lglu32 | |
3 | LIBSDL := `/usr/mingw32/bin/sdl-config --libs` | |
4 | LIBS := ${LIBSDL} ${LIBGL} | |
5 | ||
6 | OPTFLAGS := -O2 | |
7 | DBGFLAGS := -ggdb | |
8 | PRFFLAGS := ${DBGFLAGS} -pg | |
9 | MYFLAGS := -Wall -pedantic -ansi | |
10 | CXXFLAGS := ${OPTFLAGS} | |
11 | ||
12 | VALFLAGS := --leak-check=full | |
13 | ||
14 | CXX := mingw32-g++ | |
15 | ||
16 | WORKINGDIR := ../bin-mingw32 | |
17 | TARGETNAME := run_physics.exe | |
18 | TARGET := ${WORKINGDIR}/${TARGETNAME} | |
19 | ||
a5aefcc6 | 20 | SRCS := # := start |
3c3c195d PG |
21 | |
22 | DIRS := # := start | |
23 | DIRS += . | |
24 | DIRS += Entities | |
25 | DIRS += GameStates | |
26 | DIRS += Effects | |
27 | DIRS += config | |
28 | DIRS += input | |
29 | DIRS += graphics | |
30 | ||
31 | include $(addsuffix /files.mk,${DIRS}) | |
32 | ||
33 | OBJSDIR := ../objs-mingw32/ | |
34 | OBJS := ${SRCS:.cpp=.o} | |
35 | OBJS := $(addprefix ${OBJSDIR},${OBJS}) | |
36 | ||
37 | DEPSDIR := ../deps/ | |
38 | DEPS := ${SRCS:.cpp=.d} | |
39 | DEPS := $(addprefix ${DEPSDIR},${DEPS}) | |
40 | ||
41 | BLDDIRS := $(addprefix ${DEPSDIR},${DIRS}) $(addprefix ${OBJSDIR},${DIRS}) | |
3c3c195d PG |
42 | |
43 | ||
44 | VERBOSE := 0 | |
45 | ||
46 | ifeq (${VERBOSE},0) | |
47 | # quiet the echo command | |
48 | Q1 := @ | |
49 | # quiet the command that is `replaced' by an echo | |
50 | Q2 := @ | |
51 | else | |
52 | # EAT the echo command as if it was not there | |
53 | Q1 := @true # NOTE: the space between @true and the # is VERY important!! | |
54 | # do not quiet the command output | |
55 | Q2 := | |
56 | endif | |
57 | ||
58 | .PHONY: all | |
59 | all: ${TARGET} | |
60 | ||
61 | # how to link the main target | |
62 | ${TARGET}: ${OBJS} | |
63 | ${Q1}echo "${CXX}: $@" | |
64 | ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS} | |
65 | ||
66 | # how to make a directory | |
67 | ${BLDDIRS}: | |
68 | ${Q2}mkdir -p $@ | |
69 | ||
70 | # rule to make a depend file from a .cpp | |
71 | ${DEPSDIR}%.d: %.cpp | ${BLDDIRS} | |
72 | ${Q1}echo "DEP: $@" | |
73 | ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@ | |
74 | ||
75 | # rule to make an object file from a .cpp | |
76 | ${OBJSDIR}%.o: %.cpp | ${BLDDIRS} | |
77 | ${Q1}echo "${CXX}: $@" | |
78 | ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< | |
79 | ||
80 | ||
81 | tags: ${SRCS} | |
82 | ${Q1}echo "ctags: $@" | |
83 | ${Q2}ctags $^ | |
84 | ||
85 | ||
86 | .PHONY: clean | |
87 | clean: | |
88 | ${Q1}echo "CLEAN: OBJS" | |
89 | ${Q2}rm -f ${OBJS} | |
90 | ${Q1}echo "CLEAN: TARGET" | |
91 | ${Q2}rm -f ${TARGET} | |
92 | ||
93 | .PHONY: distclean | |
94 | distclean: clean | |
95 | ${Q1}echo "CLEAN: DEPS" | |
96 | ${Q2}rm -f ${DEPS} | |
97 | ${Q1}echo "CLEAN: tags prof gmon.out" | |
98 | ${Q2}rm -f tags prof gmon.out | |
99 | ||
100 | .PHONY: gitclean | |
101 | gitclean: | |
102 | ${Q1}echo "git-clean: show, use gitcleanf to force" | |
103 | ${Q2}cd ..; git clean -nxd | |
104 | ||
105 | .PHONY: gitcleanf | |
106 | gitcleanf: | |
107 | ${Q1}echo "git-clean: forced" | |
108 | ${Q2}cd ..; git clean -fxd | |
109 | ||
110 | .PHONY: tar | |
111 | tar: ../physics.tar.bz2 | |
112 | ||
113 | .PHONY: ../physics.tar.bz2 | |
114 | ../physics.tar.bz2: | |
115 | @echo "git-archive: Warning, archives HEAD not current" | |
116 | ${Q1}echo "git-archive: ../physics.tar.bz2" | |
117 | ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2 | |
118 | ||
119 | .PHONY: run | |
120 | run: all | |
121 | cd ${WORKINGDIR}; wine ${TARGETNAME} | |
122 | ||
123 | .PHONY: gdb | |
124 | gdb: all | |
125 | cd ${WORKINGDIR}; gdb ${TARGETNAME} | |
126 | ||
127 | .PHONY: cgdb | |
128 | cgdb: all | |
129 | cd ${WORKINGDIR}; cgdb ${TARGETNAME} | |
130 | ||
131 | .PHONY: val | |
132 | val: all | |
a5aefcc6 | 133 | cd ${WORKINGDIR}; valgrind ${VALFLAGS} ./${TARGETNAME} |
3c3c195d PG |
134 | |
135 | .PHONY: prof | |
136 | prof: run | |
137 | cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > src/prof | |
138 | kprof -f prof | |
139 | ||
140 | -include ${DEPS} |