# Template file for 'efivar'
pkgname=efivar
version=39
revision=1
build_style=gnu-makefile
make_build_args="libdir=/usr/lib"
make_check_args="GRUB_PREFIX=grub"
make_check_target="test"
make_install_args="libdir=/usr/lib"
hostmakedepends="pkg-config mdocml"
checkdepends="grub"
short_desc="Tools to manipulate EFI variables"
maintainer="Orphaned <orphan@voidlinux.org>"
license="LGPL-2.1-or-later"
homepage="https://github.com/rhboot/efivar"
distfiles="${homepage}/archive/${version}.tar.gz"
checksum=c9edd15f2eeeea63232f3e669a48e992c7be9aff57ee22672ac31f5eca1609a6

disable_parallel_check=yes

post_extract() {
	vsed -e 's/-march=native//' -i src/include/defaults.mk
	if [ "$CROSS_BUILD" ]; then
		# we build makeguids manually, make sure its not rebuild
		vsed -e '/$(MAKEGUIDS_OUTPUT) : makeguids/d' -i src/Makefile
	fi
}

pre_build() {
	if [ "$CROSS_BUILD" ]; then
		# work around broken cross build support by building makeguids
		# and then cleaning up shared objects.
		make ${makejobs} -C src makeguids HOSTCC=gcc HOSTCCLD=gcc \
			HOST_CFLAGS= HOST_LDFLAGS= SRCDIR=${wrksrc} TOPDIR=${wrksrc}
		rm -f src/*.o
	fi
}

post_install() {
	vbin src/test/tester efivar-tester
}

libefivar_package() {
	short_desc="Library to manipulate EFI variables"
	pkg_install() {
		vmove usr/lib/*.so.*
	}
}

libefivar-devel_package() {
	short_desc="Library to manipulate EFI variables - development files"
	depends="libefivar-${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove usr/lib/*.so
		vmove usr/share/man/man3
	}
}
