# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=('yasm' 'yasm-devel')
pkgver=1.3.0
pkgrel=2
pkgdesc="A rewrite of NASM to allow for multiple syntax supported (NASM, TASM, GAS, etc.)"
arch=('i686' 'x86_64')
url="https://www.tortall.net/projects/yasm/"
license=('BSD' 'GPL2' 'LGPL2.1' 'PerlArtistic')
options=('staticlibs')
source=(https://www.tortall.net/projects/yasm/releases/${pkgname}-${pkgver}.tar.gz
        'msysize.patch'
        'yasm-1.2.0-1.src.patch')
sha256sums=('3dce6601b495f5b3d45b59f7d2492a340ee7e84b5beca17e48f862502bd5603f'
            'c29f0b53b13f8a3e16dbfb38c1f67ed281cdad9140447726bfcba321fe0f67ad'
            '10a8dee681519d6fe14bf7f4dc9cb5b0f55cc7210c4e532e6939c4363cb0d3c0')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/msysize.patch
  patch -p2 -i ${srcdir}/yasm-1.2.0-1.src.patch

  autoreconf -fi
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr --build=${CHOST}
  make
  make DESTDIR="${srcdir}/dest" install
}

check() {
  cd ${pkgname}-${pkgver}
  make check
}

package_yasm() {
  mkdir -p ${pkgdir}/usr

  cp -rf ${srcdir}/dest/usr/bin ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_yasm-devel() {
  mkdir -p ${pkgdir}/usr

  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
