# Maintainer: Max Harmathy <harmathy@secure.mailbox.org>
# Contributor: Barry Smith <brrtsm at gmail.com>
# Contributor: nblock <nblock [/at\] archlinux DOT us>
# Contributor: Frederik AlkÃ¦rsig (FALKER) <havnelisten AT gmail.com>

pkgname=thinkfan
pkgver=2.0.0
pkgrel=3
pkgdesc="A minimalist fan control program. Supports the sysfs hwmon interface and thinkpad_acpi"
url="https://github.com/vmatare/thinkfan"
arch=('i686' 'x86_64')
makedepends=('cmake')
depends=(
  gcc-libs
  glibc
  libatasmart
  lm_sensors
  yaml-cpp
)
license=('GPL-3.0-or-later')
source=("$pkgname-$pkgver.tar.gz::https://github.com/vmatare/$pkgname/archive/$pkgver.tar.gz"
        'thinkfan.service'
        'thinkpad_acpi.conf')
sha256sums=('0fc94eb378dcba8c889e91f41dab3a8d6eebc7324a59a0704cc39aa66551987e'
            '625730e33fae251f3a1cc8259b222089fb45ada08e9cf5c816ea1cde6560e989'
            '28874576641b3cc1aa486e1bc9ed40eadfe8b13d6d3014016e31fedc5dc5195f')
install=thinkfan.install

build() {
  cd "$srcdir/$pkgname-$pkgver"

  cmake . -DCMAKE_INSTALL_PREFIX=/usr -DUSE_ATASMART:BOOL=ON
  make
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  install -d -m755 "$pkgdir"/usr/{bin,lib/{modprobe.d,systemd/system},share/{doc/"$pkgname"/{,examples},man/man{1,5}}}
  install -D -m755 "$pkgname" "$pkgdir"/usr/bin
  install -D -m644 examples/* "$pkgdir"/usr/share/doc/"$pkgname"/examples
  install -D -m644 "$pkgname".1 "$pkgdir"/usr/share/man/man1
  install -D -m644 "$pkgname".conf.5 "$pkgdir"/usr/share/man/man5
  install -D -m644 "$srcdir/$pkgname".service rcscripts/systemd/thinkfan-{sleep,wakeup}.service "$pkgdir"/usr/lib/systemd/system
  install -D -m644 rcscripts/systemd/override.conf "$pkgdir"/usr/lib/systemd/system/thinkfan.service.d/override.conf
  install -D -m644 "$srcdir"/thinkpad_acpi.conf "$pkgdir"/usr/lib/modprobe.d
}

# vim:set ts=2 sw=2 noet:
