# $Id: PKGBUILD,v 1.50 2007/10/05 02:45:17 dan Exp $
# Maintainer: judd <jvinet@zeroflux.org>
pkgname=perl
pkgver=5.8.8
pkgrel=8
pkgdesc="Practical Extraction and Report Language"
arch=(i686 x86_64) 
license=('GPL' 'PerlArtistic')
url="http://www.perl.org"
groups=('base')
depends=('gdbm' 'db>=4.6' 'bash')
source=(http://www.perl.com/CPAN/src/perl-$pkgver.tar.gz
	http://search.cpan.org/CPAN/authors/id/P/PM/PMQS/DB_File-1.814.tar.gz
	http://search.cpan.org/CPAN/authors/id/N/NW/NWCLARK/sprintf-5.8.7.patch
	http://search.cpan.org/CPAN/authors/id/S/SA/SAPER/Sys-Syslog-0.10.tar.gz
	perl-5.8.6-picdl.patch0
	perl-5.8.8-gcc-4.2.0.patch)
install=perl.install
md5sums=('b8c118d4360846829beb30b02a6b91a7'
         '5ae102fe172f2aaf771a8d9cae23ca3a'
         'e1ce6f6cf32434db77f78be5938af09c'
         '8fc1f24fc7890e4fd8360e7e9f293099'
         '319b56a7ce715fb7a494fe4d5cb9474c'
         '546fc05b63b0add38898361c8de0c949')

build() {
  cd $startdir/src/$pkgname-$pkgver
  # replace Sys/Syslog with fixed version 0.10.
  cd ext
  rm -rf Sys/Syslog/*
  mv $startdir/src/Sys-Syslog-0.10/* Sys/Syslog
  # replace the old DB_File with the newest one from CPAN,
  # since it supports sleepycat's db 4.1.x
  rm -rf DB_File
  mv $startdir/src/DB_File-1.814 ./DB_File

  cd $startdir/src/$pkgname-$pkgver
  patch -Np1 -i ${startdir}/src/perl-5.8.8-gcc-4.2.0.patch || return 1
  if [ "$CARCH" = "x86_64" ]; then
    # for x86_64
    patch -Np0 -i ../perl-5.8.6-picdl.patch0 || return 1
    ./Configure -des -Dprefix=/usr -Dinstallprefix=$startdir/pkg/usr \
      -Dman1dir=/usr/man/man1 -Dman3dir=/usr/man/man3 -Doptimize="$CFLAGS" \
      -Dusethreads -Dcccdlflags='-fPIC'
  else 
    # for i686
    ./Configure -des -Dprefix=/usr -Dinstallprefix=$startdir/pkg/usr \
      -Dman1dir=/usr/man/man1 -Dman3dir=/usr/man/man3 -Doptimize="$CFLAGS" \
      -Dusethreads
  fi
  make || return 1
  make install
  (cd $startdir/pkg/usr/bin; mv perl$pkgver perl; ln -sf c2ph pstruct)
  (cd $startdir/pkg/usr/bin; ln -sf s2p psed)
  (cd $startdir/pkg/usr/lib/perl5; mv $pkgver current)
  (cd $startdir/pkg/usr/lib/perl5/site_perl; mv $pkgver current)
  find $startdir/pkg -type f | xargs grep -l "$startdir/pkg" | \
    xargs -n1 perl -i -p -e "s|$startdir/pkg||g;"
}