# Maintainer (Arch): Christian Rebischke <chris.rebischke@archlinux.org>
# Contributor (Arch): Timothy Redaelli <timothy.redaelli@gmail.com>
# Contributor (Arch): Andy Weidenbaum <archbaum@gmail.com>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: Márcio Silva <coadde@hyperbola.info>

# parabola changes and rationale:
#  - replaced opencl-nvidia recommendation with opencl-mesa

pkgname=bfgminer
pkgver=5.5.0
pkgrel=3
pkgrel+=.parabola1
pkgdesc="Bitcoin miner featuring overclocking, monitoring, fan speed control and remote management. For FPGA/GPU/CPU Bitcoin mining"
pkgdesc+=", with opencl-mesa recommendation"
arch=('x86_64')
arch+=('i686' 'armv7h')
depends=('curl' 'jansson' 'libevent' 'libmicrohttpd' 'libusb' 'lm_sensors')
makedepends=('uthash' 'yasm')
optdepends=('opencl-mesa: OpenCL implementation for AMD/ATI GPUs')
url='https://bitcointalk.org/?topic=877081'
license=('GPL3')
source=("https://luke.dashjr.org/programs/bitcoin/files/${pkgname}/${pkgver}/${pkgname}-${pkgver}.txz"
        'remove-dangerous-rpath.patch')
sha512sums=('d1adae473e01fcf1cd0efde74d3e8ce10609e520397d688bf4e226c1113c1606c782e3cfdba6847f1a3886cac30de6b5baa03b731aca86287d53bf01ef705cdb'
            '087aa60d818ff37cb7a4edce7a34331a492b5e379a8e034d7a2e02b106bb6ea52b4ce6a1077f602987a2c30213bc185063990796a828ae95f60cff03c7a0bc3f')

prepare() {
  cd "${pkgname}"-"${pkgver}"

  patch -p1 -i "${srcdir}"/remove-dangerous-rpath.patch
}

build() {
  cd "${pkgname}"-"${pkgver}"

  ./configure --prefix=/usr \
    --sbindir=/usr/bin \
    --enable-cpumining \
    --enable-bfsb \
    --enable-metabank \
    --enable-scrypt \
    --enable-opencl \
    --with-udevrulesdir=/usr/lib/udev/rules.d
  # --enable-knc (FS#33640)
  make
}

package() {
  cd "${pkgname}"-"${pkgver}"

  make DESTDIR="${pkgdir}" install
}
