# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Christoph Hoopmann <choopm at 0pointer.org>
# Contributor: Pascal E. <archlinux at hardfalcon dot net>
# Contributor: Andrej Gelenberg <andrej.gelenberg at udo dot edu>

pkgname=libnfc
pkgver=1.7.1+204+g4ae4cc8
pkgrel=1
pkgdesc="Platform independent Near Field Communication (NFC) library"
arch=('x86_64')
url="http://nfc-tools.org/"
license=('LGPL3')
depends=('libusb-compat' 'pcsclite')
makedepends=('cmake' 'git')
optdepends=('acsccid: acr122_pcsc support')
_commit=4ae4cc86f85dd7362e9f369ba2bff0ab258b1799 # Latest tested commit
source=("git+https://github.com/nfc-tools/libnfc.git#commit=${_commit}")
sha256sums=('SKIP')

pkgver() {
    cd ${pkgname}
    git describe --tags | sed 's/libnfc-//' |sed 's/-/+/g'
}

prepare() {
    mkdir -p build
    cd ${pkgname}
    # Use uaccess 
    sed -i "s|MODE=\"0664\", GROUP=\"plugdev\"|TAG+=\"uaccess\"|g" contrib/udev/93-pn53x.rules
}

build() {
    cd build
    cmake ../${pkgname} \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DLIBNFC_DRIVER_ACR122_PCSC=ON
    make
}

package() {
    cd build
    make DESTDIR="${pkgdir}" install
    cd ../${pkgname}
    install -Dm644 libnfc.conf.sample -t "${pkgdir}"/etc/nfc/
    install -Dm644 contrib/udev/93-pn53x.rules -t "${pkgdir}"/usr/lib/udev/rules.d/
    install -Dm644 contrib/linux/blacklist-libnfc.conf -t "$pkgdir"/etc/modprobe.d/
}
