#https://github.com/GTAmodding/re3/wiki/Building-on-Linux
#https://github.com/GTAmodding/re3
glibc="$(ldd --version | awk '/ldd/{print $NF}')"
#
#INSTALLING CMAKE 3.21 IF YOU ALREADY HAVE THIS VERSION OR NEWER THEN COMMENT THE NEXT STEPS
###CMAKE 3.21 START HERE###########
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
sudo apt-get update
####CMAKE 3.21 END HERE##########
sudo apt install cmake git python3-pip libgl1-mesa-dev
git clone --recursive https://github.com/GTAmodding/re3.git
sudo pip3 install conan
cd re3
conan export vendor/librw librw/master@
mkdir build
cd build
conan install .. re3/master@ -if build -o re3:audio=openal -o librw:platform=gl3 -o librw:gl3_gfxlib=glfw --build missing -s re3:build_type=RelWithDebInfo -s librw:build_type=RelWithDebInfo
conan build .. -if build -bf build -pf package
strip build/re3/src/re3
cp build/re3/src/re3 ../gamefiles/
cd ../gamefiles
7za a -mx -r ../gt3.re3_x86_64_GLIBC_"$glibc".7z
echo "RE3 GIT VERSION for GTA3 COMPILED AND COMPRESSED WITH THE FILENAME gt3.re3_x86_64_GIT_VERSION_GLIBC_"$glibc".7z"
