# Template file for 'efivar'
pkgname=efivar
version=31
revision=2
makedepends="popt-devel"
short_desc="Tools to manipulate EFI variables"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="LGPL-2.1"
homepage="https://github.com/rhinstaller/efivar"
only_for_archs="i686 i686-musl x86_64 x86_64-musl"
distfiles="https://github.com/rhinstaller/efivar/archive/${version}/${version}.tar.gz>${pkgname}-${version}.tar.gz"
checksum=fa9331b762ab9f0749dd8d58a218701f33e4ea515ac57a120657447e046e6568

CFLAGS="-D_GNU_SOURCE"

do_build() {
	case "$XBPS_TARGET_MACHINE" in
	*-musl)
		cp ${FILESDIR}/bswap_constant.h src/include/efivar/
		patch -p0 < ${FILESDIR}/makeguids.patch
		;;
	esac
	sed -i Make.rules -e s';-o $@ $^ $(LDLIBS);-o $@ $^ $(LDLIBS) -lpopt;'
	make ${makejobs} CC=$CC libdir="/usr/lib/"
	make -C src/test ${makejobs} CC=$CC libdir="/usr/lib/"
}
do_install() {
	make DESTDIR=${DESTDIR} libdir="/usr/lib/" 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="${makedepends} libefivar>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove usr/lib/*.so
		vmove usr/share/man/man3
	}
}
