#!/data/data/com.termux/files/usr/bin/bash
ARCH=$(dpkg --print-architecture)
PLATFORM=${ARCH}-linux-android
if [ $ARCH == "arm" ];
then export PLATFORM=arm-linux-androideabi
fi
cd /data/data/com.termux/files/usr/bin/
if [ -a /data/data/com.termux/files/usr/bin/gcc-8 ];  then
ln -sf gcc-8 gcc
ln -sf gcc cc
ln -sf g++-8 g++
ln -sf g++ c++
ln -sf cpp-8 cpp
ln -sf gfortran-8 gfortran 
ln -sf gcc ${PLATFORM}-gcc
ln -sf g++ ${PLATFORM}-g++
ln -sf cpp ${PLATFORM}-cpp
ln -sf g++ ${PLATFORM}-clang++
ln -sf gcc ${PLATFORM}-clang
ln -sf /data/data/com.termux/files/usr/lib/libgfortran.so.5 /data/data/com.termux/files/usr/lib/libgfortran.so
if [ -a /data/data/com.termux/files/usr/bin/gcov-8 ]; then
ln -sf gcov-8 gcov
ln -sf gcov-tool-8 gcov-tool
ln -sf gcov-dump-8 gcov-dump
fi
if [ -a /data/data/com.termux/files/usr/bin/gnat-8 ]; then
	for GNAT in gnat*-8 ; do
		GNAT3=$(echo ${GNAT:0:-2} )
		ln -sf $GNAT $GNAT3
	done
fi

echo "gcc now points to gcc-8"
else 
echo "gcc-8 is not installed"
fi
# The reason i change the platform-clang as well is because python configuration uses that for linker.
