configure.ac rework
- Put libusb and PC/SC check in m4 macros. - Suppress --disable-pcsclite and --disable-libusb - Add --with-drivers option: we now could choose which driver to build. without this option a default set is build (ATM all drivers except PN532_UART)
This commit is contained in:
parent
b747573dc7
commit
b55400a0d5
13 changed files with 230 additions and 122 deletions
52
m4/libnfc_check_libusb.m4
Normal file
52
m4/libnfc_check_libusb.m4
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
dnl Check for LIBUSB
|
||||
dnl On success, HAVE_LIBUSB is set to 1 and PKG_CONFIG_REQUIRES is filled when
|
||||
dnl libusb is found using pkg-config
|
||||
|
||||
AC_DEFUN([LIBNFC_CHECK_LIBUSB],
|
||||
[
|
||||
if test x"$libusb_required" = "xyes"; then
|
||||
HAVE_LIBUSB=0
|
||||
|
||||
# Search using pkg-config
|
||||
if test x"$PKG_CONFIG" != "x"; then
|
||||
PKG_CHECK_MODULES([libusb], [libusb], [HAVE_LIBUSB=1], [HAVE_LIBUSB=0])
|
||||
if test x"$HAVE_LIBUSB" = "x1"; then
|
||||
if test x"$PKG_CONFIG_REQUIRES" != x""; then
|
||||
PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES,"
|
||||
fi
|
||||
PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES libusb"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for libusb)
|
||||
|
||||
# Search using libusb-config
|
||||
if test x"$HAVE_LIBUSB" = "x0"; then
|
||||
AC_PATH_PROG(libusb_CONFIG,libusb-config)
|
||||
if test x"$libusb_CONFIG" != "x" ; then
|
||||
libusb_CFLAGS=`$libusb_CONFIG --cflags`
|
||||
libusb_LIBS=`$libusb_CONFIG --libs`
|
||||
HAVE_LIBUSB=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Search the library and headers directly (last chance)
|
||||
if test x"$HAVE_LIBUSB" = "x0"; then
|
||||
AC_CHECK_HEADER(usb.h, [], [AC_MSG_ERROR([The libusb headers are missing])])
|
||||
AC_CHECK_LIB(usb, libusb_init, [], [AC_MSG_ERROR([The libusb library is missing])])
|
||||
|
||||
libusb_LIBS="-lusb"
|
||||
HAVE_LIBUSB=1
|
||||
fi
|
||||
|
||||
if test x"$HAVE_LIBUSB" = "x0"; then
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([libusb is mandatory.])
|
||||
else
|
||||
AC_MSG_RESULT(yes)
|
||||
fi
|
||||
|
||||
AC_SUBST(libusb_LIBS)
|
||||
AC_SUBST(libusb_CFLAGS)
|
||||
fi
|
||||
])
|
||||
29
m4/libnfc_check_pcsc.m4
Normal file
29
m4/libnfc_check_pcsc.m4
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
dnl Check for PCSC presence (if required)
|
||||
dnl On success, HAVE_PCSC is set to 1 and PKG_CONFIG_REQUIRES is filled when
|
||||
dnl libpcsclite is found using pkg-config
|
||||
|
||||
AC_DEFUN([LIBNFC_CHECK_PCSC],
|
||||
[
|
||||
if test "x$pcsc_required" = "xyes"; then
|
||||
case "$host" in
|
||||
*darwin*)
|
||||
AC_MSG_CHECKING(for PC/SC)
|
||||
libpcsclite_LIBS="-Wl,-framework,PCSC"
|
||||
libpcsclite_CFLAGS="-I/System/Library/Frameworks/PCSC.framework/Headers"
|
||||
AC_MSG_RESULT(yes: darwin PC/SC framework)
|
||||
;;
|
||||
*)
|
||||
PKG_CHECK_MODULES([libpcsclite], [libpcsclite], [HAVE_PCSC=1], [HAVE_PCSC=0])
|
||||
if test x"$HAVE_PCSC" = "x0" ; then
|
||||
AC_MSG_ERROR([libpcsclite is mandatory.])
|
||||
fi
|
||||
if test x"$PKG_CONFIG_REQUIRES" != x""; then
|
||||
PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES,"
|
||||
fi
|
||||
PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES libpcsclite"
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(libpcsclite_LIBS)
|
||||
AC_SUBST(libpcsclite_CFLAGS)
|
||||
fi
|
||||
])
|
||||
64
m4/libnfc_drivers.m4
Normal file
64
m4/libnfc_drivers.m4
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
dnl Handle drivers arguments list
|
||||
|
||||
AC_DEFUN([LIBNFC_ARG_WITH_DRIVERS],
|
||||
[
|
||||
AC_MSG_CHECKING(which drivers to build)
|
||||
AC_ARG_WITH(drivers,
|
||||
AC_HELP_STRING([[[[--with-drivers=driver@<:@,driver...@:>@]]]], [Only use specific drivers (default set)]),
|
||||
[ case "${withval}" in
|
||||
yes | no)
|
||||
dnl ignore calls without any arguments
|
||||
DRIVER_BUILD_LIST="default"
|
||||
AC_MSG_RESULT(default drivers)
|
||||
;;
|
||||
*)
|
||||
DRIVER_BUILD_LIST=`echo ${withval} | sed "s/,/ /g"`
|
||||
AC_MSG_RESULT(${DRIVER_BUILD_LIST})
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[
|
||||
DRIVER_BUILD_LIST="default"
|
||||
AC_MSG_RESULT(default drivers)
|
||||
]
|
||||
)
|
||||
|
||||
case "${DRIVER_BUILD_LIST}" in
|
||||
default)
|
||||
DRIVER_BUILD_LIST="acr122 arygon pn531_usb pn533_usb"
|
||||
;;
|
||||
all)
|
||||
DRIVER_BUILD_LIST="acr122 arygon pn531_usb pn533_usb pn532_uart"
|
||||
;;
|
||||
esac
|
||||
|
||||
DRIVERS_CFLAGS=""
|
||||
|
||||
for driver in ${DRIVER_BUILD_LIST}
|
||||
do
|
||||
case "${driver}" in
|
||||
acr122)
|
||||
pcsc_required="yes"
|
||||
DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_ACR122_ENABLED"
|
||||
;;
|
||||
pn531_usb)
|
||||
libusb_required="yes"
|
||||
DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN531_USB_ENABLED"
|
||||
;;
|
||||
pn533_usb)
|
||||
libusb_required="yes"
|
||||
DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN533_USB_ENABLED"
|
||||
;;
|
||||
arygon)
|
||||
DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_ARYGON_ENABLED"
|
||||
;;
|
||||
pn532_uart)
|
||||
DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN532_UART_ENABLED"
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([Unknow driver: $driver])
|
||||
;;
|
||||
esac
|
||||
done
|
||||
AC_SUBST(DRIVERS_CFLAGS)
|
||||
])
|
||||
Loading…
Add table
Add a link
Reference in a new issue