# Template file for 'open-iscsi'
pkgname=open-iscsi
version=2.0r873
revision=3
wrksrc="${pkgname}-${version/r/-}"
conf_files="/etc/iscsi/iscsid.conf /etc/iscsi/initiatorname.iscsi"
short_desc="Open-iSCSI userland tools"
maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
license="GPL-2"
homepage="http://www.open-iscsi.org/"
distfiles="http://www.open-iscsi.org/bits/${wrksrc}.tar.gz"
checksum=7dd9f2f97da417560349a8da44ea4fcfe98bfd5ef284240a2cc4ff8e88ac7cd9
nocross=yes

post_extract() {
	sed -i '1i#include <sys/time.h>' utils/open-isns/isns.h
	sed -i '1i#include <fcntl.h>' usr/idbm.c
	sed -i 's/(__compar_fn_t)//' utils/fwparam_ibft/fwparam_ppc.c
}
do_build() {
	make ${makejobs} CC="$CC" OPTFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
}
do_install() {
	make install exec_prefix=/usr sbindir=/usr/bin DESTDIR="$DESTDIR"

	vbin usr/iscsistart
	for m in doc/*.8; do
		vman $m
	done

	true >${DESTDIR}/etc/iscsi/initiatorname.iscsi
	vsconf ${DESTDIR}/etc/iscsi/ifaces/iface.example
	rm ${DESTDIR}/etc/iscsi/ifaces/iface.example

	sed -i 's,/sbin/iscsid,/usr/bin/iscsid,' ${DESTDIR}/etc/iscsi/iscsid.conf
}
