buildwin32.sh 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #!/bin/bash
  2. set -e
  3. CORE_GIT=https://github.com/minetest/minetest
  4. CORE_BRANCH=master
  5. CORE_NAME=minetest
  6. GAME_GIT=https://github.com/minetest/minetest_game
  7. GAME_BRANCH=master
  8. GAME_NAME=minetest_game
  9. dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  10. if [ $# -ne 1 ]; then
  11. echo "Usage: $0 <build directory>"
  12. exit 1
  13. fi
  14. builddir=$1
  15. mkdir -p $builddir
  16. builddir="$( cd "$builddir" && pwd )"
  17. packagedir=$builddir/packages
  18. libdir=$builddir/libs
  19. # Test which win32 compiler is present
  20. which i586-mingw32msvc-windres &>/dev/null && toolchain_file=$dir/toolchain_i586-mingw32msvc.cmake
  21. which i686-w64-mingw32-windres &>/dev/null && toolchain_file=$dir/toolchain_i646-w64-mingw32.cmake
  22. if [ -z "$toolchain_file" ]; then
  23. echo "Unable to determine which mingw32 compiler to use"
  24. exit 1
  25. fi
  26. echo "Using $toolchain_file"
  27. irrlicht_version=1.8.4
  28. ogg_version=1.3.2
  29. vorbis_version=1.3.5
  30. curl_version=7.65.3
  31. gettext_version=0.20.1
  32. freetype_version=2.10.1
  33. sqlite3_version=3.27.2
  34. luajit_version=2.1.0-beta3
  35. leveldb_version=1.22
  36. zlib_version=1.2.11
  37. mkdir -p $packagedir
  38. mkdir -p $libdir
  39. cd $builddir
  40. # Get stuff
  41. [ -e $packagedir/irrlicht-$irrlicht_version.zip ] || wget http://minetest.kitsunemimi.pw/irrlicht-$irrlicht_version-win32.zip \
  42. -c -O $packagedir/irrlicht-$irrlicht_version.zip
  43. [ -e $packagedir/zlib-$zlib_version.zip ] || wget http://minetest.kitsunemimi.pw/zlib-$zlib_version-win32.zip \
  44. -c -O $packagedir/zlib-$zlib_version.zip
  45. [ -e $packagedir/libogg-$ogg_version.zip ] || wget http://minetest.kitsunemimi.pw/libogg-$ogg_version-win32.zip \
  46. -c -O $packagedir/libogg-$ogg_version.zip
  47. [ -e $packagedir/libvorbis-$vorbis_version.zip ] || wget http://minetest.kitsunemimi.pw/libvorbis-$vorbis_version-win32.zip \
  48. -c -O $packagedir/libvorbis-$vorbis_version.zip
  49. [ -e $packagedir/curl-$curl_version.zip ] || wget http://minetest.kitsunemimi.pw/curl-$curl_version-win32.zip \
  50. -c -O $packagedir/curl-$curl_version.zip
  51. [ -e $packagedir/gettext-$gettext_version.zip ] || wget http://minetest.kitsunemimi.pw/gettext-$gettext_version-win32.zip \
  52. -c -O $packagedir/gettext-$gettext_version.zip
  53. [ -e $packagedir/freetype2-$freetype_version.zip ] || wget http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win32.zip \
  54. -c -O $packagedir/freetype2-$freetype_version.zip
  55. [ -e $packagedir/sqlite3-$sqlite3_version.zip ] || wget http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win32.zip \
  56. -c -O $packagedir/sqlite3-$sqlite3_version.zip
  57. [ -e $packagedir/luajit-$luajit_version.zip ] || wget http://minetest.kitsunemimi.pw/luajit-$luajit_version-win32.zip \
  58. -c -O $packagedir/luajit-$luajit_version.zip
  59. [ -e $packagedir/libleveldb-$leveldb_version.zip ] || wget http://minetest.kitsunemimi.pw/libleveldb-$leveldb_version-win32.zip \
  60. -c -O $packagedir/libleveldb-$leveldb_version.zip
  61. [ -e $packagedir/openal_stripped.zip ] || wget http://minetest.kitsunemimi.pw/openal_stripped.zip \
  62. -c -O $packagedir/openal_stripped.zip
  63. # Extract stuff
  64. cd $libdir
  65. [ -d irrlicht ] || unzip -o $packagedir/irrlicht-$irrlicht_version.zip -d irrlicht
  66. [ -d zlib ] || unzip -o $packagedir/zlib-$zlib_version.zip -d zlib
  67. [ -d libogg ] || unzip -o $packagedir/libogg-$ogg_version.zip -d libogg
  68. [ -d libvorbis ] || unzip -o $packagedir/libvorbis-$vorbis_version.zip -d libvorbis
  69. [ -d libcurl ] || unzip -o $packagedir/curl-$curl_version.zip -d libcurl
  70. [ -d gettext ] || unzip -o $packagedir/gettext-$gettext_version.zip -d gettext
  71. [ -d freetype ] || unzip -o $packagedir/freetype2-$freetype_version.zip -d freetype
  72. [ -d sqlite3 ] || unzip -o $packagedir/sqlite3-$sqlite3_version.zip -d sqlite3
  73. [ -d openal_stripped ] || unzip -o $packagedir/openal_stripped.zip
  74. [ -d luajit ] || unzip -o $packagedir/luajit-$luajit_version.zip -d luajit
  75. [ -d leveldb ] || unzip -o $packagedir/libleveldb-$leveldb_version.zip -d leveldb
  76. # Get minetest
  77. cd $builddir
  78. if [ ! "x$EXISTING_MINETEST_DIR" = "x" ]; then
  79. cd /$EXISTING_MINETEST_DIR # must be absolute path
  80. else
  81. [ -d $CORE_NAME ] && (cd $CORE_NAME && git pull) || (git clone -b $CORE_BRANCH $CORE_GIT)
  82. cd $CORE_NAME
  83. fi
  84. git_hash=$(git rev-parse --short HEAD)
  85. # Get minetest_game
  86. if [ "x$NO_MINETEST_GAME" = "x" ]; then
  87. cd games
  88. [ -d $GAME_NAME ] && (cd $GAME_NAME && git pull) || (git clone -b $GAME_BRANCH $GAME_GIT)
  89. cd ..
  90. fi
  91. # Build the thing
  92. [ -d _build ] && rm -Rf _build/
  93. mkdir _build
  94. cd _build
  95. cmake .. \
  96. -DCMAKE_INSTALL_PREFIX=/tmp \
  97. -DVERSION_EXTRA=$git_hash \
  98. -DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
  99. -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
  100. \
  101. -DENABLE_SOUND=1 \
  102. -DENABLE_CURL=1 \
  103. -DENABLE_GETTEXT=1 \
  104. -DENABLE_FREETYPE=1 \
  105. -DENABLE_LEVELDB=1 \
  106. \
  107. -DIRRLICHT_INCLUDE_DIR=$libdir/irrlicht/include \
  108. -DIRRLICHT_LIBRARY=$libdir/irrlicht/lib/Win32-gcc/libIrrlicht.dll.a \
  109. -DIRRLICHT_DLL=$libdir/irrlicht/bin/Win32-gcc/Irrlicht.dll \
  110. \
  111. -DZLIB_INCLUDE_DIR=$libdir/zlib/include \
  112. -DZLIB_LIBRARIES=$libdir/zlib/lib/libz.dll.a \
  113. -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
  114. \
  115. -DLUA_INCLUDE_DIR=$libdir/luajit/include \
  116. -DLUA_LIBRARY=$libdir/luajit/libluajit.a \
  117. \
  118. -DOGG_INCLUDE_DIR=$libdir/libogg/include \
  119. -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
  120. -DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
  121. \
  122. -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
  123. -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
  124. -DVORBIS_DLL=$libdir/libvorbis/bin/libvorbis-0.dll \
  125. -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
  126. -DVORBISFILE_DLL=$libdir/libvorbis/bin/libvorbisfile-3.dll \
  127. \
  128. -DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include/AL \
  129. -DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \
  130. -DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \
  131. \
  132. -DCURL_DLL=$libdir/libcurl/bin/libcurl-4.dll \
  133. -DCURL_INCLUDE_DIR=$libdir/libcurl/include \
  134. -DCURL_LIBRARY=$libdir/libcurl/lib/libcurl.dll.a \
  135. \
  136. -DGETTEXT_MSGFMT=`which msgfmt` \
  137. -DGETTEXT_DLL=$libdir/gettext/bin/libintl-8.dll \
  138. -DGETTEXT_ICONV_DLL=$libdir/gettext/bin/libiconv-2.dll \
  139. -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
  140. -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
  141. \
  142. -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
  143. -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
  144. -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
  145. -DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
  146. \
  147. -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
  148. -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
  149. -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll \
  150. \
  151. -DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
  152. -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
  153. -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
  154. make -j$(nproc)
  155. [ "x$NO_PACKAGE" = "x" ] && make package
  156. exit 0
  157. # EOF