# Template file for 'cgminer'
pkgname=cgminer
version=3.3.0
revision=1
build_style=gnu-configure
configure_args="--disable-adl --enable-bitforce --enable-bflsc
 --enable-icarus --enable-avalon --enable-modminer --enable-ztex"
hostmakedepends="pkg-config yasm"
makedepends="libcurl-devel libusb-devel libudev-devel ncurses-devel"
short_desc="Multi-threaded multi-pool CPU and GPU miner for bitcoin"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-3"
homepage="https://github.com/ckolivas/cgminer"
distfiles="http://ck.kolivas.org/apps/cgminer/cgminer-${version}.tar.bz2"
checksum=2f0f43c7cae167bc97cbd4388f57936f9249c0cafb6f03b1448e34fe88342f7d

post_install() {
	vinstall example.conf 644 etc cgminer.conf
	sed -i -e 's#/usr/local/bin#/usr/bin#g' ${DESTDIR}/etc/cgminer.conf
	vinstall ${FILESDIR}/cgminer.service 644 usr/lib/systemd/system
}

cgminer_package() {
	conf_files="/etc/cgminer.conf"
	pkg_install() {
		vmove all
	}
}

# Package build options
build_options="opencl"
desc_option_opencl="Enable support for OpenCL mining"

# Enable opencl by default on x86.
if [ "$XBPS_TARGET_MACHINE" = "i686" -o "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
	build_options_default="opencl"
fi

if [ "$build_option_opencl" ]; then
	configure_args+=" --enable-scrypt --enable-opencl"
	makedepends+=" opencl-headers nvidia-opencl"
else
	configure_args+=" --disable-scrypt --disable-opencl"
fi
