pkgname=libffi
pkgver=3.5.2
pkgdesc='Portable foreign function interface library'
homepage='https://sourceware.org/libffi/'
license=(MIT)
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://github.com/libffi/libffi/releases/download/v${pkgver}/${sources[0]}")
md5sums=("92af9efad4ba398995abf44835c5d9e9")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
}

src_build() {
  CFLAGS+=" -march=native"
  ./configure --prefix=/usr          \
              --disable-static       \
              --with-gcc-arch=native
  make
}

src_check() {
  make check
}

src_install() {
  make DESTDIR="${pkgdir}" install
  install -Dm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
  install -Dm 644 README.md -t "$pkgdir"/usr/share/doc/$pkgname
}

