# Maintainer: Antoni Aloy <aaloytorrens@gmail.com>
# Contributor: Mark Jynx <markjynx@cock.li>
pkgname="libsoundio"
pkgver="2.0.0"
pkgrel=2
pkgdesc="C library for cross-platform real-time audio input and output"
url="http://libsound.io"
arch="all"
options="!check" # Tests are not automated
license="MIT"
depends_dev="alsa-lib-dev"
makedepends="cmake samurai $depends_dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/andrewrk/libsoundio/archive/$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib   \
		-DBUILD_STATIC_LIBS=OFF      \
		-DBUILD_EXAMPLE_PROGRAMS=OFF \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		${CMAKE_CROSSOPTS} .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="347a9be1789a41e778ea8d0efa1d00e03e725a4ab65e3aaf6c71e49138643f08a50a81bd60087d86a3b4d63beaeec617e47ba6b81f829ece8a3ac17418eb5309  libsoundio-2.0.0.tar.gz"
