source: trunk/build/lol-build @ 1485

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

build: MinGW compilation fixes, rename libcaca.lib to caca.lib so that
g++ understands -lcaca directly; also add -DCACA_STATIC to the default flags.

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