PORTNAME=	libnfc
PORTVERSION=	1.8.0
PORTREVISION=	1
CATEGORIES=	devel
MASTER_SITES=	https://github.com/nfc-tools/libnfc/releases/download/libnfc-${PORTVERSION}/

MAINTAINER=	romain@FreeBSD.org
COMMENT=	Near Field Communication (NFC) library
WWW=		http://www.libnfc.org

LICENSE=	LGPL3+

#OPTIONS_DEFINE=	ACR122_PCSC ACR122_USB ACR122S ARYGON PN532_I2C PN532_SPI PN532_UART PN53X_USB
#OPTIONS_DEFAULT=ACR122_USB ACR122S ARYGON PN532_I2C PN532_SPI PN532_UART PN53X_USB
OPTIONS_DEFINE=	ACR122_PCSC ACR122_USB ACR122S ARYGON PN532_UART PN53X_USB EXAMPLES
OPTIONS_DEFAULT=ACR122_USB ACR122S ARYGON PN532_UART PN53X_USB
ACR122_PCSC_DESC=ACR122 driver (PC/SC)
ACR122_USB_DESC=ACR122 driver (USB)
ACR122S_DESC=	ACR122 driver (UART)
ARYGON_DESC=	Arygon driver
#PN532_I2C_DESC=PN532 I2C driver
#PN532_SPI_DESC=PN532 SPI driver
PN532_UART_DESC=PN532 UART driver
PN53X_USB_DESC=	PN53X USB driver

GNU_CONFIGURE=	yes
GNU_CONFIGURE_MANPREFIX=	${PREFIX}/share
USES=		gmake libtool pathfix pkgconfig readline tar:bzip2
USE_LDCONFIG=	yes
MAKE_ENV=	INSTALL_STRIP_FLAG="${STRIP}"
CFLAGS+=	-D__BSD_VISIBLE

# Restrict to stable (even) versions, indicated by the second component.
PORTSCOUT=	limitw:1,even

.include <bsd.port.options.mk>

.if ${PORT_OPTIONS:MACR122_PCSC}
ACR122_PCSC_DRIVER=	acr122_pcsc,
.else
ACR122_PCSC_DRIVER=
.endif

.if ${PORT_OPTIONS:MACR122_USB}
ACR122_USB_DRIVER=	acr122_usb,
.else
ACR122_USB_DRIVER=
.endif

.if ${PORT_OPTIONS:MACR122S}
ACR122S_DRIVER=	acr122s,
.else
ACR122S_DRIVER=
.endif

.if ${PORT_OPTIONS:MARYGON}
ARYGON_DRIVER=	arygon,
.else
ARYGON_DRIVER=
.endif

#.if ${PORT_OPTIONS:MPN532_I2C}
#PN532_I2C_DRIVER=pn532_i2c,
#.else
#PN532_I2C_DRIVER=
#.endif

#.if ${PORT_OPTIONS:MPN532_SPI}
#PN532_SPI_DRIVER=pn532_spi,
#.else
#PN532_SPI_DRIVER=
#.endif

.if ${PORT_OPTIONS:MPN532_UART}
PN532_UART_DRIVER=pn532_uart,
.else
PN532_UART_DRIVER=
.endif

.if ${PORT_OPTIONS:MPN53X_USB}
PN53X_USB_DRIVER=pn53x_usb,
.else
PN53X_USB_DRIVER=
.endif

CONFIGURE_ARGS+=--with-drivers="${ACR122_PCSC_DRIVER}${ACR122_USB_DRIVER}${ACR122S_DRIVER}${ARYGON_DRIVER}${PN532_I2C_DRIVER}${PN532_SPI_DRIVER}${PN532_UART_DRIVER}${PN53X_USB_DRIVER}"

.if ${PORT_OPTIONS:MACR122_PCSC}
LIB_DEPENDS+=	libpcsclite.so:devel/pcsc-lite
RUN_DEPENDS+=	${LOCALBASE}/lib/pcsc/drivers/ifd-ccid.bundle/Contents/FreeBSD/libccid.so:devel/libccid
.endif

post-install:
.if ${PORT_OPTIONS:MEXAMPLES}
	${MKDIR} ${STAGEDIR}/${EXAMPLESDIR}
	${INSTALL_DATA} ${WRKSRC}/contrib/devd/pn53x.conf ${STAGEDIR}/${EXAMPLESDIR}
.endif

.include <bsd.port.mk>
