build-w32.sh 3.3 KB

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