# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgname=libcbor
pkgver=%version%
pkgrel=%release%
pkgdesc='C library for parsing and generating CBOR, the general-purpose schema-less binary data format'
url='https://github.com/PJK/libcbor'
arch=('x86_64')
license=('MIT')
depends=('glibc')
makedepends=('cmake' 'cmocka')
provides=('libcbor.so')
source=(https://github.com/PJK/libcbor/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('c14aaa55c0c82e09b9eb2cc6847951d1bac8a081a247776c507d5450367da5717b1056bad09fb0f0178311de8754e8f89c060e0fc0f400fafdc42de441421e66')
b2sums=('6ac400ee9cabb0ec68355c35f762ea61222152059e70bcf9dc3cf4e06a6599bb6a392197ee979821a0e50c22a5c9e94e5d11458178ed7e26b049c410fddfa24f')

build() {
  cd ${pkgname}-${pkgver}
  cmake . \
    -Bbuild \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_C_FLAGS="${CFLAGS} ${CPPFLAGS}" \
    -DBUILD_SHARED_LIBS=ON \
    -DWITH_TESTS=1
  make -C build VERBOSE=1
  make -C build/test VERBOSE=1
}

check() {
  cd ${pkgname}-${pkgver}
  make -C build/test test
}

package() {
  cd ${pkgname}-${pkgver}
  make -C build DESTDIR="${pkgdir}" install
  install -Dm 644 README.md CHANGELOG.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE.md -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
