#! /bin/bash

#DEF
export QT_VERSION=5
export COMPILER=GCC
export BIT=64

POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do
  case $1 in
    -q|--qt)
      export QT_VERSION="$2"
      shift # past argument
      shift # past value
      ;;
    -c|--compiler)
      export COMPILER="$2"
      shift # past argument
      shift # past value
      ;;
    -b|--bit)
      export BIT="$2"
      shift # past argument
      shift # past value
      ;;
    -*|--*)
      echo "Unknown option $1"
      exit 1
      ;;
    *)
      POSITIONAL_ARGS+=("$1") # save positional arg
      shift # past argument
      ;;
  esac
done



set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters


export PATH_DEVELOP=/opt/ANDevelop

. $PATH_DEVELOP/enviroment.sh

export OTHER_LIBS=$(echo "$LD_LIBRARY_PATH" | sed -r 's/[:]+/,/g'),/usr/lib/SharedLibs

if [[ "$QT_VERSION" = "6" ]]
then
export QMAKE_PATH=/opt/ANDevelop/tools/x86_64-linux-gnu/x86_64-ubuntu12.04-linux-gnu/sysroot/opt/qt/6.7.1.3/usr/bin/qmake
export OTHER_LIBS=/opt/ANDevelop/tools/x86_64-linux-gnu/x86_64-ubuntu12.04-linux-gnu/sysroot/usr/lib
else
export QMAKE_PATH=/opt/ANDevelop/tools/x86_64-linux-gnu/x86_64-ubuntu12.04-linux-gnu/sysroot/opt/qt/5.15.14.2/usr/bin/qmake
export OTHER_LIBS=/opt/ANDevelop/tools/x86_64-linux-gnu/x86_64-ubuntu12.04-linux-gnu/sysroot/usr/lib
fi

if [[ "$COMPILER" = "CLANG" ]]
then
#export CC=$PATH_DEVELOP/llvm-$LLVM_VERSION/bin/clang
#export CXX=$PATH_DEVELOP/llvm-$LLVM_VERSION/bin/clang++
export CMD_BUILD_LINUX="-makefile -o Makefile -r -spec linux-clang-g++"
else
#export CC=$PATH_DEVELOP/gcc-$GCC_VERSION/bin/gcc
#export CXX=$PATH_DEVELOP/gcc-$GCC_VERSION/bin/g++
export CMD_BUILD_LINUX="-makefile -o Makefile -r -spec linux-g++"
fi


echo QT_VERSION: $QT_VERSION
echo COMPILER: $COMPILER
echo BIT: $BIT
echo OTHER_LIBS: $OTHER_LIBS
echo QMAKE_PATH: $QMAKE_PATH
echo CMD_BUILD_LINUX: $CMD_BUILD_LINUX
echo CC: $CC
echo CXX: $CXX
