# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=ccid
pkgver=1.5.5
pkgrel=1
pkgdesc='A generic USB Chip/Smart Card Interface Devices driver'
arch=('x86_64')
url='https://ccid.apdu.fr/'
license=('LGPL' 'GPL')
depends=('pcsclite' 'libusb' 'flex')
backup=('etc/reader.conf.d/libccidtwin')
source=("https://ccid.apdu.fr/files/${pkgname}-${pkgver}.tar.bz2"{,.asc})
sha256sums=('194708f75fe369d45dd7c15e8b3e8a7db8b49cfc5557574ca2a2e76ef12ca0ca'
            'SKIP')

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

  ./configure \
    LEXLIB='' \
    --prefix=/usr \
    --sysconfdir=/etc \
    --enable-twinserial \
    --enable-serialconfdir=/etc/reader.conf.d
  make
}

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

  make DESTDIR="${pkgdir}" install
  # move the configuration file in /etc and create a symbolic link
  mv "${pkgdir}/usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist" "${pkgdir}/etc/libccid_Info.plist"
  ln -s /etc/libccid_Info.plist "${pkgdir}/usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist"

  install -Dm644 src/92_pcscd_ccid.rules "${pkgdir}/usr/lib/udev/rules.d/92_pcscd_ccid.rules"
}
