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