#!/bin/sh

export PATH="${HOMEBREW_PREFIX}/opt/llvm/bin:$PATH"
export OPENJKDF2_RELEASE_COMMIT=$(git log -1 --format="%H")
export OPENJKDF2_RELEASE_COMMIT_SHORT=$(git rev-parse --short=8 HEAD)

#cp DF2/player_bak/Max/Max.plr ~/.local/share/openjkdf2/player/Max/Max.plr
#OPENJKDF2_NO_ASAN=1 DEBUG_QOL_CHEATS=1 make -f Makefile.macos -j10 &&
mkdir -p build_darwin64 && cd build_darwin64

#mkdir -p build_protoc && cd build_protoc
#cmake -DCMAKE_BUILD_TYPE=Release -DProtobuf_BUILD_TESTS=OFF ../../3rdparty/protobuf/cmake
#make -j10 protoc
#cd ..

#mkdir -p build_protobuf && cd build_protobuf
#cmake -DCMAKE_INSTALL_PREFIX=. -DCMAKE_BUILD_TYPE=Release -DProtobuf_BUILD_TESTS=OFF -DProtobuf_BUILD_SHARED_LIBS=ON ../../3rdparty/protobuf/cmake
#make -j10 install
#cd ..

#mkdir -p build_gns && cd build_gns
#GNS_BUILD=$(pwd)
export PKG_CONFIG_PATH_OLD=$PKG_CONFIG_PATH
#export PKG_CONFIG_PATH=$PKG_CONFIG_PATH_OLD:${HOMEBREW_PREFIX}/opt/openssl@1.1/lib/pkgconfig
#cmake -DCMAKE_BUILD_TYPE=Release -DProtobuf_USE_STATIC_LIBS=ON -DProtobuf_LIBRARIES="-L$GNS_BUILD/../build_protobuf/lib" -DProtobuf_LIBRARIES_PATH="$GNS_BUILD/../build_protobuf/lib" -DProtobuf_INCLUDE_DIR=$GNS_BUILD/../../3rdparty/protobuf/src -DProtobuf_INCLUDE_DIR2=$GNS_BUILD/../build_protobuf/include -DProtobuf_PROTOC_EXECUTABLE=$GNS_BUILD/../build_protoc/protoc $GNS_BUILD/../../3rdparty/GameNetworkingSockets
#make -j10
#cd ..

#mkdir -p build_physfs && cd build_physfs
#PHYSFS_BUILD=$(pwd)
#cmake -DCMAKE_BUILD_TYPE=Release -DPHYSFS_ARCHIVE_GRP=FALSE -DPHYSFS_ARCHIVE_WAD=FALSE -DPHYSFS_ARCHIVE_HOG=FALSE -DPHYSFS_ARCHIVE_MVL=FALSE -DPHYSFS_ARCHIVE_QPAK=FALSE -DPHYSFS_ARCHIVE_SLB=FALSE -DPHYSFS_ARCHIVE_VDF=FALSE $PHYSFS_BUILD/../../3rdparty/physfs
#make -j10
#cd ..

cmake .. &&
make -j10 &&
cd ..
