# Contributor: Sodface <sod@sodface.com>
# Maintainer: Sodface <sod@sodface.com>
pkgname=freeipmi
pkgver=1.6.14
pkgrel=2
pkgdesc="IPMI library and utilities"
url="https://www.gnu.org/software/freeipmi/"
arch="all !ppc64le"
license="GPL-3.0-or-later"
options="!check" # no test suite
makedepends="argp-standalone libgcrypt-dev"
subpackages="$pkgname-doc $pkgname-dev $pkgname-libs $pkgname-openrc"
source="
	https://ftp.gnu.org/gnu/freeipmi/freeipmi-$pkgver.tar.gz
	bmc-watchdog.confd
	bmc-watchdog.initd
	ipmidetectd.confd
	ipmidetectd.initd
	ipmiseld.confd
	ipmiseld.initd
	gcc-14.patch
	"

prepare() {
	default_prepare
	update_config_sub
	update_config_guess
}

build() {
	# https://gitlab.alpinelinux.org/alpine/aports/-/issues/16390
	export LDFLAGS="$LDFLAGS -Wl,-z,stack-size=0x200000"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--disable-static \
		--disable-init-scripts
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm 644 "$srcdir"/bmc-watchdog.confd \
		"$pkgdir"/etc/conf.d/bmc-watchdog
	install -Dm755 "$srcdir"/bmc-watchdog.initd \
		"$pkgdir"/etc/init.d/bmc-watchdog
	install -Dm 644 "$srcdir"/ipmidetectd.confd \
		"$pkgdir"/etc/conf.d/ipmidetectd
	install -Dm755 "$srcdir"/ipmidetectd.initd \
		"$pkgdir"/etc/init.d/ipmidetectd
	install -Dm 644 "$srcdir"/ipmiseld.confd \
		"$pkgdir"/etc/conf.d/ipmiseld
	install -Dm755 "$srcdir"/ipmiseld.initd \
		"$pkgdir"/etc/init.d/ipmiseld
}

sha512sums="
5dab6430d257776cad1aed39cb2e2536af42c56e3f53774111efc15b0dfc19241eedfbcbfb1f088dd8be38ce694bff9779050daaec9ad0b2d4dad329ce8f3fe3  freeipmi-1.6.14.tar.gz
11bbd920eb67a64a9d3742e860ae146c1a00398f44d4cead49f8f6070f46a09249c05bb647a1b7bf2c4c6c78e1ae393b2e52395f640bc7e5139aade7c99b45b2  bmc-watchdog.confd
1e064b0b295fbf76e5deddeaa4edf1b0e5d9b642c2e4be9f3c5cce0700c02ec18778eac4a0cd8196fc5d71ffad9921de8df08a8569812252dd3d604c6f67ad5a  bmc-watchdog.initd
f10e908a451c646b2c61338d79e69663c05216a54093745bd2b659041e0b91adb9be4077c92d63f6f3d62cb5510168b6a57e5e86375533e235fd3abb2b72a49c  ipmidetectd.confd
52e90bb45eb32b447250db3df44d7ba37f821a2d699bc586bdb50706b13e638008cd46ad97cb421fa2d2248f2bb3543d99ed95d27bfdd3b82b560a6fe5da153e  ipmidetectd.initd
0a031f29a4692085054d5fc2dfe6d0ad7fb762f7ee96849ce2d562a90d6e3b0f3ae8328ab852dc22bee6221bc5cd8b588bd02075222038fa0f0e2f64ac185799  ipmiseld.confd
f95ed699a467689dc1c7c047bd2da8fde04eabc890d02a6517e044a3a5cd05e9ebdeb2b8504fdc053920a8ef281bcf4e2be5a38d3bb4746952bba0e96a47c153  ipmiseld.initd
aab65bb509d8caea54b55e38fc8eacea88b03a17b50668c485efa2b12070d2da24241fdc8d38c8743806bb85b75bd091df16ccebe97882cc20c2d731c67dc740  gcc-14.patch
"
