# Template file for 'autofs'
pkgname=autofs
version=5.1.9
revision=2
build_style=gnu-configure
make_build_args="DONTSTRIP=1"
configure_args="--with-libtirpc --with-mapdir=/etc/autofs --sbindir=/usr/bin"
conf_files="/etc/autofs/*"
hostmakedepends="pkg-config flex kmod rpcsvc-proto"
makedepends="libtirpc-devel libxml2-devel"
short_desc="Kernel-based automounter for Linux"
maintainer="Helmut Pozimski <helmut@pozimski.eu>"
license="GPL-2.0-or-later"
homepage="https://www.kernel.org/pub/linux/daemons/autofs"
distfiles="${KERNEL_SITE}/daemons/autofs/v5/autofs-${version}.tar.xz"
checksum=87e6af6a03794b9462ea519781e50e7d23b5f7c92cd59e1142c85d2493b3c24b

CFLAGS="-I${XBPS_CROSS_BASE}/usr/include/gssglue -I${XBPS_CROSS_BASE}/usr/include/tirpc"

if [ -z "$CROSS_BUILD" ] && [ "$XBPS_TARGET_LIBC" != "musl" ]; then
	makedepends+=" sssd-devel"
fi

pre_configure() {
	vsed -e 's,__S_IEXEC,S_IXUSR,g' -i daemon/lookup.c -i modules/lookup_multi.c
}

pre_build() {
	unset STRIP
	# Fix path for map files
	vsed -e "s@/etc/@/etc/autofs/@g" -i samples/auto.master
}

post_install() {
	vsv $pkgname
	make DESTDIR=${DESTDIR} -C samples install
	# Remove unused stuff
	rm ${DESTDIR}/usr/share/man/man5/autofs.5
	rm -r ${DESTDIR}/etc/default || :
	rm ${DESTDIR}/autofs || :
}
