From 3ec00eb06ca02e45de635ac39a450324bb5cfc8b Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Thu, 10 Sep 2009 09:28:17 +0000 Subject: [PATCH] libusb dependency can be disabled using CMake files - but it remove PN531USB and PN533USB support - this is useful for Windows newer than XP. (Thanks to Fkooman) --- CMakeLists.txt | 5 +++-- README-Windows.txt | 28 ++++++++++++++++++++-------- src/CMakeLists.txt | 8 ++++++-- src/devices.h | 8 ++++++-- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2549992..4636304 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,8 @@ SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") SET(LIBNFC_VERBOSE_OUTPUT OFF CACHE BOOL "Verbose output of communication with the NFC chip") SET(LIBNFC_LANG_C99 OFF CACHE BOOL "Use C99 language standard (GCC only)") -SET(LIBNFC_PCSC ON CACHE BOOL "Enable PC/SC support") +SET(LIBNFC_PCSC ON CACHE BOOL "Enable PC/SC support (PN532)") +SET(LIBNFC_USB OFF CACHE BOOL "Enable direct USB communication support (PN531 and PN533)") SET(LIBNFC_DISABLE_SERIAL_AUTOPROBE OFF CACHE BOOL "Disable serial autoprobe") # Set some pkg-config variables @@ -47,11 +48,11 @@ IF(MSVC) ELSE(MSVC) SET(CPACK_GENERATOR "TBZ2") ENDIF(MSVC) -SET(CPACK_PACKAGE_FILE_NAME "libnfc-${VERSION}-bin-${CMAKE_SYSTEM_PROCESSOR}") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Near Field Communication (NFC) library") SET(CPACK_PACKAGE_VENDOR "Roel Verdult") SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +SET(CPACK_PACKAGE_INSTALL_DIRECTORY "LibNFC") SET(CPACK_PACKAGE_VERSION_MAJOR "1") SET(CPACK_PACKAGE_VERSION_MINOR "2") SET(CPACK_PACKAGE_VERSION_PATCH "2") diff --git a/README-Windows.txt b/README-Windows.txt index 723b635..43d03ca 100644 --- a/README-Windows.txt +++ b/README-Windows.txt @@ -1,10 +1,9 @@ Requirements - Running ====================== -In order to run the included tools, at least these dependencies should be -installed: +In order to use the library and run included examples, at least this +dependency should be installed: -- LibUsb-Win32 0.1.12.2 [1] -- Microsoft Visual C++ 2008 SP1 Redistributable Package [2] +- Microsoft Visual C++ 2008 SP1 Redistributable Package [1] These C++ 2008 SP1 libraries are also part of "Microsoft .NET Framework 3.5 Service Pack 1 and .NET Framework 3.5 Family" which can be obtained through @@ -13,17 +12,25 @@ Windows Update. There are two versions of the redistributable package (one for x86 and one for x64). Be sure which one is needed. +An optional requirement is: + +- LibUsb-Win32 0.1.12.2 [2] + +In case support for the PN531USB and PN533USB is needed. LibUsb has serious issues +on Windows systems newer than Windows XP (and on 64 bit). See LibUsb support +mailing lists for more information. + Requirements - Development ========================== This project uses CMake for creating a Visual Studio project from the -source files. +source files. The following software was used to create the libnfc distribution: - CMake 2.6.4 [3] - Microsoft Windows SDK for Windows 7 (7.0) [4] - Microsoft .NET framework 3.5 SP1 (Windows Update) -- LibUsb-Win32 0.1.12.2 [1] +- LibUsb-Win32 0.1.12.2 (only on Windows XP builds) [2] - NSIS 2.45 (to create the installer) [5] - 7-Zip 4.65 (for generating source archive) [6] @@ -49,6 +56,11 @@ Now you can configure the build. Press "Configure", specify "NMake Makefiles" and then you have the opportunity to set some configuration variables. If you don't want a Debug build change the variable CMAKE_BUILD_TYPE to "Release". +If a non-GUI solution is preferred one can use: + + C:\dev\libnfc-read-only\bin> cmake -G "NMake Makefiles" + -DCMAKE_BUILD_TYPE=Release .. + Now run NMake: C:\dev\libnfc-read-only\bin> nmake package @@ -95,8 +107,8 @@ however. References ========== -[1] http://libusb-win32.sourceforge.net/ -[2] http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2 +[1] http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2 +[2] http://libusb-win32.sourceforge.net/ [3] http://www.cmake.org [4] http://msdn.microsoft.com/en-us/windows/bb980924.aspx [5] http://nsis.sourceforge.net/Main_Page diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3ee4dc6..1613f1d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -SET(LIBRARY-SOURCES libnfc dev_pn531 dev_pn533 rs232 bitutils dev_arygon) +SET(LIBRARY-SOURCES libnfc rs232 bitutils dev_arygon) SET(TOOLS-SOURCES list mftool mfultool initiator target anticol emulate relay) # find PCSC library and headers @@ -9,7 +9,11 @@ IF(LIBNFC_PCSC) ENDIF(LIBNFC_PCSC) # find libusb library and headers -FIND_PACKAGE(LIBUSB REQUIRED) +IF(LIBNFC_USB) + FIND_PACKAGE(LIBUSB REQUIRED) + ADD_DEFINITIONS("-DHAVE_LIBUSB=1") + SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "dev_pn531 dev_pn533") +ENDIF(LIBNFC_USB) IF(LIBNFC_VERBOSE_OUTPUT) ADD_DEFINITIONS("-DDEBUG") diff --git a/src/devices.h b/src/devices.h index e4145aa..f4a7c73 100644 --- a/src/devices.h +++ b/src/devices.h @@ -26,8 +26,10 @@ along with this program. If not, see #ifdef HAVE_PCSC_LITE #include "dev_acr122.h" #endif -#include "dev_pn531.h" -#include "dev_pn533.h" +#ifdef HAVE_LIBUSB + #include "dev_pn531.h" + #include "dev_pn533.h" +#endif HAVE_LIBUSB #include "dev_arygon.h" const static struct dev_callbacks dev_callbacks_list[] = { @@ -35,8 +37,10 @@ const static struct dev_callbacks dev_callbacks_list[] = { #ifdef HAVE_PCSC_LITE { "ACR122", dev_acr122_connect, dev_acr122_transceive, dev_acr122_disconnect }, #endif +#ifdef HAVE_LIBUSB { "PN531USB", dev_pn531_connect, dev_pn531_transceive, dev_pn531_disconnect }, { "PN533USB", dev_pn533_connect, dev_pn533_transceive, dev_pn533_disconnect }, +#endif HAVE_LIBUSB { "ARYGON", dev_arygon_connect, dev_arygon_transceive, dev_arygon_disconnect } };