# Maintainer: Ray Donnelly <mingw.android@gmail.com>

_realname=astyle
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.1
pkgrel=1
pkgdesc='A free, fast and small automatic formatter for C, C++, C#, and Java source code (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
source=("https://sourceforge.net/projects/${_realname}/files/${_realname}/${_realname}%20${pkgver}/${_realname}_${pkgver}_linux.tar.gz"
        "mingw-w64-fix-install.patch")
sha256sums=('cbcc4cf996294534bb56f025d6f199ebfde81aa4c271ccbd5ee1c1a3192745d7'
            '5723492b717a588cfec0aa094f2754587e5b28effff2e0b717d59b0f8641e78a')

prepare() {
  cd "${srcdir}"/${_realname}
  patch -p1 -i "${srcdir}"/mingw-w64-fix-install.patch
}

build() {
  [ -d "${srcdir}"/build-${CARCH} ] && rm -rf "${srcdir}"/build-${CARCH}
  mv "${srcdir}"/${_realname} "${srcdir}"/build-${CARCH}
  cd "${srcdir}"/build-${CARCH}/build/gcc
  make
}

package() {
  cd "${srcdir}"/build-${CARCH}/build/gcc
  make install prefix=${pkgdir}${MINGW_PREFIX}
}
