4 GIT_ORG=https://github.com/dragonfireclient
5 CORE_GIT=$GIT_ORG/dragonfireclient
7 CORE_NAME=dragonfireclient
8 GAME_GIT=https://git.minetest.land/MineClone2/MineClone2
11 CLIENT_MODS="autotool diglib digcustom nametags autokey autoeat invutil killaura worldutil physics_override noweather chateffects simpletp"
13 dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
15 echo "Usage: $0 <build directory>"
20 builddir="$( cd "$builddir" && pwd )"
23 # Test which win64 compiler is present
24 command -v x86_64-w64-mingw32-gcc >/dev/null &&
25 compiler=x86_64-w64-mingw32-gcc
26 command -v x86_64-w64-mingw32-gcc-posix >/dev/null &&
27 compiler=x86_64-w64-mingw32-gcc-posix
29 if [ -z "$compiler" ]; then
30 echo "Unable to determine which MinGW compiler to use"
33 toolchain_file=$dir/toolchain_${compiler/-gcc/}.cmake
34 echo "Using $toolchain_file"
36 # Try to find runtime DLLs in various paths (varies by distribution, sigh)
37 tmp=$(dirname "$(command -v $compiler)")/..
39 for name in lib{gcc_,stdc++-,winpthread-}'*'.dll; do
40 for dir in $tmp/x86_64-w64-mingw32/{bin,lib} $tmp/lib/gcc/x86_64-w64-mingw32/*; do
41 [ -d "$dir" ] || continue
42 file=$(echo $dir/$name)
43 [ -f "$file" ] && { runtime_dlls+="$file;"; break; }
46 [ -z "$runtime_dlls" ] &&
47 echo "The compiler runtime DLLs could not be found, they might be missing in the final package."
50 irrlicht_version=1.9.0mt6
55 gettext_version=0.20.1
56 freetype_version=2.11.1
57 sqlite3_version=3.37.2
58 luajit_version=2.1.0-beta3
68 [ -z "$filename" ] && filename=${url##*/}
69 local foldername=${filename%%[.-]*}
71 [ -z "$extract" ] && extract=unzip
73 [ -d "./$foldername" ] && return 0
74 wget "$url" -c -O "./$filename"
75 if [ "$extract" = "unzip" ]; then
76 unzip -o "$filename" -d "$foldername"
77 elif [ "$extract" = "unzip_nofolder" ]; then
85 download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win64.zip" irrlicht-$irrlicht_version.zip
86 download "http://minetest.kitsunemimi.pw/zlib-$zlib_version-win64.zip"
87 download "http://minetest.kitsunemimi.pw/zstd-$zstd_version-win64.zip"
88 download "http://minetest.kitsunemimi.pw/libogg-$ogg_version-win64.zip"
89 download "http://minetest.kitsunemimi.pw/libvorbis-$vorbis_version-win64.zip"
90 download "http://minetest.kitsunemimi.pw/curl-$curl_version-win64.zip"
91 download "http://minetest.kitsunemimi.pw/gettext-$gettext_version-win64.zip"
92 download "http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win64.zip" freetype-$freetype_version.zip
93 download "http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win64.zip"
94 download "http://minetest.kitsunemimi.pw/luajit-$luajit_version-win64.zip"
95 download "http://minetest.kitsunemimi.pw/libleveldb-$leveldb_version-win64.zip" leveldb-$leveldb_version.zip
96 download "http://minetest.kitsunemimi.pw/openal-soft-$openal_version-win64.zip"
98 # Set source dir, downloading Minetest as needed
99 if [ -n "$EXISTING_MINETEST_DIR" ]; then
100 sourcedir="$( cd "$EXISTING_MINETEST_DIR" && pwd )"
103 sourcedir=$PWD/$CORE_NAME
104 [ -d $CORE_NAME ] && { pushd $CORE_NAME; git pull; popd; } || \
105 git clone -b $CORE_BRANCH $CORE_GIT $CORE_NAME
106 if [ -z "$NO_MINETEST_GAME" ]; then
108 [ -d games/$GAME_NAME ] && { pushd games/$GAME_NAME; git pull; popd; } || \
109 git clone -b $GAME_BRANCH $GAME_GIT games/$GAME_NAME
111 rm -f clientmods/mods.conf
112 for mod in $CLIENT_MODS; do
114 [ -d clientmods/$mod ] && { pushd clientmods/$mod; git pull; popd; } || \
115 git clone $GIT_ORG/$mod clientmods/$mod
116 echo "load_mod_$mod = true" >> clientmods/mods.conf
119 [ -d clientmods/lua_async ] && { pushd clientmods/lua_async; git pull; popd; } || \
120 git clone --recursive https://github.com/EliasFleckenstein03/lua_async_mt clientmods/lua_async
121 echo "load_mod_lua_async = true" >> clientmods/mods.conf
124 git_hash=$(cd $sourcedir && git rev-parse --short HEAD)
128 [ -d build ] && rm -rf build
130 irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';')
131 vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';')
132 gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';')
134 cmake -S $sourcedir -B build \
135 -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
136 -DCMAKE_INSTALL_PREFIX=/tmp \
137 -DVERSION_EXTRA=$git_hash \
138 -DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
139 -DEXTRA_DLL="$runtime_dlls" \
146 -DCMAKE_PREFIX_PATH=$libdir/irrlicht \
147 -DIRRLICHT_DLL="$irr_dlls" \
149 -DZLIB_INCLUDE_DIR=$libdir/zlib/include \
150 -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a \
151 -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
153 -DZSTD_INCLUDE_DIR=$libdir/zstd/include \
154 -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a \
155 -DZSTD_DLL=$libdir/zstd/bin/libzstd.dll \
157 -DLUA_INCLUDE_DIR=$libdir/luajit/include \
158 -DLUA_LIBRARY=$libdir/luajit/libluajit.a \
160 -DOGG_INCLUDE_DIR=$libdir/libogg/include \
161 -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
162 -DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
164 -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
165 -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
166 -DVORBIS_DLL="$vorbis_dlls" \
167 -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
169 -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL \
170 -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a \
171 -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll \
173 -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll \
174 -DCURL_INCLUDE_DIR=$libdir/curl/include \
175 -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a \
177 -DGETTEXT_MSGFMT=`command -v msgfmt` \
178 -DGETTEXT_DLL="$gettext_dlls" \
179 -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
180 -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
182 -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
183 -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
184 -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
185 -DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
187 -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
188 -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
189 -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll \
191 -DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
192 -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
193 -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
195 cmake --build build -j$(nproc)
197 [ -z "$NO_PACKAGE" ] && cmake --build build --target package