common.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. CORE_GIT=https://github.com/minetest/minetest
  2. CORE_BRANCH=master
  3. CORE_NAME=minetest
  4. ogg_version=1.3.5
  5. openal_version=1.23.1
  6. vorbis_version=1.3.7
  7. curl_version=8.5.0
  8. gettext_version=0.20.2
  9. freetype_version=2.13.2
  10. sqlite3_version=3.44.2
  11. luajit_version=20240125
  12. leveldb_version=1.23
  13. zlib_version=1.3.1
  14. zstd_version=1.5.5
  15. libjpeg_version=3.0.1
  16. libpng_version=1.6.40
  17. sdl2_version=2.30.3
  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. sha256sum -w -c <(grep -F "$filename" "$topdir/sha256sums.txt")
  27. if [ "$extract" = "unzip" ]; then
  28. unzip -o "$filename" -d "$foldername"
  29. elif [ "$extract" = "unzip_nofolder" ]; then
  30. unzip -o "$filename"
  31. else
  32. return 1
  33. fi
  34. }
  35. # sets $sourcedir
  36. get_sources () {
  37. if [ -n "$EXISTING_MINETEST_DIR" ]; then
  38. sourcedir="$( cd "$EXISTING_MINETEST_DIR" && pwd )"
  39. return
  40. fi
  41. cd $builddir
  42. sourcedir=$PWD/$CORE_NAME
  43. [ -d $CORE_NAME ] && { pushd $CORE_NAME; git pull --ff-only; popd; } || \
  44. git clone -b $CORE_BRANCH $CORE_GIT $CORE_NAME
  45. }
  46. # sets $runtime_dlls
  47. find_runtime_dlls () {
  48. local triple=$1
  49. # Try to find runtime DLLs in various paths
  50. local tmp=$(dirname "$(command -v $compiler)")/..
  51. runtime_dlls=
  52. for name in lib{clang_rt,c++,unwind,winpthread-}'*'.dll; do
  53. for dir in $tmp/$triple/{bin,lib}; do
  54. [ -d "$dir" ] || continue
  55. local file=$(echo $dir/$name)
  56. [ -f "$file" ] && { runtime_dlls+="$file;"; break; }
  57. done
  58. done
  59. if [ -z "$runtime_dlls" ]; then
  60. echo "The compiler runtime DLLs could not be found, they might be missing in the final package."
  61. else
  62. echo "Found DLLs: $runtime_dlls"
  63. fi
  64. }
  65. _dlls () {
  66. for f in "$@"; do
  67. if [ ! -e "$f" ]; then
  68. echo "Could not find $f" >&2
  69. elif [[ -f "$f" && "$f" == *.dll ]]; then
  70. printf '%s;' "$f"
  71. fi
  72. done
  73. }
  74. add_cmake_libs () {
  75. cmake_args+=(
  76. -DPNG_LIBRARY=$libdir/libpng/lib/libpng.dll.a
  77. -DPNG_PNG_INCLUDE_DIR=$libdir/libpng/include
  78. -DPNG_DLL="$(_dlls $libdir/libpng/bin/*)"
  79. -DJPEG_LIBRARY=$libdir/libjpeg/lib/libjpeg.dll.a
  80. -DJPEG_INCLUDE_DIR=$libdir/libjpeg/include
  81. -DJPEG_DLL="$(_dlls $libdir/libjpeg/bin/libjpeg*)"
  82. -DCMAKE_PREFIX_PATH=$libdir/sdl2/lib/cmake
  83. -DSDL2_DLL="$(_dlls $libdir/sdl2/bin/*)"
  84. -DZLIB_INCLUDE_DIR=$libdir/zlib/include
  85. -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a
  86. -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll
  87. -DZSTD_INCLUDE_DIR=$libdir/zstd/include
  88. -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a
  89. -DZSTD_DLL=$libdir/zstd/bin/libzstd.dll
  90. -DLUA_INCLUDE_DIR=$libdir/luajit/include
  91. -DLUA_LIBRARY=$libdir/luajit/libluajit.a
  92. -DOGG_INCLUDE_DIR=$libdir/libogg/include
  93. -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a
  94. -DOGG_DLL="$(_dlls $libdir/libogg/bin/*)"
  95. -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include
  96. -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a
  97. -DVORBIS_DLL="$(_dlls $libdir/libvorbis/bin/libvorbis{,file}[-.]*)"
  98. -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a
  99. -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL
  100. -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a
  101. -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll
  102. -DCURL_DLL="$(_dlls $libdir/curl/bin/libcurl*)"
  103. -DCURL_INCLUDE_DIR=$libdir/curl/include
  104. -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a
  105. -DGETTEXT_MSGFMT=`command -v msgfmt`
  106. -DGETTEXT_DLL="$(_dlls $libdir/gettext/bin/lib{intl,iconv}*)"
  107. -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include
  108. -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a
  109. -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2
  110. -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2
  111. -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a
  112. -DFREETYPE_DLL="$(_dlls $libdir/freetype/bin/libfreetype*)"
  113. -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include
  114. -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a
  115. -DSQLITE3_DLL="$(_dlls $libdir/sqlite3/bin/libsqlite*)"
  116. -DLEVELDB_INCLUDE_DIR=$libdir/libleveldb/include
  117. -DLEVELDB_LIBRARY=$libdir/libleveldb/lib/libleveldb.dll.a
  118. -DLEVELDB_DLL=$libdir/libleveldb/bin/libleveldb.dll
  119. )
  120. }