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

pkgname="crosstool-ng"
pkgver=1.24.0
pkgrel=1
pkgdesc="A cross-platform open-source toolchain system"
arch=('i686' 'x86_64')
url="http://www.crosstool-ng.org/"
license=("MIT")
makedepends=("autoconf" "automake-wrapper" "binutils" "bison"
             "flex" "gettext-devel" "git" "gcc" "gperf"
             "patch" "libtool" "make" "ncurses-devel"
             "tar" "texinfo" "wget" "xz")
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=('804ced838ea7fe3fac1e82f0061269de940c82b05d0de672e7d424af98f22d2d'
            '63e39da13cb078d118a03ee492041067da58e531d948a37630349887417496d5')
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
}
