# Contributor: Russ Webber <russ@rw.id.au>
# Maintainer: Russ Webber <russ@rw.id.au>
pkgname=log4cxx
pkgver=1.1.0
pkgrel=3
pkgdesc="C++ port of the Log4j logging framework"
url="http://logging.apache.org/log4cxx"
license="Apache-2.0"
options="!check"  # testsuite in 1.1.0 does not work on alpine
subpackages="$pkgname-dev"
arch="all"
makedepends="cmake zip libxml2-dev apr-util-dev samurai"
source="https://archive.apache.org/dist/logging/log4cxx/$pkgver/apache-log4cxx-$pkgver.tar.gz"
builddir="$srcdir/apache-$pkgname-$pkgver"

# secfixes:
#   1.1.0-r0:
#     - CVE-2023-31038

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi

	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	ctest --test-dir build -E sizebasedrollingtest
}

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

sha512sums="
66a66eab933a6afd0779e3f73f65afa4fb82481208b591fd7c7c86ded805f50abcd9cdf954bdb49e1e7f5198e6c1c4fff8a7e180ff5fff9491f1946e9ba6fe2b  apache-log4cxx-1.1.0.tar.gz
"
