# Maintainer: Paul (PAPPP) Eberhart <pappp@pappp.net>
pkgname=chdkptp-svn
pkgver=460
pkgrel=1
pkgdesc="chdkptp is a client application for the CHDK  PTP Extension"
arch=('x86_64')
url="https://www.assembla.com/spaces/chdkptp/wiki"
license=('GPL' 'MIT')
groups=()
depends=('iup-all-bin' 'libusb-compat')
makedepends=('subversion')
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=
#source=('http://subversion.assembla.com/svn/chdkptp/')
noextract=()
md5sums=() #generate with 'makepkg -g'

_svntrunk=http://subversion.assembla.com/svn/chdkptp
_svnmod=trunk

build() {
  cd "$srcdir"
  msg "Connecting to SVN server...."

  if [[ -d "$_svnmod/.svn" ]]; then
    (cd "$_svnmod" && svn up -r "$pkgver")
  else
    svn co "$_svntrunk" --config-dir ./ -r "$pkgver" "$_svnmod"
  fi

  msg "SVN checkout done or server timeout"
  msg "Starting build..."

  rm -rf "$srcdir/$_svnmod-build"
  svn export "$srcdir/$_svnmod" "$srcdir/$_svnmod-build"
  cd "$srcdir/$_svnmod-build"

  #
  # BUILD HERE
  #
  cd trunk
  cp config-sample-linux.mk config.mk
  sed -i 's|IUP_SUPPORT=0|IUP_SUPPORT=1|' config.mk
  sed -i 's|CD_SUPPORT=0|CD_SUPPORT=1|' config.mk
  sed -i 's|#IUP_INCLUDE_DIR=/path/to/iup/include|IUP_INCLUDE_DIR=/usr/include/iup-3.7/|' config.mk 
  sed -i 's|#CD_INCLUDE_DIR=/path/to/cd/include|CD_INCLUDE_DIR=/usr/include/cd-5.6/|' config.mk
  cp chdkptp-sample.sh chdkptp.sh
  sed -i 's|CHDKPTP_DIR=/path/to/chdkptp|CHDKPTP_DIR=/usr/share/chdkptp/|' chdkptp.sh
  make
}

package() {
  cd "$srcdir/$_svnmod-build/trunk"
  mkdir -p "$pkgdir/usr/share/chdkptp/"
  mkdir -p "$pkgdir/usr/bin/"
  install chdkptp "$pkgdir/usr/share/chdkptp"
  # Grumble install doesn't understand recursive directories grumble
  cp -r lua/ "$pkgdir/usr/share/chdkptp" 
  install chdkptp.sh "$pkgdir/usr/bin/chdkptp.sh"
}

# vim:set ts=2 sw=2 et:
