buildwin64.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. libdir=$builddir/libs
  18. # Test which win64 compiler is present
  19. which x86_64-w64-mingw32-gcc &>/dev/null &&
  20. toolchain_file=$dir/toolchain_x86_64-w64-mingw32.cmake
  21. which x86_64-w64-mingw32-gcc-posix &>/dev/null &&
  22. toolchain_file=$dir/toolchain_x86_64-w64-mingw32-posix.cmake
  23. if [ -z "$toolchain_file" ]; then
  24. echo "Unable to determine which mingw32 compiler to use"
  25. exit 1
  26. fi
  27. echo "Using $toolchain_file"
  28. irrlicht_version=1.9.0mt3
  29. ogg_version=1.3.4
  30. vorbis_version=1.3.7
  31. curl_version=7.76.1
  32. gettext_version=0.20.1
  33. freetype_version=2.10.4
  34. sqlite3_version=3.35.5
  35. luajit_version=2.1.0-beta3
  36. leveldb_version=1.23
  37. zlib_version=1.2.11
  38. zstd_version=1.4.9
  39. mkdir -p $libdir
  40. download () {
  41. local url=$1
  42. local filename=$2
  43. [ -z "$filename" ] && filename=${url##*/}
  44. local foldername=${filename%%[.-]*}
  45. local extract=$3
  46. [ -z "$extract" ] && extract=unzip
  47. [ -d "./$foldername" ] && return 0
  48. wget "$url" -c -O "./$filename"
  49. if [ "$extract" = "unzip" ]; then
  50. unzip -o "$filename" -d "$foldername"
  51. elif [ "$extract" = "unzip_nofolder" ]; then
  52. unzip -o "$filename"
  53. else
  54. return 1
  55. fi
  56. }
  57. # Get stuff
  58. cd $libdir
  59. download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win64.zip" irrlicht-$irrlicht_version.zip
  60. download "http://minetest.kitsunemimi.pw/zlib-$zlib_version-win64.zip"
  61. download "http://minetest.kitsunemimi.pw/zstd-$zstd_version-win64.zip"
  62. download "http://minetest.kitsunemimi.pw/libogg-$ogg_version-win64.zip"
  63. download "http://minetest.kitsunemimi.pw/libvorbis-$vorbis_version-win64.zip"
  64. download "http://minetest.kitsunemimi.pw/curl-$curl_version-win64.zip"
  65. download "http://minetest.kitsunemimi.pw/gettext-$gettext_version-win64.zip"
  66. download "http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win64.zip" freetype-$freetype_version.zip
  67. download "http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win64.zip"
  68. download "http://minetest.kitsunemimi.pw/luajit-$luajit_version-win64.zip"
  69. download "http://minetest.kitsunemimi.pw/libleveldb-$leveldb_version-win64.zip" leveldb-$leveldb_version.zip
  70. download "http://minetest.kitsunemimi.pw/openal_stripped64.zip" 'openal_stripped.zip' unzip_nofolder
  71. # Set source dir, downloading Minetest as needed
  72. if [ -n "$EXISTING_MINETEST_DIR" ]; then
  73. sourcedir="$( cd "$EXISTING_MINETEST_DIR" && pwd )"
  74. else
  75. sourcedir=$PWD/$CORE_NAME
  76. [ -d $CORE_NAME ] && { pushd $CORE_NAME; git pull; popd; } || \
  77. git clone -b $CORE_BRANCH $CORE_GIT $CORE_NAME
  78. if [ -z "$NO_MINETEST_GAME" ]; then
  79. [ -d games/$GAME_NAME ] && { pushd games/$GAME_NAME; git pull; popd; } || \
  80. git clone -b $GAME_BRANCH $GAME_GIT games/$GAME_NAME
  81. fi
  82. fi
  83. git_hash=$(cd $sourcedir && git rev-parse --short HEAD)
  84. # Build the thing
  85. cd $builddir
  86. [ -d build ] && rm -rf build
  87. mkdir build
  88. cd build
  89. irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';')
  90. vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';')
  91. gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';')
  92. cmake -S $sourcedir -B . \
  93. -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
  94. -DCMAKE_INSTALL_PREFIX=/tmp \
  95. -DVERSION_EXTRA=$git_hash \
  96. -DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
  97. \
  98. -DENABLE_SOUND=1 \
  99. -DENABLE_CURL=1 \
  100. -DENABLE_GETTEXT=1 \
  101. -DENABLE_FREETYPE=1 \
  102. -DENABLE_LEVELDB=1 \
  103. \
  104. -DCMAKE_PREFIX_PATH=$libdir/irrlicht \
  105. -DIRRLICHT_DLL="$irr_dlls" \
  106. \
  107. -DZLIB_INCLUDE_DIR=$libdir/zlib/include \
  108. -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a \
  109. -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
  110. \
  111. -DZSTD_INCLUDE_DIR=$libdir/zstd/include \
  112. -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a \
  113. -DZSTD_DLL=$libdir/zstd/bin/libzstd.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="$vorbis_dlls" \
  125. -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
  126. \
  127. -DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include/AL \
  128. -DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \
  129. -DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \
  130. \
  131. -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll \
  132. -DCURL_INCLUDE_DIR=$libdir/curl/include \
  133. -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a \
  134. \
  135. -DGETTEXT_MSGFMT=`which msgfmt` \
  136. -DGETTEXT_DLL="$gettext_dlls" \
  137. -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
  138. -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
  139. \
  140. -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
  141. -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
  142. -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
  143. -DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
  144. \
  145. -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
  146. -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
  147. -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll \
  148. \
  149. -DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
  150. -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
  151. -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
  152. make -j$(nproc)
  153. [ -z "$NO_PACKAGE" ] && make package
  154. exit 0
  155. # EOF