source: trunk/build/lol-build @ 1684

Last change on this file since 1684 was 1684, checked in by sam, 8 years ago

build: switch the Android native build rules to autoconf; still a bit rough
but we can now create shared objects for each project; only the testsuite
is not building properly because of issues with STLport, and EglApp is
deactivated because AndroidApp should have precedence.

  • Property svn:executable set to *
File size: 9.2 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            ./configure --host=arm-linux-androideabi ac_cv_exeext=.so \
157                CPPFLAGS="-Wno-psabi -I$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport -I$ANDROID_NDK_ROOT/sources/cxx-stl/gabi++/include -fpic -fno-exceptions -fno-rtti -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64" \
158                CFLAGS="-march=armv5te -mtune=xscale -msoft-float -mthumb" \
159                CXXFLAGS="-march=armv5te -mtune=xscale -msoft-float -mthumb" \
160                LOL_LIBS="-L$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi -lstlport_shared -lm -fpic -XCClinker -shared"
161            # FIXME: is this needed?
162            # android update project --path .
163            # ndk-build
164            # ant compile
165            # ndk-build distclean
166            # ant clean
167            ;;
168        raspi-arm)
169            ./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"
170            ;;
171        nacl-i386)
172            ./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"
173            ;;
174        nacl-amd64)
175            ./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"
176            ;;
177        ps3-ppu)
178            PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
179            ;;
180        win*-i386|win*-amd64)
181            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-1.2.15/include"
182            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-image-1.2.10/include"
183            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-mixer-1.2.11/include"
184            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/glew-1.7.0/include/GL -DGLEW_STATIC"
185            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/glib-2.0/include"
186            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/gtk-2.0/include"
187            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/glib-2.0"
188            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gtk-2.0"
189            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/cairo"
190            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/pango-1.0"
191            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gdk-pixbuf-2.0"
192            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/atk-1.0"
193            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtkglarea-2.0.1/include"
194            CPPFLAGS="$CPPFLAGS -mms-bitfields"
195            LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
196            GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
197            GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
198            GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
199
200            CPPFLAGS="$CPPFLAGS -I$PWD/contrib/libcaca-0.99.beta18/include -DCACA_STATIC"
201
202            PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
203            ;;
204        *)
205            PATH="$PATH" ./configure CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS"
206            ;;
207    esac
208}
209
210build()
211{
212    cd "$top_srcdir"
213    case "$platform" in
214        ios-arm)
215            cd monsterz/ios
216            xcodebuild -configuration Release -sdk iphonesimulator4.3
217            ;;
218        *)
219            make -j$LOL_PARALLEL
220            ;;
221    esac
222}
223
224check()
225{
226    cd "$top_srcdir"
227    case "$platform" in
228        ios-arm)
229            ;;
230        android-arm)
231            ;;
232        raspi-arm)
233            ;;
234        ps3-ppu)
235            ;;
236        nacl-*)
237            ;;
238        win*-i386)
239            # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
240            # exists, use it to run the test suite.
241            if test "x${MSYSTEM}${DISPLAY}" = x \
242               && xvfb-run --help 2>&1 >/dev/null; then
243                xvfb-run make check
244            else
245                make check
246            fi
247            ;;
248        win*-amd64)
249            # No support for Wine64 yet
250            ;;
251        *)
252            make check
253            ;;
254    esac
255}
256
257clean()
258{
259    cd "$top_srcdir"
260    case "$platform" in
261        ios-arm)
262            cd monsterz/ios
263            xcodebuild -configuration Release -sdk iphonesimulator4.3 clean
264            ;;
265        *)
266            make distclean
267            ;;
268    esac
269}
270
271__init__
272echo "lol-build: executing action '$action' on platform '$platform'" >&2
273eval "$action"
274
Note: See TracBrowser for help on using the repository browser.