# Maintainer: Martell Malone <martellmalone@gmail.com>

pkgname="crosstool-ng"
pkgver=1.27.0
pkgrel=1
pkgdesc="A cross-platform open-source toolchain system"
arch=('i686' 'x86_64')
url="http://www.crosstool-ng.org/"
license=("spdx:MIT")
makedepends=("autoconf" "automake-wrapper" "binutils" "bison"
             "flex" "gettext-devel" "git" "gcc" "gperf"
             "patch" "ncurses-devel"
             "tar" "texinfo" "wget" "xz" 'autotools' 'unzip' 'help2man')
depends=("ncurses" "libintl")
options=('staticlibs' 'strip')
source=("http://crosstool-ng.org/download/crosstool-ng/${pkgname}-${pkgver}.tar.xz"
        "0001-Modify-config-to-support-correct-Mingw64-Triplet-Nam.patch")
sha256sums=('0506ab98fa0ad6d263a555feeb2c7fff9bc24a434635d4b0cdff9137fe5b4477'
            '6d470e518609df696f76c1ba57ce278254c80ba7b33705ef8e45c7d36a23c493')
noextract=(${pkgname}-${pkgver}.tar.xz)

prepare() {
  [[ -d ${srcdir}/${pkgname}-${pkgver} ]] && rm -rf ${srcdir}/${pkgname}-${pkgver}
  tar -xJf ${srcdir}/${pkgname}-${pkgver}.tar.xz -C ${srcdir} || true
  
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i "${srcdir}/0001-Modify-config-to-support-correct-Mingw64-Triplet-Nam.patch"

  ./bootstrap
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
    --build=${CHOST} \
    --prefix=/usr

  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR=${pkgdir} install
}
