if [ "$OPTIMIZATIONS" = fast ];then
  GCC_OPTIM="-Ofast"
  GCC_OPTIM="$GCC_OPTIM -fexcess-precision=fast"
  LD_OPTIM="-Wl,--as-needed"
fi

if [ "$OPTIMIZATIONS" = speed ];then
  GCC_OPTIM="$GCC_OPTIM -O3"
  GCC_OPTIM="$GCC_OPTIM -fexcess-precision=fast"
  GCC_OPTIM="$GCC_OPTIM -ffast-math"
  LD_OPTIM="-Wl,--as-needed"
fi

if [ "$OPTIMIZATIONS" = normal ];then
  GCC_OPTIM="$GCC_OPTIM -O2"
  LD_OPTIM=""
fi

if [ "$OPTIMIZATIONS" = size ];then
  GCC_OPTIM="$GCC_OPTIM -Os"
  GCC_OPTIM="$GCC_OPTIM -fexcess-precision=fast"
  GCC_OPTIM="$GCC_OPTIM -ffast-math"
  LD_OPTIM="-Wl,--as-needed"
fi

if [ "$LTO_SUPPORT" = yes ];then
  GCC_OPTIM="$GCC_OPTIM -flto"
  LD_OPTIM="$LD_OPTIM -fuse-linker-plugin"
  LD_OPTIM="$LD_OPTIM -flto"
fi

if [ "$DEBUG" = yes ]; then
  TARGET_CFLAGS="$TARGET_CFLAGS -ggdb"
  TARGET_CXXFLAGS="$TARGET_CXXFLAGS -ggdb"
  TARGET_LDFLAGS="$TARGET_LDFLAGS -ggdb"
else
  TARGET_CFLAGS="$TARGET_CFLAGS -fomit-frame-pointer"
  TARGET_CXXFLAGS="$TARGET_CXXFLAGS -fomit-frame-pointer"
  TARGET_LDFLAGS="$TARGET_LDFLAGS -s"
fi

TARGET_CPPFLAGS=
TARGET_CFLAGS="$TARGET_CFLAGS -Wall -pipe $GCC_OPTIM $PROJECT_CFLAGS"
TARGET_CXXFLAGS="$TARGET_CFLAGS"
TARGET_LDFLAGS="$TARGET_LDFLAGS $LD_OPTIM $GCC_OPTIM"
TARGET_LIBDIR="$SYSROOT_PREFIX/lib $SYSROOT_PREFIX/usr/lib"
TARGET_INCDIR="$SYSROOT_PREFIX/include $SYSROOT_PREFIX/usr/include"

HOST_CPPFLAGS=""
HOST_CFLAGS="-O2 -Wall -pipe -I$ROOT/$TOOLCHAIN/include"
HOST_CXXFLAGS="$HOST_CFLAGS"
HOST_LDFLAGS="-Wl,-rpath,$ROOT/$TOOLCHAIN/lib -L$ROOT/$TOOLCHAIN/lib"
HOST_LIBDIR="$ROOT/$TOOLCHAIN/lib"

# add distro specific library dirs
  # ubuntu/debian specific "multiarch support"
    FAMILY_TRIPLET=$(echo $HOST_NAME | sed -e "s,$(uname -m),$(uname -i),")
    if [ -d /lib/$FAMILY_TRIPLET ]; then
      HOST_LIBDIR="$HOST_LIBDIR /lib/$FAMILY_TRIPLET"
    fi
    if [ -d /usr/lib/$FAMILY_TRIPLET ]; then
      HOST_LIBDIR="$HOST_LIBDIR /usr/lib/$FAMILY_TRIPLET"
    fi

  # default multiarch support
    case "`uname -m`" in
      i*86)
        if [ -d /lib32 ]; then
          HOST_LIBDIR="$HOST_LIBDIR /lib32"
        fi
        if [ -d /usr/lib32 ]; then
          HOST_LIBDIR="$HOST_LIBDIR /usr/lib32"
        fi
      ;;
      x86_64)
        if [ -d /lib64 ]; then
          HOST_LIBDIR="$HOST_LIBDIR /lib64"
        fi
        if [ -d /usr/lib64 ]; then
          HOST_LIBDIR="$HOST_LIBDIR /usr/lib64"
        fi
      ;;
    esac

  # default dirs
    HOST_LIBDIR="$HOST_LIBDIR /lib /usr/lib"
    HOST_INCDIR="$ROOT/$TOOLCHAIN/include /usr/include"
