# Template file for 'libmnl'
pkgname=libmnl
version=1.0.5
revision=5
short_desc="Minimalistic Netlink library"
maintainer="finwo <finwo@pm.me>"
license="LGPL-2.1-or-later"
homepage="https://www.netfilter.org/projects/libmnl/"
distfiles="https://www.netfilter.org/pub/libmnl/libmnl-1.0.5.tar.bz2"
checksum=274b9b919ef3152bfb3da3a13c950dd60d6e2bcd54230ffeca298d03b40d0525
# glibc first: the post-install runs /sbin/ldconfig, which needs libc
# present. busybox first: control scripts run under /bin/sh, which must
# exist before the script executes (ordering, not just runtime truth -
# apk runs each package's scripts right after unpacking it).
depends="glibc busybox"

# Notes:
# - iproute2's `ip` builds without libmnl but loses extended-error-ack
#   decoding (netlink error messages become opaque). On a netlink-driven
#   NOS that is a debugging tax we refuse to pay; libmnl is tiny and
#   dependency-free, so it is a real package, not vendored.
# - Shared-only per packages/README.md. Sysroot seed (second install +
#   .pc prefix rewrite) so iproute2's configure finds it via PKG_CONFIG_PATH.

do_configure() {
  cd "${WRKSRC}"
  ./configure --prefix=/usr --disable-static
}

do_build() {
  cd "${WRKSRC}"
  make -j"$(nproc)"
}

do_install() {
  cd "${WRKSRC}"
  make install DESTDIR="${DESTDIR}"
  make install DESTDIR="${SYSROOT}"
  # .la files are build-time libtool metadata, never shipped
  rm -f "${DESTDIR}"/usr/lib/*.la "${SYSROOT}"/usr/lib/*.la
  # The sysroot .pc prefix is rewritten and verified centrally by mk/build.sh,
  # which runs pc-fixup.sh after this function returns.
}
