common.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. CORE_GIT=https://github.com/minetest/minetest
  2. CORE_BRANCH=master
  3. CORE_NAME=minetest
  4. GAME_GIT=https://github.com/minetest/minetest_game
  5. GAME_BRANCH=master
  6. GAME_NAME=minetest_game
  7. ogg_version=1.3.5
  8. openal_version=1.23.0
  9. vorbis_version=1.3.7
  10. curl_version=8.0.1
  11. gettext_version=0.20.2
  12. freetype_version=2.12.1
  13. sqlite3_version=3.41.2
  14. luajit_version=20230221
  15. leveldb_version=1.23
  16. zlib_version=1.2.13
  17. zstd_version=1.5.5
  18. download () {
  19. local url=$1
  20. local filename=$2
  21. [ -z "$filename" ] && filename=${url##*/}
  22. local foldername=${filename%%[.-]*}
  23. local extract=${3:-unzip}
  24. [ -d "./$foldername" ] && return 0
  25. wget "$url" -c -O "./$filename"
  26. if [ "$extract" = "unzip" ]; then
  27. unzip -o "$filename" -d "$foldername"
  28. elif [ "$extract" = "unzip_nofolder" ]; then
  29. unzip -o "$filename"
  30. else
  31. return 1
  32. fi
  33. }
  34. # sets $sourcedir
  35. get_sources () {
  36. if [ -n "$EXISTING_MINETEST_DIR" ]; then
  37. sourcedir="$( cd "$EXISTING_MINETEST_DIR" && pwd )"
  38. return
  39. fi
  40. cd $builddir
  41. sourcedir=$PWD/$CORE_NAME
  42. [ -d $CORE_NAME ] && { pushd $CORE_NAME; git pull --ff-only; popd; } || \
  43. git clone -b $CORE_BRANCH $CORE_GIT $CORE_NAME
  44. if [ -z "$NO_MINETEST_GAME" ]; then
  45. cd $sourcedir
  46. [ -d games/$GAME_NAME ] && { pushd games/$GAME_NAME; git pull --ff-only; popd; } || \
  47. git clone -b $GAME_BRANCH $GAME_GIT games/$GAME_NAME
  48. fi
  49. }
  50. # sets $runtime_dlls
  51. find_runtime_dlls () {
  52. local triple=$1
  53. # Try to find runtime DLLs in various paths (varies by distribution, sigh)
  54. local tmp=$(dirname "$(command -v $compiler)")/..
  55. runtime_dlls=
  56. for name in lib{gcc_,stdc++-,winpthread-}'*'.dll; do
  57. for dir in $tmp/$triple/{bin,lib} $tmp/lib/gcc/$triple/*; do
  58. [ -d "$dir" ] || continue
  59. local file=$(echo $dir/$name)
  60. [ -f "$file" ] && { runtime_dlls+="$file;"; break; }
  61. done
  62. done
  63. if [ -z "$runtime_dlls" ]; then
  64. echo "The compiler runtime DLLs could not be found, they might be missing in the final package."
  65. else
  66. echo "Found DLLs: $runtime_dlls"
  67. fi
  68. }
  69. add_cmake_libs () {
  70. local irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';')
  71. local vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';')
  72. local gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';')
  73. cmake_args+=(
  74. -DCMAKE_PREFIX_PATH=$libdir/irrlicht
  75. -DIRRLICHT_DLL="$irr_dlls"
  76. -DZLIB_INCLUDE_DIR=$libdir/zlib/include
  77. -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a
  78. -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll
  79. -DZSTD_INCLUDE_DIR=$libdir/zstd/include
  80. -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a
  81. -DZSTD_DLL=$libdir/zstd/bin/libzstd.dll
  82. -DLUA_INCLUDE_DIR=$libdir/luajit/include
  83. -DLUA_LIBRARY=$libdir/luajit/libluajit.a
  84. -DOGG_INCLUDE_DIR=$libdir/libogg/include
  85. -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a
  86. -DOGG_DLL=$libdir/libogg/bin/libogg-0.dll
  87. -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include
  88. -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a
  89. -DVORBIS_DLL="$vorbis_dlls"
  90. -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a
  91. -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL
  92. -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a
  93. -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll
  94. -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll
  95. -DCURL_INCLUDE_DIR=$libdir/curl/include
  96. -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a
  97. -DGETTEXT_MSGFMT=`command -v msgfmt`
  98. -DGETTEXT_DLL="$gettext_dlls"
  99. -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include
  100. -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a
  101. -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2
  102. -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2
  103. -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a
  104. -DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll
  105. -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include
  106. -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a
  107. -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll
  108. -DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include
  109. -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a
  110. -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
  111. )
  112. }