1505.01
[voxelands/voxelands-menche.git] / util / build-w32.sh
blob2de3215c3b6be4fbf9b9ab14948106639518aa45
1 #!/bin/sh
2 # options to make. -j# should be set to the number of CPU cores + 1
3 export MAKEFLAGS="-j5"
4 export DIR=`pwd`
6 # First, download and compile the cross-compiler
7 if [ ! -e mxe ]; then
8 git clone -b master git://github.com/mxe/mxe.git
9 else
10 cd mxe && git pull
11 cd $DIR
14 cd mxe
15 git checkout master
16 make $MAKEFLAGS gcc
17 cd $DIR
19 # environment variables for cross-compiling
20 export CC="$DIR/mxe/usr/bin/i686-pc-mingw32.static-gcc"
21 export CXX="$DIR/mxe/usr/bin/i686-pc-mingw32.static-g++"
22 export AR="$DIR/mxe/usr/bin/i686-pc-mingw32.static-ar"
23 export C_INCLUDE_PATH="$DIR/mxe/usr/i686-pc-mingw32.static/include"
24 export CMAKE_TOOLCHAIN="$DIR/mxe/usr/i686-pc-mingw32.static/share/cmake/mxe-conf.cmake"
25 export CFLAGS="-m32 -march=i686 -O2 -fomit-frame-pointer -fwrapv -fvisibility=hidden -Wformat-security -Wformat-nonliteral -Wpointer-arith -Winit-self -pipe"
26 export CXXFLAGS="$CFLAGS"
27 export LDFLAGS="-Wl,-O1 -Wl,--discard-all,--no-undefined,--sort-common"
29 # cmake needs "windres.exe" exactly in the PATH.
30 # can't figure out how to change it and it doesn't like aliases.
31 ln -s $DIR/mxe/usr/bin/i686-pc-mingw32.static-windres $DIR/mxe/usr/bin/windres.exe
32 ln -s $DIR/mxe/usr/bin/i686-pc-mingw32.static-windres $DIR/mxe/usr/bin/windres
33 export PATH="$DIR/mxe/usr/bin:$PATH"
35 # Download the required libraries
36 if [ ! -e irrlicht-1.8/ ]; then
37 wget http://downloads.sourceforge.net/irrlicht/irrlicht-1.8.zip
38 unzip irrlicht-1.8.zip || exit 1
41 # Build the required libraries
42 cd irrlicht-1.8/source/Irrlicht/
43 make $MAKEFLAGS NDEBUG=1 win32 || exit 1
44 cd $DIR
46 # Get the minetest-classic source
47 if [ ! -e voxelands ]; then
48 git clone git://gitorious.org/minetest-classic/minetest-classic.git voxelands
49 else
50 cd voxelands && git reset --hard
51 cd $DIR
52 cd voxelands && git pull
53 cd $DIR
56 BRANCH='master'
57 if [ $# = '1' ]; then
58 export BRANCH=$1
60 echo "Building branch: $BRANCH"
62 # Configure and build voxelands
63 cd voxelands
64 git checkout $BRANCH
65 sed -i "s/[\\][\\]/\//g" src/winresource.rc # Fix nasty Windoze paths
66 rm CMakeCache.txt
67 cmake . -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN \
68 -DCMAKE_INSTALL_PREFIX=/tmp \
69 -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG \
70 -DBUILD_SERVER=1 \
71 -DRUN_IN_PLACE=1 \
72 -DIRRLICHT_INCLUDE_DIR=$DIR/irrlicht-1.8/include \
73 -DIRRLICHT_LIBRARY=$DIR/irrlicht-1.8/lib/Win32-gcc/libIrrlicht.a \
74 -DIRRLICHT_DLL=$DIR/irrlicht-1.8/bin/Win32-gcc/Irrlicht.dll \
75 -DZLIB_INCLUDE_DIR=$DIR/zlib/include \
76 -DZLIB_LIBRARIES=$DIR/zlib/bin/zlibwapi.dll \
77 -DZLIB_DLL=$DIR/zlib/bin/zlibwapi.dll \
78 -DOGG_INCLUDE_DIR=$DIR/libogg/include \
79 -DOGG_LIBRARY=$DIR/libogg/lib/libogg.dll.a \
80 -DOGG_DLL=$DIR/libogg/bin/libogg-0.dll \
81 -DVORBIS_INCLUDE_DIR=$DIR/libvorbis/include \
82 -DVORBIS_LIBRARY=$DIR/libvorbis/lib/libvorbis.dll.a \
83 -DVORBIS_DLL=$DIR/libvorbis/bin/libvorbis-0.dll \
84 -DVORBISFILE_LIBRARY=$DIR/libvorbis/lib/libvorbisfile.dll.a \
85 -DVORBISFILE_DLL=$DIR/libvorbis/bin/libvorbisfile-3.dll \
86 -DOPENAL_INCLUDE_DIR=$DIR/libopenal/include \
87 -DOPENAL_LIBRARY=$DIR/libopenal/lib/libOpenAL32.dll.a \
88 -DOPENAL_DLL=$DIR/libopenal/bin/OpenAL32.dll \
89 -DENABLE_AUDIO=1 || exit 1
91 make $MAKEFLAGS package || exit 1
93 cd $DIR
95 # Keep the environment clean!
96 rm $DIR/mxe/usr/bin/windres.exe
97 unset DIR
98 unset CC
99 unset CXX
100 unset AR
101 unset C_INCLUDE_PATH
102 unset CFLAGS
103 unset CXXFLAGS
104 unset CPPFLAGS
105 unset MAKEFLAGS