### macOS
Darkplaces loads `libjpeg.62.dylib`
+# zlib
+zlib is required to read *.pk3 files. Also it is a dependency of libpng and probably some other libraries.
+
+### Windows
+Darkplaces loads: ifdef ZLIB_USES_WINAPI `zlibwapi.dll` or `zlib.dll` else `zlib1.dll`. We use `zlib1.dll`!
+
+Obtainment instructions:
+* download as MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-zlib
+* use dll from `bin` folder
+
+Cross-compiling: ** TODO : Remove the "lib" prefix so libpng can load it properly later! **
+
+```
+ZLIBVER="1.2.11"
+curl -L -o zlib-$ZLIBVER.tar.xz https://zlib.net/zlib-$ZLIBVER.tar.xz || true
+tar -xf zlib-$ZLIBVER.tar.xz
+rm zlib-$ZLIBVER.tar.xz
+curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
+
+d0=$(pwd)
+rm -rf build
+mkdir build
+cd build
+sed -i '/zlib PROPERTIES SUFFIX/i set_target_properties(zlib PROPERTIES PREFIX "")' "$d0/zlib-$ZLIBVER/CMakeLists.txt" # Remove the "lib" prefix. TODO Do this through the cmake cache?
+cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DBUILD_SHARED_LIBS=true -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/zlib-$ZLIBVER"
+make
+make install
+cd "$d0"
+cp out/bin/zlib1.dll ~/Games/xonotic/misc/buildfiles/win64/zlib1.dll
+```
+
+### macOS
+Darkplaces loads `libz.dylib`
+
# libpng
libpng is needed to display png images/textures
* download MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-libpng
* use dll from `bin` folder
-### macOS
-Darkplaces loads `libpng16.16.dylib` or `libpng15.15.dylib` or `libpng14.14.dylib` or `libpng12.0.dylib`
+Cross-compiling: (WARNING: RESULTING LIBRARY DOESN'T LOAD - THIS MUST BE ADJUSTED!)
-# zlib
-zlib is required to read *.pk3 files. Also it is a dependency of libpng and probably some other libraries.
+```
+d0=$(pwd)
+PNGVER="libpng16"
+ZLIB_ROOT=$d0/../zlib/out # Location to the zlib compiled library
-### Windows
-Darkplaces loads: ifdef ZLIB_USES_WINAPI `zlibwapi.dll` or `zlib.dll` else `zlib1.dll`. We use `zlib1.dll`!
+git clone -b $PNGVER git://git.code.sf.net/p/libpng/code libpng || true
+curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
-Obtainment instructions:
-* download as MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-zlib
-* use dll from `bin` folder
+rm -rf build
+mkdir build
+cd build
+cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DPNG_STATIC=false -DPNG_TESTS=false -DPNG_EXECUTABLES=false -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DZLIB_INCLUDE_DIR=$ZLIB_ROOT/include -DZLIB_LIBRARY=$ZLIB_ROOT/lib/libzlib.dll.a -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/libpng"
+make
+make install
+cd "$d0"
+cp out/bin/libpng16.dll ~/Games/xonotic/misc/buildfiles/win64/libpng16.dll
+```
### macOS
-Darkplaces loads `libz.dylib`
+Darkplaces loads `libpng16.16.dylib` or `libpng15.15.dylib` or `libpng14.14.dylib` or `libpng12.0.dylib`
# libfreetype
Required for the Xolonium font
Darkplaces loads: `libfreetype-6.dll` or `freetype6.dll`
```
-VER="2.11.1"
-curl -L -o freetype-$VER.tar.xz https://download.savannah.gnu.org/releases/freetype/freetype-$VER.tar.xz || true
-tar -xf freetype-$VER.tar.xz
-rm freetype-$VER.tar.xz
+FTVER="2.11.1"
+curl -L -o freetype-$FTVER.tar.xz https://download.savannah.gnu.org/releases/freetype/freetype-$FTVER.tar.xz || true
+tar -xf freetype-$FTVER.tar.xz
+rm freetype-$FTVER.tar.xz
curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
d0=$(pwd)
rm -rf build
mkdir build
cd build
-cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DBUILD_SHARED_LIBS=true -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/freetype-$VER"
+cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DBUILD_SHARED_LIBS=true -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/freetype-$FTVER"
make
make install
cd "$d0"
* download MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-libogg
* use dll from `bin` folder
+Cross-compiling:
+
+```
+OGGVER="v1.3.5"
+git clone -b $OGGVER https://gitlab.xiph.org/xiph/ogg.git
+curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
+d0=$(pwd)
+rm -rf build
+mkdir build
+cd build
+cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DBUILD_SHARED_LIBS=true -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/ogg"
+make
+make install
+cd "$d0"
+cp out/bin/libogg.dll ~/Games/xonotic/misc/buildfiles/win64/libogg.dll
+```
+
### macOS
Darkplaces loads `libogg.dylib`