#!/bin/sh
##
##  perl-mini.sh -- generate a minimum Perl distribution suitable for building "miniperl" only
##

V=5.22.4

echo "++ unpacking perl-$V.tar.gz"
gunzip -d -c perl-$V.tar.gz | tar xf -

echo "++ stripping down distribution files"
for x in \
    Cross \
    NetWare \
    Changes* \
    README.* \
    INSTALL \
    MANIFEST \
    apollo \
    beos \
    cygwin \
    emacs \
    epoc \
    jpl \
    mint \
    mpeix \
    os2 \
    qnx \
    uts \
    vmesa \
    vms \
    vos \
    win32 \
    wince \
    djgpp \
    plan9 \
    symbian \
    t \
    pod \
    Porting \
    lib \
    ext/[A-Z]* \
    ext/threads \
    ext/threads-shared \
    ext/arybase \
    ext/attrs \
    ext/re \
    ext/mro \
    cpan/* \
    dist/* \
    haiku \
    mad \
; do
    rm -rf perl-$V/$x # >/dev/null 2>&1 || true
done

echo "++ adjusting distribution"
chmod a+rw perl-$V/Makefile.SH
sed -e '/-MExporter/d' <perl-$V/Makefile.SH >perl-$V/Makefile.SH.new
mv perl-$V/Makefile.SH.new perl-$V/Makefile.SH

echo "++ packing perl-$V-mini.tar.gz"
tar cf - perl-$V | gzip -9 >perl-$V-mini.tar.gz
rm -rf perl-$V

