#!/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-9 ];  then
ln -sf gcc-9 gcc
ln -sf gcc cc
ln -sf g++-9 g++
ln -sf g++ c++
ln -sf cpp-9 cpp
ln -sf gfortran-9 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-9 ]; then
ln -sf gcov-9 gcov
ln -sf gcov-tool-9 gcov-tool
ln -sf gcov-dump-9 gcov-dump
fi
if [ -a /data/data/com.termux/files/usr/bin/gnat-9 ]; then
	for GNAT in gnat*-9 ; do
		GNAT3=$(echo ${GNAT:0:-2} )
		ln -sf $GNAT $GNAT3
	done
fi
echo "gcc now points to gcc-9"
else 
echo "gcc-9 is not installed"
fi
# The reason i change the platform-clang as well is because python configuration uses that for linker.
