# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=m68k-apple-macos-binutils
pkgbase=mingw-w64-${_realname}-git
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=r808.8d32c583ae
pkgrel=1
pkgdesc='cross-binutils for classic 68K Macintoshes (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/autc04/Retro68"
license=('GPL3')
depends=("${MINGW_PACKAGE_PREFIX}-isl")
makedepends=("${MINGW_PACKAGE_PREFIX}-libtool" autoconf automake git make bison flex)
_commit=8d32c583aee7051b9cd3a99d88d5defa39e868cf
source=("retro68::git+https://github.com/autc04/Retro68#commit=${_commit}")
sha256sums=('SKIP')

pkgver() {
  cd $srcdir/retro68
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  mkdir -p "${srcdir}/build-${CHOST}" && cd "${srcdir}/build-${CHOST}"
  ../retro68/binutils/configure \
	--build=${MINGW_CHOST} \
	--prefix=${MINGW_PREFIX} \
	--target=m68k-apple-macos \
	--disable-doc
  make ${MAKEFLAGS}
}

package() {
  cd "${srcdir}/build-${CHOST}"
  make DESTDIR="$pkgdir" install
  rm -rf "${pkgdir}${MINGW_PREFIX}/share/info"
  cd ../retro68
  install -D -m644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
