# Template file for 'mkinitcpio-nfs-utils'
pkgname=mkinitcpio-nfs-utils
version=0.3
revision=4
build_style=gnu-makefile
depends="mkinitcpio"
short_desc="Ipconfig and nfsmount tools for NFS root support in mkinitcpio"
maintainer="Andrea Brancaleoni <abc@pompel.me>"
license="GPL-2.0-only"
homepage="http://www.archlinux.org/"
distfiles="https://sources.archlinux.org/other/mkinitcpio/$pkgname-$version.tar.xz"
checksum=d290d489844fae100ca7b848b8eef40078124ff373203086bacc07329d1e8939

if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
	# musl doesn't set this
	CFLAGS="-DSYS_NMLN=65"
fi

post_patch() {
	vsed -i '/CC.*-o/s/$/ $(LDFLAGS)/' */Makefile

	# No RPC in musl for now
	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
		vsed -i 's|PROGRAMS = ipconfig nfsmount|PROGRAMS = ipconfig|g' Makefile
	fi
}

do_install() {
	# Makefile installation is broken, just install the two executables directly
	vinstall ipconfig/ipconfig 755 usr/lib/initcpio
	if [ "$XBPS_TARGET_LIBC" != "musl" ]; then
		vinstall nfsmount/nfsmount 755 usr/lib/initcpio
	fi

	vinstall ${FILESDIR}/initcpio-install-net 644 usr/lib/initcpio/install net
	vinstall ${FILESDIR}/initcpio-hook-net 644 usr/lib/initcpio/hooks net
}
