source: trunk/build/lol-build @ 1697

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

android: explicitly load stlport_shared when initialising the native object.

  • Property svn:executable set to *
File size: 9.4 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###############################################################################
35# Initialisation code
36#
37#  - sets the top_srcdir variable
38#  - sets the LOL_PARALLEL variable
39#  - fix PATH and MKPATH if necessary
40#
41__init__()
42{
43    top_srcdir="$(dirname "$0")/.."
44    cd "$top_srcdir"
45    top_srcdir="`pwd`"
46
47    case "$cpu_count" in
48      [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
49      *) if [ -r "/proc/cpuinfo" ]; then
50           cpu_count="$(grep -c '^processor\>' /proc/cpuinfo)"
51         fi ;;
52    esac
53    case "$cpu_count" in
54      [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
55      *) cpu_count="$(sysctl -n hw.ncpu 2>/dev/null)" ;;
56    esac
57    case "$cpu_count" in
58      [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
59      *) cpu_count=1 ;;
60    esac
61    case "$cpu_count" in
62      1) LOL_PARALLEL=1 ;;
63      2) LOL_PARALLEL=3 ;;
64      *) LOL_PARALLEL="$(expr $cpu_count '*' 3 / 2)" ;;
65    esac
66
67    case "${MSYSTEM}" in
68        MINGW32|MINGW64)
69            PATH="$PATH:./contrib/gtk-2.22.1/bin"
70            M4PATH="$M4PATH:./contrib/gtk-2.22.1/share/aclocal"
71            ;;
72    esac
73}
74
75bootstrap()
76{
77    cd "$top_srcdir"
78    case "$platform" in
79        ios-arm)
80            # No bootstrapping needed
81            ;;
82        *)
83            PATH="$PATH" M4PATH="$M4PATH" ./bootstrap
84            ;;
85    esac
86}
87
88configure()
89{
90    cd "$top_srcdir"
91    case "$platform" in
92        win*-i386)
93            if test "x${MSYSTEM}" = xMINGW32; then
94                :
95            elif i586-mingw32msvc-g++ --version >/dev/null 2>&1; then
96                HOSTFLAGS=--host=i586-mingw32msvc
97                BUILDFLAGS=--build=none
98            elif i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
99                HOSTFLAGS=--host=i686-w64-mingw32
100                BUILDFLAGS=--build=none
101            else
102                echo "Error: could not find win32 compiler" >&2
103                false
104            fi
105            if test "x${MSYSTEM}" = xMINGW64; then
106                # If using mingw64, we're not really cross-compiling
107                BUILDFLAGS=
108            fi
109            PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"
110            PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/libcaca-0.99.beta18/lib/pkgconfig"
111            LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/i686-w64-mingw32"
112            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.15/lib/i686-w64-mingw32"
113            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/i686-w64-mingw32"
114            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/i686-w64-mingw32"
115            LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/lib"
116            LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/bin"
117            LDFLAGS="$LDFLAGS -L$PWD/contrib/gtkglarea-2.0.1/lib"
118            LDFLAGS="$LDFLAGS -L$PWD/contrib/libcaca-0.99.beta18/lib/i686-w64-mingw32"
119            ;;
120        win*-amd64)
121            if test "x${MSYSTEM}" = xMINGW64; then
122                :
123            elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
124                HOSTFLAGS=--host=x86_64-w64-mingw32
125                BUILDFLAGS=--build=none
126            else
127                echo "Error: could not find win64 compiler" >&2
128                false
129            fi
130            if test "x${MSYSTEM}" = xMINGW32; then
131                # If using mingw32, we're not really cross-compiling
132                BUILDFLAGS=
133            fi
134            PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"
135            PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/libcaca-0.99.beta18/lib/pkgconfig"
136            LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/x86_64-w64-mingw32"
137            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.15/lib/x86_64-w64-mingw32"
138            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/x86_64-w64-mingw32"
139            LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/x86_64-w64-mingw32"
140            LDFLAGS="$LDFLAGS -L$PWD/contrib/libcaca-0.99.beta18/lib/x86_64-w64-mingw32"
141            ;;
142        *-i386)
143            # Ensure we're _really_ on i386
144            CXXFLAGS="$CXXFLAGS -m32"
145            ;;
146        *-amd64)
147            # Ensure we're _really_ on amd64
148            CXXFLAGS="$CXXFLAGS -m64"
149            ;;
150    esac
151    case "$platform" in
152        ios-arm)
153            # No configuration needed
154            ;;
155        android-arm)
156            CPPFLAGS="-Wno-psabi -I$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport -fpic -fno-exceptions -fno-rtti -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64"
157            CFLAGS="-march=armv5te -mtune=xscale -msoft-float -mthumb"
158            CXXFLAGS="-march=armv5te -mtune=xscale -msoft-float -mthumb"
159            LOL_LIBS="-L$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi -lstlport_shared -lm -fpic -XCClinker -shared"
160            ./configure --host=arm-linux-androideabi ac_cv_exeext=.so CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LOL_LIBS="$LOL_LIBS"
161            # FIXME: is this needed?
162            # ant debug
163            # ant debug install
164            # ant clean
165            ;;
166        raspi-arm)
167            ./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 -I$RASPI_SDK_ROOT/chroot/usr/include" LDFLAGS="-L$RASPI_SDK_ROOT/firmware/opt/vc/lib -L$RASPI_SDK_ROOT/chroot/lib/arm-linux-gnueabihf -Wl,-rpath-link -Wl,$RASPI_SDK_ROOT/chroot/lib/arm-linux-gnueabihf -L$RASPI_SDK_ROOT/chroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link -Wl,$RASPI_SDK_ROOT/chroot/usr/lib/arm-linux-gnueabihf -Wl,--unresolved-symbols=ignore-in-shared-libs"
168            ;;
169        nacl-i386)
170            ./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"
171            ;;
172        nacl-amd64)
173            ./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"
174            ;;
175        ps3-ppu)
176            PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
177            ;;
178        win*-i386|win*-amd64)
179            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-1.2.15/include"
180            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-image-1.2.10/include"
181            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-mixer-1.2.11/include"
182            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/glew-1.7.0/include/GL -DGLEW_STATIC"
183            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/glib-2.0/include"
184            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/gtk-2.0/include"
185            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/glib-2.0"
186            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gtk-2.0"
187            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/cairo"
188            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/pango-1.0"
189            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gdk-pixbuf-2.0"
190            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/atk-1.0"
191            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtkglarea-2.0.1/include"
192            CPPFLAGS="$CPPFLAGS -mms-bitfields"
193            LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
194            GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
195            GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
196            GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
197
198            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/libcaca-0.99.beta18/include -DCACA_STATIC"
199
200            PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
201            ;;
202        *)
203            PATH="$PATH" ./configure CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS"
204            ;;
205    esac
206}
207
208build()
209{
210    cd "$top_srcdir"
211    case "$platform" in
212        ios-arm)
213            cd monsterz/ios
214            xcodebuild -configuration Release -sdk iphonesimulator4.3
215            ;;
216        *)
217            make -j$LOL_PARALLEL
218            ;;
219    esac
220}
221
222check()
223{
224    cd "$top_srcdir"
225    case "$platform" in
226        ios-arm)
227            ;;
228        android-arm)
229            ;;
230        raspi-arm)
231            ;;
232        ps3-ppu)
233            ;;
234        nacl-*)
235            ;;
236        win*-i386)
237            # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
238            # exists, use it to run the test suite.
239            if test "x${MSYSTEM}${DISPLAY}" = x \
240               && xvfb-run --help 2>&1 >/dev/null; then
241                xvfb-run make check
242            else
243                make check
244            fi
245            ;;
246        win*-amd64)
247            # No support for Wine64 yet
248            ;;
249        *)
250            make check
251            ;;
252    esac
253}
254
255clean()
256{
257    cd "$top_srcdir"
258    case "$platform" in
259        ios-arm)
260            cd monsterz/ios
261            xcodebuild -configuration Release -sdk iphonesimulator4.3 clean
262            ;;
263        *)
264            make distclean
265            ;;
266    esac
267}
268
269__init__
270echo "lol-build: executing action '$action' on platform '$platform'" >&2
271eval "$action"
272
Note: See TracBrowser for help on using the repository browser.