# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>

pkgname=ccache
pkgver=4.10.2
pkgrel=2
pkgdesc='Compiler cache that speeds up recompilation by caching previous compilations'
url='https://ccache.dev/'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
license=('GPL-3.0-or-later')
depends=('fmt' 'glibc' 'gcc-libs' 'hiredis' 'zstd' 'libzstd.so')
makedepends=('cmake' 'asciidoctor' 'perl')
source=(https://github.com/ccache/ccache/releases/download/v${pkgver}/ccache-${pkgver}.tar.xz{,.asc})
sha512sums=('3815c71d7266c32839acb306763268018acc58b3bbbd9ec79fc101e4217c1720d2ad2f01645bf69168c1c61d27700b6f3bb755cfa82689cca69824f015653f3c'
            'SKIP')
b2sums=('7352b8b48ed889e1f251ae59cb7cd9d01d7d3226b58a7823be176907dc074ff22ca5d6a271e2caede7d97a65457b9067b48e9d39ab833bf45fb055eb3bfe7607'
        'SKIP')
validpgpkeys=('5A939A71A46792CF57866A51996DDA075594ADB8') # Joel Rosdahl <joel@rosdahl.net>

build() {
  cd ${pkgname}-${pkgver}
  cmake \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -Wno-dev \
    -B build \
    -S .
  make VERBOSE=1 -C build
}

check() {
  cd ${pkgname}-${pkgver}
  make VERBOSE=1 check -C build
}

package() {
  cd ${pkgname}-${pkgver}

  make DESTDIR="${pkgdir}" install -C build
  make DESTDIR="${pkgdir}" install -C build/doc

  install -Dm 644 doc/*.md doc/*.adoc -t "${pkgdir}/usr/share/doc/${pkgname}"

  install -d "${pkgdir}/usr/lib/ccache/bin"
  local _prog
  for _prog in gcc g++ c++; do
    ln -s /usr/bin/ccache "${pkgdir}/usr/lib/ccache/bin/$_prog"
    ln -s /usr/bin/ccache "${pkgdir}/usr/lib/ccache/bin/${CHOST}-$_prog"
  done
  for _prog in cc clang clang++; do
    ln -s /usr/bin/ccache "${pkgdir}/usr/lib/ccache/bin/$_prog"
  done
}

# vim: ts=2 sw=2 et:
