# Maintainer: Robin Broda <robin@broda.me>
# Contributor: Pierre Neidhardt <ambrevar@gmail.com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Gergely Imreh <imrehgATgmailDOTcom>
# Contributor: dschauer <dschauerATgmailDOTcom>
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>
# Contributor: Jeremy Cowgar <jeremy@cowgar.com>

pkgname=tcc
_commit='b8b6a5fd7b4e8cab8e5a5d01064cf5bf2b5eed95'
pkgver=0.9.27.r1151.gb8b6a5fd
pkgrel=1
pkgdesc="Tiny C Compiler"
arch=('x86_64')
url="https://bellard.org/tcc/"
license=('LGPL')
depends=('glibc')
makedepends=('git')
options=('docs' 'staticlibs')
source=("git+https://repo.or.cz/tinycc.git#commit=${_commit}")
sha256sums=('803cc5e1f2b29b3abbb3ca9f9cbcb8302c77c8d443247d73697e90a56b168db6')

pkgver() {
  cd tinycc

  GITTAG="$(git describe --abbrev=0 --tags 2>/dev/null)"
  printf '%s.r%s.g%s' \
    "$(sed -e "s/^${pkgname%%-git}//" -e 's/^[-_/a-zA-Z]\+//' -e 's/[-_+]/./g' <<< ${GITTAG})" \
    "$(git rev-list --count ${GITTAG}..)" \
    "$(git rev-parse --short HEAD)"
}

build() {
  cd tinycc

  ./configure \
    --prefix=/usr \
    --docdir=/usr/share/doc/tcc \
    --disable-static
  make
}

package() {
  cd tinycc

  make DESTDIR="${pkgdir}" install
}
