# Maintainer (aur): Shalygin Konstantin <k0ste@k0ste.ru>
# Contributor: Shalygin Konstantin <k0ste@k0ste.ru>
# Contributor: Aurélien Desbrières <aurelien@hackers.camp>
# Maintainer: Parabola Hackers <dev@lists.parabola.nu>

pkgname='xtables-addons'
pkgver='3.24'
pkgrel='1'
pkgdesc='Xtables-addons is a set of additional extensions for the Xtables packet filter that is present in the Linux kernel'
arch=('armv7h' 'i686' 'x86_64')
license=('GPL2')
url="https://inai.de/projects/${pkgname}"
depends=('iptables' 'glibc' 'linux')
makedepends=('linux-api-headers' 'linux-headers' 'libtool' 'gcc' 'pkg-config')
source=("https://inai.de/files/${pkgname}/${pkgname}-${pkgver}.tar.xz")
sha256sums=('3e823f71720519ced31c4c7d2bfaf7120d9c01c59a0843dfcbe93c95c64d81c1')
depends=(     ${depends[*]/iptables/}       ) # 'base'
depends=(     ${depends[*]/glibc/}          ) # 'base'
makedepends=( ${makedepends[*]/gcc/}        ) # 'base-devel'
makedepends=( ${makedepends[*]/libtool/}    ) # 'base-devel'
makedepends=( ${makedepends[*]/pkg-config/} ) # 'base-devel'
_kernel=6.5.8
_kernver=/usr/lib/modules/${_kernel}-*/
depends=(     ${depends[*]/linux/linux-libre=${_kernel}}                     )
makedepends=( ${makedepends[*]/linux-headers/linux-libre-headers=${_kernel}} )

prepare() {
  cd "${pkgname}-${pkgver}"

  autoreconf -fvi
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --bindir=/usr/bin \
    --sbindir=/usr/bin \
    --libdir=/usr/lib \
    --mandir=/usr/share/man \
    --docdir=/usr/share/doc \
    --libexecdir=/usr/lib/iptables \
    --with-xtlibdir=/usr/lib/xtables \
    --with-kbuild="${_kernver}build"
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make
}

package() {
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  libtool --finish "${pkgdir}/usr/lib"
  mv -f "${pkgdir}"/lib/* "${pkgdir}/usr/lib"
  rmdir "${pkgdir}/lib"
  rm -f ${pkgdir}${_kernver}modules.*
}
