ln -sf python-2.7.pc \
    "$PKGDIR"/usr/lib/pkgconfig/python2.pc
ln -sf ../../libpython2.7.so \
    "$PKGDIR"/usr/lib/python2.7/config/libpython2.7.so
mv "$PKGDIR"/usr/bin/smtpd.py \
   "$PKGDIR"/usr/lib/python2.7/

install -dm755 "$PKGDIR"/usr/lib/python2.7/Tools/{i18n,scripts}
install -m755 Tools/i18n/{msgfmt,pygettext}.py "$PKGDIR"/usr/lib/python2.7/Tools/i18n/
install -m755 Tools/scripts/{README,*py} "$PKGDIR"/usr/lib/python2.7/Tools/scripts/

sed -i "s#$SRCDIR/Python-$PKGVER:##" "$PKGDIR"/usr/lib/python2.7/config/Makefile

# FIXME: Hack, remove gcc-only or autobuild-specific flags.
#        They are passed into pip, causing trouble.
sed -e 's|-O3|-O2|g' \
    -e 's|-fira-loop-pressure -fira-hoist-pressure||g' \
    -e 's|-fdeclone-ctor-dtor||g' \
    -e 's|-specs=/usr/lib/gcc/specs/hardened-cc1||g' \
    -e 's|-flto=jobserver||g' \
    -e 's|-specs=/usr/lib/gcc/specs/hardened-ld||g' \
    -e 's|-msecure-plt||g' \
    -i "$PKGDIR"/usr/lib/python2.7/config/Makefile \
    -i "$PKGDIR"/usr/lib/python2.7/_sysconfigdata.py

rm -v "${PKGDIR}"/usr/bin/python
