From 17e615e8b1109afd8934f485da351c776fa6b875 Mon Sep 17 00:00:00 2001 From: Dan Church Date: Mon, 11 May 2020 13:10:48 -0500 Subject: [PATCH] Add check for Libnfc-NCI before enabling pn71xx If the user specifically requests the driver, throw an error if it cannot find libnfc-nci. Also use the value from pkg-config to determine the library name, instead of hard-coding it. --- configure.ac | 11 +++++++++++ libnfc/drivers/Makefile.am | 2 +- m4/libnfc_drivers.m4 | 7 ++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index ad8d34cb..47bbf8db 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,7 @@ AC_HEADER_STDBOOL AC_CHECK_HEADERS([fcntl.h limits.h stdio.h stdlib.h stdint.h stddef.h stdbool.h sys/ioctl.h sys/param.h sys/time.h termios.h]) AC_CHECK_HEADERS([linux/spi/spidev.h], [spi_available="yes"]) AC_CHECK_HEADERS([linux/i2c-dev.h], [i2c_available="yes"]) +AC_CHECK_HEADERS([linux_nfc_api.h], [nfc_nci_available="yes"]) AC_CHECK_FUNCS([memmove memset select strdup strerror strstr strtol usleep], [AC_DEFINE([_XOPEN_SOURCE], [600], [Enable POSIX extensions if present])]) @@ -130,6 +131,16 @@ then AC_SEARCH_LIBS([clock_gettime], [rt]) fi +# Enable Libnfc-NCI if required +if test x"$nfc_nci_required" = x"yes" +then + PKG_CHECK_MODULES([LIBNFC_NCI], [libnfc-nci], + [AC_MSG_NOTICE([libnfc-nci present])], + [AC_MSG_ERROR([libnfc-nci not present but required for some drivers configuration])] + ) + CFLAGS="$CPPFLAGS $LIBNFC_NCI_CFLAGS" +fi + # Documentation (default: no) AC_ARG_ENABLE([doc],AS_HELP_STRING([--enable-doc],[Enable documentation generation.]),[enable_doc=$enableval],[enable_doc="no"]) diff --git a/libnfc/drivers/Makefile.am b/libnfc/drivers/Makefile.am index 3f4d7682..2e6ad451 100644 --- a/libnfc/drivers/Makefile.am +++ b/libnfc/drivers/Makefile.am @@ -44,7 +44,7 @@ libnfcdrivers_la_SOURCES += pn532_i2c.c pn532_i2c.h endif if DRIVER_PN71XX_ENABLED -libnfcdrivers_la_LIBADD += -lnfc_nci_linux +libnfcdrivers_la_LIBADD += @LIBNFC_NCI_LIBS@ libnfcdrivers_la_SOURCES += pn71xx.c pn71xx.h endif diff --git a/m4/libnfc_drivers.m4 b/m4/libnfc_drivers.m4 index c8a75fff..901f9d32 100644 --- a/m4/libnfc_drivers.m4 +++ b/m4/libnfc_drivers.m4 @@ -37,7 +37,7 @@ AC_DEFUN([LIBNFC_ARG_WITH_DRIVERS], fi ;; all) - DRIVER_BUILD_LIST="acr122_pcsc acr122_usb acr122s arygon pn53x_usb pn532_uart pn71xx pcsc" + DRIVER_BUILD_LIST="acr122_pcsc acr122_usb acr122s arygon pn53x_usb pn532_uart pcsc" if test x"$spi_available" = x"yes" then @@ -47,6 +47,10 @@ AC_DEFUN([LIBNFC_ARG_WITH_DRIVERS], then DRIVER_BUILD_LIST="$DRIVER_BUILD_LIST pn532_i2c" fi + if test x"$nfc_nci_available" = x"yes" + then + DRIVER_BUILD_LIST="$DRIVER_BUILD_LIST pn71xx" + fi ;; esac @@ -112,6 +116,7 @@ AC_DEFUN([LIBNFC_ARG_WITH_DRIVERS], DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN532_I2C_ENABLED" ;; pn71xx) + nfc_nci_required="yes" driver_pn71xx_enabled="yes" DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN71XX_ENABLED" ;;