1 | #!/bin/sh |
---|
2 | |
---|
3 | # |
---|
4 | # Lol Engine build script |
---|
5 | # Usage: |
---|
6 | # lol-build <action> [<platform>] |
---|
7 | # |
---|
8 | # Where <action> is one of: |
---|
9 | # - bootstrap |
---|
10 | # - configure |
---|
11 | # - build |
---|
12 | # - check |
---|
13 | # - clean |
---|
14 | # |
---|
15 | # And <platform> is one of: |
---|
16 | # - linux-i386 |
---|
17 | # - linux-amd64 |
---|
18 | # - ios-arm |
---|
19 | # - android-arm |
---|
20 | # - ps3-ppu |
---|
21 | # - windows-i386 |
---|
22 | # - windows-amd64 |
---|
23 | # |
---|
24 | |
---|
25 | set -e |
---|
26 | |
---|
27 | action="$1" |
---|
28 | platform="$2" |
---|
29 | |
---|
30 | __init__() |
---|
31 | { |
---|
32 | top_srcdir=$(dirname "$0")/.. |
---|
33 | cd $top_srcdir |
---|
34 | top_srcdir="`pwd`" |
---|
35 | |
---|
36 | case "${MSYSTEM}" in |
---|
37 | MINGW32|MINGW64) |
---|
38 | PATH="$PATH:./contrib/gtk-2.22.1/bin" |
---|
39 | M4PATH="$M4PATH:./contrib/gtk-2.22.1/share/aclocal" |
---|
40 | ;; |
---|
41 | esac |
---|
42 | } |
---|
43 | |
---|
44 | bootstrap() |
---|
45 | { |
---|
46 | cd $top_srcdir |
---|
47 | case "$platform" in |
---|
48 | ios-arm) |
---|
49 | # No bootstrapping needed |
---|
50 | ;; |
---|
51 | android-arm) |
---|
52 | # No bootstrapping needed |
---|
53 | ;; |
---|
54 | *) |
---|
55 | PATH="$PATH" M4PATH="$M4PATH" ./bootstrap |
---|
56 | ;; |
---|
57 | esac |
---|
58 | } |
---|
59 | |
---|
60 | configure() |
---|
61 | { |
---|
62 | cd $top_srcdir |
---|
63 | case "$platform" in |
---|
64 | windows-i386) |
---|
65 | if test "x${MSYSTEM}" = xMINGW32; then |
---|
66 | : |
---|
67 | elif i586-mingw32msvc-g++ --version >/dev/null 2>&1; then |
---|
68 | HOSTFLAGS=--host=i586-mingw32msvc |
---|
69 | BUILDFLAGS=--build=none |
---|
70 | elif i686-w64-mingw32-g++ --version >/dev/null 2>&1; then |
---|
71 | HOSTFLAGS=--host=i686-w64-mingw32 |
---|
72 | BUILDFLAGS=--build=none |
---|
73 | else |
---|
74 | echo "Error: could not find win32 compiler" >&2 |
---|
75 | false |
---|
76 | fi |
---|
77 | if test "x${MSYSTEM}" = xMINGW64; then |
---|
78 | # If using mingw64, we're not really cross-compiling |
---|
79 | BUILDFLAGS= |
---|
80 | fi |
---|
81 | PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig" |
---|
82 | LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/i686-w64-mingw32" |
---|
83 | LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.14/lib/i686-w64-mingw32" |
---|
84 | LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/i686-w64-mingw32" |
---|
85 | LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/i686-w64-mingw32" |
---|
86 | LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/lib" |
---|
87 | LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/bin" |
---|
88 | LDFLAGS="$LDFLAGS -L$PWD/contrib/gtkglarea-2.0.1/lib" |
---|
89 | ;; |
---|
90 | windows-amd64) |
---|
91 | if test "x${MSYSTEM}" = xMINGW64; then |
---|
92 | : |
---|
93 | elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then |
---|
94 | HOSTFLAGS=--host=x86_64-w64-mingw32 |
---|
95 | BUILDFLAGS=--build=none |
---|
96 | else |
---|
97 | echo "Error: could not find win64 compiler" >&2 |
---|
98 | false |
---|
99 | fi |
---|
100 | if test "x${MSYSTEM}" = xMINGW32; then |
---|
101 | # If using mingw32, we're not really cross-compiling |
---|
102 | BUILDFLAGS= |
---|
103 | fi |
---|
104 | PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/x86_64-w64-mingw32/pkgconfig" |
---|
105 | LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/x86_64-w64-mingw32" |
---|
106 | LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.14/lib/x86_64-w64-mingw32" |
---|
107 | LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/x86_64-w64-mingw32" |
---|
108 | LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/x86_64-w64-mingw32" |
---|
109 | ;; |
---|
110 | esac |
---|
111 | case "$platform" in |
---|
112 | ios-arm) |
---|
113 | # No configuration needed |
---|
114 | ;; |
---|
115 | android-arm) |
---|
116 | cd monsterz/android |
---|
117 | android update project --path . |
---|
118 | ;; |
---|
119 | ps3-ppu) |
---|
120 | PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=none |
---|
121 | ;; |
---|
122 | windows-i386|windows-amd64) |
---|
123 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-1.2.14/include" |
---|
124 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-image-1.2.10/include" |
---|
125 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-mixer-1.2.11/include" |
---|
126 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/glew-1.7.0/include/GL -DGLEW_STATIC" |
---|
127 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/glib-2.0/include" |
---|
128 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/gtk-2.0/include" |
---|
129 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/glib-2.0" |
---|
130 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gtk-2.0" |
---|
131 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/cairo" |
---|
132 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/pango-1.0" |
---|
133 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gdk-pixbuf-2.0" |
---|
134 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/atk-1.0" |
---|
135 | CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtkglarea-2.0.1/include" |
---|
136 | CPPFLAGS="$CPPFLAGS -mms-bitfields" |
---|
137 | LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++" |
---|
138 | GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32" |
---|
139 | GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0" |
---|
140 | GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0" |
---|
141 | PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS" |
---|
142 | ;; |
---|
143 | *) |
---|
144 | PATH="$PATH" ./configure |
---|
145 | ;; |
---|
146 | esac |
---|
147 | } |
---|
148 | |
---|
149 | build() |
---|
150 | { |
---|
151 | cd $top_srcdir |
---|
152 | case "$platform" in |
---|
153 | ios-arm) |
---|
154 | cd monsterz/ios |
---|
155 | xcodebuild -configuration Release -sdk iphonesimulator4.3 |
---|
156 | ;; |
---|
157 | android-arm) |
---|
158 | cd monsterz/android |
---|
159 | ndk-build |
---|
160 | ant compile |
---|
161 | ;; |
---|
162 | *) |
---|
163 | make -j6 |
---|
164 | ;; |
---|
165 | esac |
---|
166 | } |
---|
167 | |
---|
168 | check() |
---|
169 | { |
---|
170 | cd $top_srcdir |
---|
171 | case "$platform" in |
---|
172 | ios-arm) |
---|
173 | ;; |
---|
174 | android-arm) |
---|
175 | ;; |
---|
176 | ps3-ppu) |
---|
177 | ;; |
---|
178 | windows-amd64) |
---|
179 | # No support for Wine64 yet |
---|
180 | ;; |
---|
181 | *) |
---|
182 | make check |
---|
183 | ;; |
---|
184 | esac |
---|
185 | } |
---|
186 | |
---|
187 | clean() |
---|
188 | { |
---|
189 | cd $top_srcdir |
---|
190 | case "$platform" in |
---|
191 | ios-arm) |
---|
192 | cd monsterz/ios |
---|
193 | xcodebuild -configuration Release -sdk iphonesimulator4.3 clean |
---|
194 | ;; |
---|
195 | android-arm) |
---|
196 | cd monsterz/android |
---|
197 | ndk-build distclean |
---|
198 | ant clean |
---|
199 | ;; |
---|
200 | *) |
---|
201 | make distclean |
---|
202 | ;; |
---|
203 | esac |
---|
204 | } |
---|
205 | |
---|
206 | __init__ |
---|
207 | echo "lol-build: executing action '$action' on platform '$platform'" >&2 |
---|
208 | eval "$action" |
---|
209 | |
---|