# Check version consistency.
MAJOR="${PKGVER%%.*}"
if [ "${PKGNAME/$MAJOR/}" == "$PKGNAME" ] ; then
	abdie "Either version or PKGNAME is wrong: ‘$PKGNAME’ with version ‘$PKGVER’."
fi

# Note: You will see this in "gcc -v" output.
#
# BASE-VER identifies the GCC version, please DO NOT EDIT.
# * DEV-PHASE are used as branding identification, you may alter the line.
abinfo "Appending AOSC versions to gcc -v ..."
echo 'AOSC OS' > "$SRCDIR"/gcc/DEV-PHASE

abinfo "Stripping pre-defined configure options ..."
export AUTOTOOLS_DEF=""

abinfo 'GCC passes only CPPFLAGS in some stages, appending other flags to $CPPFLAGS ...'
export CPPFLAGS="${CPPFLAGS} -O3 ${CFLAGS_COMMON_ARCH}"

abinfo "Configuring libgccjit ..."
mkdir -pv "$SRCDIR"/jitbuild
cd "$SRCDIR"/jitbuild
"$SRCDIR"/configure \
    ${AUTOTOOLS_DEF[@]} \
    ${AUTOTOOLS_AFTER[@]} \
    --disable-bootstrap \
    --enable-host-shared \
    --enable-languages=jit \
    --build="${ARCH_TARGET[$ARCH]}" \
    --host="${ARCH_TARGET[$ARCH]}"

abinfo "Building libgccjit ..."
make
