# Shadow build is necessary for a successful GCC build (at least for 4.9.2).
cd "$SRCDIR"/abbuild

abinfo "Installing libgccjit (with some files going to be overrided by general GCC) ..."
make install \
    -C "$SRCDIR"/jitbuild \
    DESTDIR="$PKGDIR"

abinfo "Installing GCC ..."
make install \
    DESTDIR="$PKGDIR"

abinfo "Generating Python code cache ..."
python3 -m compileall \
    "$PKGDIR"/usr/share/gcc-$PKGVER/python

if [ -d "$PKGDIR"/usr/lib64 ]; then
    abinfo "Moving /usr/lib64 => /usr/lib ..."
    cp -arv "$PKGDIR"/usr/lib{64/*,/}
    rm -rv "$PKGDIR"/usr/lib64
fi

if [ -d "$PKGDIR"/usr/lib32 ]; then
    abinfo "Moving /usr/lib32 => /usr/lib ..."
    cp -arv "$PKGDIR"/usr/lib{32/*,/}
    rm -rv "$PKGDIR"/usr/lib32
fi
