# $Id: PKGBUILD 222625 2014-09-22 10:38:58Z bluewind $
# Maintainer: Florian Pritz <bluewind@xinu.at>
# Contributor: Angel Velasquez <angvp@archlinux.org>
# Contributor: kevin <kevin.archlinux.org>
# Contributor: judd <jvinet.zeroflux.org>
# Contributor: francois <francois.archlinux.org>

pkgname=perl
pkgver=5.20.1
pkgrel=1
pkgdesc="A highly capable, feature-rich programming language"
arch=(i686 x86_64)
license=('GPL' 'PerlArtistic')
url="http://www.perl.org"
groups=('base')
depends=('gdbm' 'db' 'glibc')
# NOTE: This array is automatically generated by `./patchprov`.
#       If you want to add entries, do so in the next array.
provides=('perl-archive-tar=1.96'
          'perl-attribute-handlers=0.96'
          'perl-autodie=2.23'
          'perl-autoloader=5.74'
          'perl-autouse=1.08'
          'perl-b-debug=1.19'
          'perl-base=2.22'
          'perl-bignum=0.37'
          'perl-carp=1.3301'
          'perl-cgi=3.65'
          'perl-compress-raw-bzip2=2.064'
          'perl-compress-raw-zlib=2.065'
          'perl-config-perl-v=0.22'
          'perl-constant=1.31'
          'perl-cpan-meta-requirements=2.125'
          'perl-cpan-meta-yaml=0.012'
          'perl-cpan-meta=2.140640'
          'perl-cpan=2.05'
          'perl-data-dumper=2.151'
          'perl-db_file=1.831'
          'perl-devel-ppport=3.21'
          'perl-devel-selfstubber=1.05'
          'perl-digest-md5=2.53'
          'perl-digest-sha=5.88'
          'perl-digest=1.17'
          'perl-dumpvalue=1.17'
          'perl-encode=2.60'
          'perl-encoding-warnings=0.11'
          'perl-env=1.04'
          'perl-experimental=0.007'
          'perl-exporter=5.71'
          'perl-extutils-cbuilder=0.280217'
          'perl-extutils-command=1.18'
          'perl-extutils-constant=0.23'
          'perl-extutils-install=1.67'
          'perl-extutils-makemaker=6.98'
          'perl-extutils-manifest=1.63'
          'perl-extutils-parsexs=3.24'
          'perl-file-fetch=0.48'
          'perl-file-path=2.09'
          'perl-file-temp=0.2304'
          'perl-filter-simple=0.91'
          'perl-filter-util-call=1.49'
          'perl-getopt-long=2.42'
          'perl-http-tiny=0.043'
          'perl-i18n-collate=1.02'
          'perl-i18n-langtags=0.40'
          'perl-if=0.0603'
          'perl-io-compress=2.064'
          'perl-io-socket-ip=0.29'
          'perl-io-zlib=1.10'
          'perl-io=1.31'
          'perl-ipc-cmd=0.92'
          'perl-ipc-sysv=2.04'
          'perl-json-pp=2.27203'
          'perl-lib=0.63'
          'perl-libnet=1.25'
          'perl-locale-codes=3.30'
          'perl-locale-maketext-simple=0.21'
          'perl-locale-maketext=1.25'
          'perl-math-bigint-fastcalc=0.31'
          'perl-math-bigint=1.9993'
          'perl-math-bigrat=0.2606'
          'perl-math-complex=1.59'
          'perl-memoize=1.03'
          'perl-mime-base64=3.14'
          'perl-module-build=0.4205'
          'perl-module-corelist=5.020001'
          'perl-module-load-conditional=0.62'
          'perl-module-load=0.32'
          'perl-module-loaded=0.08'
          'perl-module-metadata=1.000019'
          'perl-net-ping=2.43'
          'perl-package-constants=0.04'
          'perl-params-check=0.38'
          'perl-parent=0.228'
          'perl-parse-cpan-meta=1.4414'
          'perl-pathtools=3.48'
          'perl-perl-ostype=1.007'
          'perl-perlfaq=5.0150044'
          'perl-perlio-via-quotedprint=0.07'
          'perl-pod-checker=1.60'
          'perl-pod-escapes=1.06'
          'perl-pod-parser=1.62'
          'perl-pod-perldoc=3.23'
          'perl-pod-simple=3.28'
          'perl-pod-usage=1.63'
          'perl-podlators=2.5.3'
          'perl-safe=2.37'
          'perl-scalar-list-utils=1.38'
          'perl-search-dict=1.07'
          'perl-selfloader=1.21'
          'perl-socket=2.013'
          'perl-storable=2.49'
          'perl-sys-syslog=0.33'
          'perl-term-ansicolor=4.02'
          'perl-term-cap=1.15'
          'perl-term-complete=1.402'
          'perl-term-readline=1.14'
          'perl-test-harness=3.30'
          'perl-test-simple=1.001002'
          'perl-test=1.26'
          'perl-text-abbrev=1.02'
          'perl-text-balanced=2.02'
          'perl-text-parsewords=3.29'
          'perl-text-tabs=2013.0523'
          'perl-thread-queue=3.05'
          'perl-thread-semaphore=2.12'
          'perl-threads-shared=1.46'
          'perl-threads=1.93'
          'perl-tie-file=1.00'
          'perl-tie-refhash=1.39'
          'perl-time-hires=1.9726'
          'perl-time-local=1.2300'
          'perl-time-piece=1.27'
          'perl-unicode-collate=1.04'
          'perl-unicode-normalize=1.17'
          'perl-version=0.9909'
          'perl-xsloader=0.17')
# Add your own provides here
provides=(${provides[@]})
source=(http://www.cpan.org/src/5.0/perl-${pkgver}.tar.bz2
        perlbin.sh
		perlbin.csh)
options=('makeflags' '!purge' 'emptydirs')
md5sums=('ede5166f949d9a07163bc5b086be9759'
         '5ed2542fdb9a60682f215bd33701e61a'
         '1f0cbbee783e8a6d32f01be5118e0d5e')

build() {
  cd ${srcdir}/${pkgname}-${pkgver}

  if [ "${CARCH}" = "x86_64" ]; then
    # for x86_64
    arch_opts="-Dcccdlflags='-fPIC'"
  else
    # for i686
    arch_opts=""
  fi

  ./Configure -des -Dusethreads -Duseshrplib -Doptimize="${CFLAGS}" \
    -Dprefix=/usr -Dvendorprefix=/usr \
    -Dprivlib=/usr/share/perl5/core_perl \
    -Darchlib=/usr/lib/perl5/core_perl \
    -Dsitelib=/usr/share/perl5/site_perl \
    -Dsitearch=/usr/lib/perl5/site_perl \
    -Dvendorlib=/usr/share/perl5/vendor_perl \
    -Dvendorarch=/usr/lib/perl5/vendor_perl \
    -Dscriptdir=/usr/bin/core_perl \
    -Dsitescript=/usr/bin/site_perl \
    -Dvendorscript=/usr/bin/vendor_perl \
    -Dinc_version_list=none \
    -Dman1ext=1perl -Dman3ext=3perl ${arch_opts} \
    -Dlddlflags="-shared ${LDFLAGS}" -Dldflags="${LDFLAGS}"
  make
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  TEST_JOBS=$(echo $MAKEFLAGS | sed 's/.*-j\([0-9][0-9]*\).*/\1/') make test_harness
#  make test
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR="$pkgdir" install

  ### Perl Settings ###
  # Change man page extensions for site and vendor module builds.
  # Set no mail address since bug reports should go to the bug tracker
  # and not someone's email.
  sed -e '/^man1ext=/ s/1perl/1p/' -e '/^man3ext=/ s/3perl/3pm/' \
      -e "/^cf_email=/ s/'.*'/''/" \
      -e "/^perladmin=/ s/'.*'/''/" \
      -i ${pkgdir}/usr/lib/perl5/core_perl/Config_heavy.pl

  ### CPAN Settings ###
  # Set CPAN default config to use the site directories.
  sed -e '/(makepl_arg =>/   s/""/"INSTALLDIRS=site"/' \
      -e '/(mbuildpl_arg =>/ s/""/"installdirs=site"/' \
      -i ${pkgdir}/usr/share/perl5/core_perl/CPAN/FirstTime.pm

  # Profile script to set paths to perl scripts.
  install -D -m755 ${srcdir}/perlbin.sh \
                   ${pkgdir}/etc/profile.d/perlbin.sh
  # Profile script to set paths to perl scripts on csh. (FS#22441)
  install -D -m755 ${srcdir}/perlbin.csh \
                  ${pkgdir}/etc/profile.d/perlbin.csh

  # Add the dirs so new installs will already have them in PATH once they
  # install their first perl programm
  install -d -m755 "$pkgdir/usr/bin/vendor_perl"
  install -d -m755 "$pkgdir/usr/bin/site_perl"

  (cd ${pkgdir}/usr/bin; mv perl${pkgver} perl)
  (cd ${pkgdir}/usr/bin/core_perl;  ln -sf c2ph pstruct; ln -sf s2p psed)

  # Remove all pod files *except* those under /usr/share/perl5/core_perl/pod/
  # (FS#16488)
  rm -f $pkgdir/usr/share/perl5/core_perl/*.pod
  for d in $pkgdir/usr/share/perl5/core_perl/*; do
    if [ -d $d -a $(basename $d) != "pod" ]; then
      find $d -name *.pod -delete
    fi
  done
  find $pkgdir/usr/lib -name *.pod -delete
  find $pkgdir -name .packlist -delete
}
