# Contributor: Andre Klitzing <andre () incubo () de>
# Contributor: mosra <mosra@centrum.cz>
pkgname=nsis
pkgver=2.46
pkgrel=3
pkgdesc='A professional open source system to create Windows installers'
arch=('i686' 'x86_64')
url='http://nsis.sourceforge.net'
license='http://nsis.sourceforge.net/License'
depends=('mingw32-runtime')
makedepends=('scons' 'mingw32-gcc' 'mingw32-binutils' 'mingw32-w32api')
source=(http://downloads.sourceforge.net/project/nsis/NSIS%202/$pkgver/$pkgname-$pkgver-src.tar.bz2
        nsis-2.43-64bit-fixes.patch)
md5sums=('61c2e81739436b06d7cf7bcce1d533ac'
         '9eead3b78da54e3afda8f6a5b663aea9')

build() {
  cd "$srcdir/$pkgname-$pkgver-src"

  # Patch taken from
  # http://cvs.fedoraproject.org/viewvc/rpms/mingw32-nsis/F-11/nsis-2.43-64bit-fixes.patch
  patch -p1 -i "$srcdir/nsis-2.43-64bit-fixes.patch" || return 1

  # Patch version from DD-MM-YYY.cvs to 2.46 (makes CPack working again)
  sed -i "s/'Version of NSIS', cvs_version)/'Version of NSIS', '${pkgver}')/" \
    "${srcdir}/${pkgname}-${pkgver}-src/SConstruct"

  scons PREFIX_DEST="$pkgdir/" PREFIX=/usr/i486-mingw32 SKIPUTILS='NSIS Menu' install || return 1

  # Add a symlink to 'makensis' for lazy people ;-)
  mkdir "$pkgdir/usr/bin/"
  cd "$pkgdir/usr/bin/"
  ln -s ../i486-mingw32/bin/makensis
}
