source: trunk/build/lol-build @ 1677

Last change on this file since 1677 was 1677, checked in by sam, 10 years ago

build: fix the Raspberry Pi build and add a build script for it.

  • Property svn:executable set to *
File size: 8.0 KB
Line 
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#  - nacl-i386
19#  - nacl-amd64
20#  - ios-arm
21#  - osx-amd64
22#  - android-arm
23#  - ps3-ppu
24#  - win*-i386
25#  - win*-amd64
26#  - raspi-arm
27#
28
29set -e
30
31action="$1"
32platform="$2"
33
34__init__()
35{
36    top_srcdir="$(dirname "$0")/.."
37    cd "$top_srcdir"
38    top_srcdir="`pwd`"
39
40    case "${MSYSTEM}" in
41        MINGW32|MINGW64)
42            PATH="$PATH:./contrib/gtk-2.22.1/bin"
43            M4PATH="$M4PATH:./contrib/gtk-2.22.1/share/aclocal"
44            ;;
45    esac
46}
47
48bootstrap()
49{
50    cd "$top_srcdir"
51    case "$platform" in
52        ios-arm)
53            # No bootstrapping needed
54            ;;
55        android-arm)
56            # No bootstrapping needed
57            ;;
58        *)
59            PATH="$PATH" M4PATH="$M4PATH" ./bootstrap
60            ;;
61    esac
62}
63
64configure()
65{
66    cd "$top_srcdir"
67    case "$platform" in
68        win*-i386)
69            if test "x${MSYSTEM}" = xMINGW32; then
70                :
71            elif i586-mingw32msvc-g++ --version >/dev/null 2>&1; then
72                HOSTFLAGS=--host=i586-mingw32msvc
73                BUILDFLAGS=--build=none
74            elif i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
75                HOSTFLAGS=--host=i686-w64-mingw32
76                BUILDFLAGS=--build=none
77            else
78                echo "Error: could not find win32 compiler" >&2
79                false
80            fi
81            if test "x${MSYSTEM}" = xMINGW64; then
82                # If using mingw64, we're not really cross-compiling
83                BUILDFLAGS=
84            fi
85            PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"
86            PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/libcaca-0.99.beta18/lib/pkgconfig"
87            LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/i686-w64-mingw32"
88            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.15/lib/i686-w64-mingw32"
89            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/i686-w64-mingw32"
90            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/i686-w64-mingw32"
91            LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/lib"
92            LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/bin"
93            LDFLAGS="$LDFLAGS -L$PWD/contrib/gtkglarea-2.0.1/lib"
94            LDFLAGS="$LDFLAGS -L$PWD/contrib/libcaca-0.99.beta18/lib/i686-w64-mingw32"
95            ;;
96        win*-amd64)
97            if test "x${MSYSTEM}" = xMINGW64; then
98                :
99            elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
100                HOSTFLAGS=--host=x86_64-w64-mingw32
101                BUILDFLAGS=--build=none
102            else
103                echo "Error: could not find win64 compiler" >&2
104                false
105            fi
106            if test "x${MSYSTEM}" = xMINGW32; then
107                # If using mingw32, we're not really cross-compiling
108                BUILDFLAGS=
109            fi
110            PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"
111            PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/libcaca-0.99.beta18/lib/pkgconfig"
112            LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/x86_64-w64-mingw32"
113            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.15/lib/x86_64-w64-mingw32"
114            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/x86_64-w64-mingw32"
115            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/x86_64-w64-mingw32"
116            LDFLAGS="$LDFLAGS -L$PWD/contrib/libcaca-0.99.beta18/lib/x86_64-w64-mingw32"
117            ;;
118        *-i386)
119            # Ensure we're _really_ on i386
120            CXXFLAGS="$CXXFLAGS -m32"
121            ;;
122        *-amd64)
123            # Ensure we're _really_ on amd64
124            CXXFLAGS="$CXXFLAGS -m64"
125            ;;
126    esac
127    case "$platform" in
128        ios-arm)
129            # No configuration needed
130            ;;
131        android-arm)
132            cd monsterz/android
133            android update project --path .
134            ;;
135        raspi-arm)
136            ./configure --host=arm-bcm2708hardfp-linux-gnueabi CPPFLAGS="-I$RASPI_SDK_ROOT/firmware/opt/vc/include -I$RASPI_SDK_ROOT/firmware/opt/vc/include/interface/vcos/pthreads" LDFLAGS="-L$RASPI_SDK_ROOT/firmware/opt/vc/lib"
137            ;;
138        nacl-i386)
139            ./configure CXX=i686-nacl-g++ CC=i686-nacl-gcc ac_cv_exeext=.32.nexe --host=i386 LOL_LIBS="-lppapi -lppapi_gles2 -lppapi_cpp -u _ZN2pp12CreateModuleEv"
140            ;;
141        nacl-amd64)
142            ./configure CXX=x86_64-nacl-g++ CC=x86_64-nacl-gcc ac_cv_exeext=.64.nexe --host=x86_64 LOL_LIBS="-lppapi -lppapi_gles2 -lppapi_cpp -u _ZN2pp12CreateModuleEv"
143            ;;
144        ps3-ppu)
145            PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
146            ;;
147        win*-i386|win*-amd64)
148            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-1.2.15/include"
149            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-image-1.2.10/include"
150            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-mixer-1.2.11/include"
151            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/glew-1.7.0/include/GL -DGLEW_STATIC"
152            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/glib-2.0/include"
153            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/gtk-2.0/include"
154            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/glib-2.0"
155            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gtk-2.0"
156            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/cairo"
157            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/pango-1.0"
158            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gdk-pixbuf-2.0"
159            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/atk-1.0"
160            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtkglarea-2.0.1/include"
161            CPPFLAGS="$CPPFLAGS -mms-bitfields"
162            LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
163            GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
164            GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
165            GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
166
167            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/libcaca-0.99.beta18/include -DCACA_STATIC"
168
169            PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
170            ;;
171        *)
172            PATH="$PATH" ./configure CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS"
173            ;;
174    esac
175}
176
177build()
178{
179    cd "$top_srcdir"
180    case "$platform" in
181        ios-arm)
182            cd monsterz/ios
183            xcodebuild -configuration Release -sdk iphonesimulator4.3
184            ;;
185        android-arm)
186            cd monsterz/android
187            ndk-build
188            ant compile
189            ;;
190        *)
191            make -j6
192            ;;
193    esac
194}
195
196check()
197{
198    cd "$top_srcdir"
199    case "$platform" in
200        ios-arm)
201            ;;
202        android-arm)
203            ;;
204        raspi-arm)
205            ;;
206        ps3-ppu)
207            ;;
208        nacl-*)
209            ;;
210        win*-i386)
211            # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
212            # exists, use it to run the test suite.
213            if test "x${MSYSTEM}${DISPLAY}" = x \
214               && xvfb-run --help 2>&1 >/dev/null; then
215                xvfb-run make check
216            else
217                make check
218            fi
219            ;;
220        win*-amd64)
221            # No support for Wine64 yet
222            ;;
223        *)
224            make check
225            ;;
226    esac
227}
228
229clean()
230{
231    cd "$top_srcdir"
232    case "$platform" in
233        ios-arm)
234            cd monsterz/ios
235            xcodebuild -configuration Release -sdk iphonesimulator4.3 clean
236            ;;
237        android-arm)
238            cd monsterz/android
239            ndk-build distclean
240            ant clean
241            ;;
242        *)
243            make distclean
244            ;;
245    esac
246}
247
248__init__
249echo "lol-build: executing action '$action' on platform '$platform'" >&2
250eval "$action"
251
Note: See TracBrowser for help on using the repository browser.