source: trunk/build/lol-build @ 1995

Last change on this file since 1995 was 1995, checked in by sam, 7 years ago

build: upgrade glew binaries to 1.9.0 and rename the contrib directory
to external so as to avoid some autocompletion collisions with "configure".

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