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 win32 compiler is present
24 command -v i686-w64-mingw32-gcc >/dev/null &&
25 compiler=i686-w64-mingw32-gcc
26 command -v i686-w64-mingw32-gcc-posix >/dev/null &&
27 compiler=i686-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/i686-w64-mingw32/{bin,lib} $tmp/lib/gcc/i686-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.0mt5
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
84 # 'dw2' just points to rebuilt versions after a toolchain change
85 # this distinction should be gotten rid of next time
88 download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win32.zip" irrlicht-$irrlicht_version.zip
89 download "http://minetest.kitsunemimi.pw/dw2/zlib-$zlib_version-win32.zip"
90 download "http://minetest.kitsunemimi.pw/zstd-$zstd_version-win32.zip"
91 download "http://minetest.kitsunemimi.pw/libogg-$ogg_version-win32.zip"
92 download "http://minetest.kitsunemimi.pw/dw2/libvorbis-$vorbis_version-win32.zip"
93 download "http://minetest.kitsunemimi.pw/curl-$curl_version-win32.zip"
94 download "http://minetest.kitsunemimi.pw/dw2/gettext-$gettext_version-win32.zip"
95 download "http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win32.zip" freetype-$freetype_version.zip
96 download "http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win32.zip"
97 download "http://minetest.kitsunemimi.pw/dw2/luajit-$luajit_version-win32.zip"
98 download "http://minetest.kitsunemimi.pw/dw2/libleveldb-$leveldb_version-win32.zip" leveldb-$leveldb_version.zip
99 download "http://minetest.kitsunemimi.pw/openal-soft-$openal_version-win32.zip"
101 # Set source dir, downloading Minetest as needed
102 if [ -n "$EXISTING_MINETEST_DIR" ]; then
103 sourcedir="$( cd "$EXISTING_MINETEST_DIR" && pwd )"
106 sourcedir=$PWD/$CORE_NAME
107 [ -d $CORE_NAME ] && { pushd $CORE_NAME; git pull; popd; } || \
108 git clone -b $CORE_BRANCH $CORE_GIT $CORE_NAME
109 if [ -z "$NO_MINETEST_GAME" ]; then
111 [ -d games/$GAME_NAME ] && { pushd games/$GAME_NAME; git pull; popd; } || \
112 git clone -b $GAME_BRANCH $GAME_GIT games/$GAME_NAME
114 rm -f clientmods/mods.conf
115 for mod in $CLIENT_MODS; do
117 [ -d clientmods/$mod ] && { pushd clientmods/$mod; git pull; popd; } || \
118 git clone $GIT_ORG/$mod clientmods/$mod
119 echo "load_mod_$mod = true" >> clientmods/mods.conf
123 git_hash=$(cd $sourcedir && git rev-parse --short HEAD)
127 [ -d build ] && rm -rf build
129 irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';')
130 vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';')
131 gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';')
133 cmake -S $sourcedir -B build \
134 -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
135 -DCMAKE_INSTALL_PREFIX=/tmp \
136 -DVERSION_EXTRA=$git_hash \
137 -DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
138 -DEXTRA_DLL="$runtime_dlls" \
145 -DCMAKE_PREFIX_PATH=$libdir/irrlicht \
146 -DIRRLICHT_DLL="$irr_dlls" \
148 -DZLIB_INCLUDE_DIR=$libdir/zlib/include \
149 -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a \
150 -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
152 -DZSTD_INCLUDE_DIR=$libdir/zstd/include \
153 -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a \
154 -DZSTD_DLL=$libdir/zstd/bin/libzstd.dll \
156 -DLUA_INCLUDE_DIR=$libdir/luajit/include \
157 -DLUA_LIBRARY=$libdir/luajit/libluajit.a \
159 -DOGG_INCLUDE_DIR=$libdir/libogg/include \
160 -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
161 -DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
163 -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
164 -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
165 -DVORBIS_DLL="$vorbis_dlls" \
166 -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
168 -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL \
169 -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a \
170 -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll \
172 -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll \
173 -DCURL_INCLUDE_DIR=$libdir/curl/include \
174 -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a \
176 -DGETTEXT_MSGFMT=`command -v msgfmt` \
177 -DGETTEXT_DLL="$gettext_dlls" \
178 -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
179 -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
181 -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
182 -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
183 -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
184 -DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
186 -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
187 -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
188 -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll \
190 -DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
191 -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
192 -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
194 cmake --build build -j$(nproc)
196 [ -z "$NO_PACKAGE" ] && cmake --build build --target package