# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Christian Kohlstedde <christian+arch-pkg@kohlsted.de>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Peter Wu <peter@lekensteyn.nl>

pkgname=bcg729
pkgver=1.0.4
pkgrel=4
pkgdesc='Encoder and decoder of the ITU G.729 Annex A/B speech codec'
url='https://www.linphone.org/technical-corner/bcg729/overview'
arch=('x86_64')
license=('GPL2')
makedepends=('cmake')
depends=('glibc')
source=(https://github.com/BelledonneCommunications/bcg729/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz
        ${pkgname}-cmake-install-pkgconfig.patch::https://github.com/BelledonneCommunications/bcg729/commit/a5907daf1b111e4ad7aab4f558f57e2af1e37e55.patch
        ${pkgname}-cmake-symbol-visibility.patch::https://github.com/BelledonneCommunications/bcg729/commit/697bf6653a8c7421f0e821ee8d42471246e6850f.patch
        ${pkgname}-cmake-symbol-visibility-test.patch::https://github.com/BelledonneCommunications/bcg729/commit/d63ce04a93711820d9a6985b1d11d8d91ed8e6b6.patch)
sha256sums=('94b3542a06cbd96306efc19f959f9febae62806a22599063f82a8c33e989d48b'
            'cf28103bab1896f3c7fa408b3f33f8db6a5ee701cc8cfb20f08741f33967e0cd'
            '9a41a1917dfc599dfd2f4f299a762d0cc991f00d54990b9fc342ae3c07e6dd40'
            'fbed00c37539d09002ff413fc9e9ca0413746d962c512e20f02a96bf665fb85e')

prepare() {
  cd ${pkgname}-${pkgver}
  # CMake: install pkg-config files for parity with autotools
  patch -Np 1 < "${srcdir}/${pkgname}-cmake-install-pkgconfig.patch"
  # cmake: fix symbol visibility
  patch -Np 1 < "${srcdir}/${pkgname}-cmake-symbol-visibility.patch"
  patch -Np 1 < "${srcdir}/${pkgname}-cmake-symbol-visibility-test.patch"
}

build() {
  install -d ${pkgname}-${pkgver}/build
  cd ${pkgname}-${pkgver}/build
  cmake .. \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DCMAKE_INSTALL_LIBDIR=lib \
      -DENABLE_STATIC=OFF
  make
}

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

# vim: ts=2 sw=2 et:
