diff --git a/configure.ac b/configure.ac index 2aed395..6cdf157 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,8 @@ AC_TYPE_UINT32_T AC_TYPE_UINT64_T AC_TYPE_INT32_T +LIBNFC_CFLAGS='-I$(top_srcdir)/src/lib -I$(top_builddir)/src/include -I$(top_srcdir)/src/include' +AC_SUBST(LIBNFC_CFLAGS) # Debug support (default:no) AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Enable debug output]),[enable_debug=$enableval],[enable_debug="no"]) @@ -197,6 +199,8 @@ fi AC_CONFIG_FILES([ Makefile + src/include/Makefile + src/include/nfc/Makefile src/lib/chips/Makefile src/lib/buses/Makefile src/lib/drivers/Makefile diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2c9bb88..bfb6e05 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,7 +17,8 @@ IF(MSVC) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../win32/stdint) ENDIF(MSVC) -INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include) ADD_SUBDIRECTORY(lib) ADD_SUBDIRECTORY(examples) +ADD_SUBDIRECTORY(include) diff --git a/src/Makefile.am b/src/Makefile.am index 0dbeb31..53ff473 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,2 +1,5 @@ -SUBDIRS = lib examples + +INCLUDES = $(LIBNFC_CFLAGS) + +SUBDIRS = lib examples include diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 1dffda8..6f82da4 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -12,6 +12,10 @@ FOREACH(source ${EXAMPLES-SOURCES}) INSTALL(TARGETS ${source} RUNTIME DESTINATION bin COMPONENT examples) ENDFOREACH(source) +# Headers +FILE(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") +INSTALL(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/nfc COMPONENT headers) + # Manuals for the examples FILE(GLOB manuals "${CMAKE_CURRENT_SOURCE_DIR}/*.1") INSTALL(FILES ${manuals} DESTINATION ${SHARE_INSTALL_PREFIX}/man/man1 COMPONENT manuals) diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am index fecafe7..a028e65 100644 --- a/src/examples/Makefile.am +++ b/src/examples/Makefile.am @@ -1,7 +1,7 @@ bin_PROGRAMS = nfc-anticol nfc-list nfc-mfclassic nfc-mfultralight nfc-relay nfc-emulate nfcip-target nfcip-initiator # set the include path found by configure -INCLUDES= $(all_includes) +INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) nfcinclude_HEADERS = mifaretag.h mifareultag.h nfcincludedir = $(includedir)/nfc diff --git a/src/examples/nfc-anticol.c b/src/examples/nfc-anticol.c index f6b606b..d0647cd 100644 --- a/src/examples/nfc-anticol.c +++ b/src/examples/nfc-anticol.c @@ -28,9 +28,9 @@ #include #include -#include +#include -#include "nfc-messages.h" +#include #include "bitutils.h" #define SAK_FLAG_ATS_SUPPORTED 0x20 diff --git a/src/examples/nfc-emulate.c b/src/examples/nfc-emulate.c index 28ab002..9193b2f 100644 --- a/src/examples/nfc-emulate.c +++ b/src/examples/nfc-emulate.c @@ -27,9 +27,9 @@ #include #include -#include +#include -#include "nfc-messages.h" +#include #include "bitutils.h" #define MAX_FRAME_LEN 264 diff --git a/src/examples/nfc-list.c b/src/examples/nfc-list.c index 42f8ce8..c26a8a9 100644 --- a/src/examples/nfc-list.c +++ b/src/examples/nfc-list.c @@ -27,9 +27,9 @@ #include -#include +#include -#include "nfc-messages.h" +#include #include "bitutils.h" #define MAX_DEVICE_COUNT 16 diff --git a/src/examples/nfc-mfclassic.c b/src/examples/nfc-mfclassic.c index 7844f45..f04b00d 100644 --- a/src/examples/nfc-mfclassic.c +++ b/src/examples/nfc-mfclassic.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include "mifaretag.h" #include "bitutils.h" diff --git a/src/examples/nfc-mfultralight.c b/src/examples/nfc-mfultralight.c index 0766f02..c54aff1 100644 --- a/src/examples/nfc-mfultralight.c +++ b/src/examples/nfc-mfultralight.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include "mifareultag.h" #include "bitutils.h" diff --git a/src/examples/nfc-relay.c b/src/examples/nfc-relay.c index 5988689..a6288c2 100644 --- a/src/examples/nfc-relay.c +++ b/src/examples/nfc-relay.c @@ -27,9 +27,9 @@ #include #include -#include +#include -#include "nfc-messages.h" +#include #include "bitutils.h" #define MAX_FRAME_LEN 264 diff --git a/src/examples/nfcip-initiator.c b/src/examples/nfcip-initiator.c index beca7e5..4ef373a 100644 --- a/src/examples/nfcip-initiator.c +++ b/src/examples/nfcip-initiator.c @@ -23,7 +23,7 @@ #include #include -#include +#include #define MAX_FRAME_LEN 264 diff --git a/src/examples/nfcip-target.c b/src/examples/nfcip-target.c index e684242..6739b4f 100644 --- a/src/examples/nfcip-target.c +++ b/src/examples/nfcip-target.c @@ -22,7 +22,7 @@ */ #include -#include +#include #define MAX_FRAME_LEN 264 diff --git a/src/include/Makefile.am b/src/include/Makefile.am new file mode 100644 index 0000000..dfad0ea --- /dev/null +++ b/src/include/Makefile.am @@ -0,0 +1,3 @@ + +SUBDIRS = nfc + diff --git a/src/include/nfc/Makefile.am b/src/include/nfc/Makefile.am new file mode 100644 index 0000000..c4ba3db --- /dev/null +++ b/src/include/nfc/Makefile.am @@ -0,0 +1,4 @@ + +nfcinclude_HEADERS = nfc.h nfc-types.h nfc-messages.h +nfcincludedir = $(includedir)/nfc + diff --git a/src/lib/nfc-messages.h b/src/include/nfc/nfc-messages.h similarity index 100% rename from src/lib/nfc-messages.h rename to src/include/nfc/nfc-messages.h diff --git a/src/lib/nfc-types.h b/src/include/nfc/nfc-types.h similarity index 99% rename from src/lib/nfc-types.h rename to src/include/nfc/nfc-types.h index 8f3c7a7..72f8e2a 100644 --- a/src/lib/nfc-types.h +++ b/src/include/nfc/nfc-types.h @@ -33,6 +33,7 @@ #include #include #include +#include typedef uint8_t byte_t; diff --git a/src/lib/nfc.h b/src/include/nfc/nfc.h similarity index 99% rename from src/lib/nfc.h rename to src/include/nfc/nfc.h index f94bc6f..3593362 100644 --- a/src/lib/nfc.h +++ b/src/include/nfc/nfc.h @@ -30,7 +30,7 @@ #include -#include "nfc-types.h" +#include #ifdef __cplusplus #define NFCAPI extern "C" { diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index eea4859..bf0dd68 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -34,7 +34,7 @@ SET(LIBRARY_SOURCES nfc bitutils ${DRIVERS_SOURCES} ${BUSES_SOURCES} ${CHIPS_SOU INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) ADD_LIBRARY(nfc SHARED ${LIBRARY_SOURCES}) TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES} ${PCSC_LIBRARIES}) -SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 0 VERSION 0.0.0) +SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 0) IF(MSVC) # On Windows the shared (runtime) library should be either in the same @@ -47,15 +47,3 @@ ELSE(MSVC) INSTALL(TARGETS nfc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) ENDIF(MSVC) -# Headers -FILE(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") -INSTALL(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/libnfc COMPONENT headers) -IF(MSVC) - # On Windows we also install the stdint headers, without it programs using it - # can't compile (like if we want to compile the included examples "out of - # tree") - #FILE(GLOB stdint "${CMAKE_CURRENT_SOURCE_DIR}/msvc/*.h") - #INSTALL(FILES ${stdint} DESTINATION ${INCLUDE_INSTALL_DIR}/libnfc COMPONENT headers) -ENDIF(MSVC) - - diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 24924ef..c4b1682 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -1,10 +1,7 @@ SUBDIRS = chips buses drivers . # set the include path found by configure -INCLUDES= $(all_includes) - -nfcinclude_HEADERS = nfc.h nfc-types.h nfc-messages.h chips.h buses.h drivers.h bitutils.h -nfcincludedir = $(includedir)/nfc +INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) lib_LTLIBRARIES = libnfc.la libnfc_la_SOURCES = nfc.c bitutils.c @@ -25,3 +22,4 @@ if LIBUSB_ENABLED libnfc_la_LIBADD += @LIBUSB_LIBS@ endif +EXTRA_DIST = chips.h buses.h drivers.h bitutils.h \ No newline at end of file diff --git a/src/lib/bitutils.h b/src/lib/bitutils.h index a34941e..7d7f8ee 100644 --- a/src/lib/bitutils.h +++ b/src/lib/bitutils.h @@ -26,7 +26,7 @@ #include -#include "nfc-types.h" +#include byte_t oddparity(const byte_t bt); void oddparity_byte_ts(const byte_t* pbtData, const size_t szLen, byte_t* pbtPar); diff --git a/src/lib/buses.h b/src/lib/buses.h index a5c7295..2925b26 100644 --- a/src/lib/buses.h +++ b/src/lib/buses.h @@ -21,5 +21,5 @@ * @brief */ -#include "nfc-types.h" +#include diff --git a/src/lib/buses/Makefile.am b/src/lib/buses/Makefile.am index e853581..0458631 100644 --- a/src/lib/buses/Makefile.am +++ b/src/lib/buses/Makefile.am @@ -1,6 +1,6 @@ # set the include path found by configure -INCLUDES= $(all_includes) +INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) noinst_HEADERS = uart.h noinst_LTLIBRARIES = libnfcbuses.la diff --git a/src/lib/buses/uart.c b/src/lib/buses/uart.c index c12aa3d..1f7f0d7 100644 --- a/src/lib/buses/uart.c +++ b/src/lib/buses/uart.c @@ -28,7 +28,7 @@ http://www.teuniz.net/RS-232/index.html #include "uart.h" -#include "nfc-messages.h" +#include // Test if we are dealing with unix operating systems #ifndef _WIN32 diff --git a/src/lib/buses/uart.h b/src/lib/buses/uart.h index a01213b..78f5819 100644 --- a/src/lib/buses/uart.h +++ b/src/lib/buses/uart.h @@ -29,7 +29,7 @@ #include -#include "nfc-types.h" +#include // Handle platform specific includes #ifndef _WIN32 diff --git a/src/lib/chips.h b/src/lib/chips.h index 109d015..221b46e 100644 --- a/src/lib/chips.h +++ b/src/lib/chips.h @@ -24,7 +24,7 @@ #ifndef __NFC_CHIPS_H__ #define __NFC_CHIPS_H__ -#include "nfc-types.h" +#include #include "chips/pn53x.h" diff --git a/src/lib/chips/Makefile.am b/src/lib/chips/Makefile.am index 9cf69f5..7bfd4da 100644 --- a/src/lib/chips/Makefile.am +++ b/src/lib/chips/Makefile.am @@ -1,6 +1,6 @@ # set the include path found by configure -INCLUDES= $(all_includes) +INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) noinst_HEADERS = pn53x.h noinst_LTLIBRARIES = libnfcchips.la diff --git a/src/lib/chips/pn53x.c b/src/lib/chips/pn53x.c index ac405e9..5732d75 100644 --- a/src/lib/chips/pn53x.c +++ b/src/lib/chips/pn53x.c @@ -26,7 +26,7 @@ #include "pn53x.h" -#include "bitutils.h" +#include "../bitutils.h" // PN53X configuration const byte_t pncmd_get_firmware_version [ 2] = { 0xD4,0x02 }; diff --git a/src/lib/chips/pn53x.h b/src/lib/chips/pn53x.h index e151d95..375ee8f 100644 --- a/src/lib/chips/pn53x.h +++ b/src/lib/chips/pn53x.h @@ -24,7 +24,7 @@ #ifndef __NFC_CHIPS_PN53X_H__ #define __NFC_CHIPS_PN53X_H__ -#include "nfc-types.h" +#include #define MAX_FRAME_LEN 264 diff --git a/src/lib/drivers.h b/src/lib/drivers.h index d20a981..91eabc0 100644 --- a/src/lib/drivers.h +++ b/src/lib/drivers.h @@ -24,7 +24,7 @@ #ifndef __NFC_DRIVERS_H__ #define __NFC_DRIVERS_H__ -#include "nfc-types.h" +#include #ifdef HAVE_PCSC_LITE #include "drivers/acr122.h" diff --git a/src/lib/drivers/Makefile.am b/src/lib/drivers/Makefile.am index 6e34bc7..47d2ac8 100644 --- a/src/lib/drivers/Makefile.am +++ b/src/lib/drivers/Makefile.am @@ -1,5 +1,5 @@ # set the include path found by configure -INCLUDES= $(all_includes) +INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) noinst_HEADERS = arygon.h pn532_uart.h noinst_LTLIBRARIES = libnfcdrivers.la diff --git a/src/lib/drivers/acr122.c b/src/lib/drivers/acr122.c index 8d9c81f..ba18a2f 100644 --- a/src/lib/drivers/acr122.c +++ b/src/lib/drivers/acr122.c @@ -38,7 +38,7 @@ #endif -#include "nfc-messages.h" +#include // WINDOWS: #define IOCTL_CCID_ESCAPE_SCARD_CTL_CODE SCARD_CTL_CODE(3500) #define IOCTL_CCID_ESCAPE_SCARD_CTL_CODE (((0x31) << 16) | ((3500) << 2)) diff --git a/src/lib/drivers/acr122.h b/src/lib/drivers/acr122.h index 8291cc5..69ab71e 100644 --- a/src/lib/drivers/acr122.h +++ b/src/lib/drivers/acr122.h @@ -28,7 +28,7 @@ #include -#include "nfc-types.h" +#include #define ACR122_DRIVER_NAME "ACR122" diff --git a/src/lib/drivers/arygon.c b/src/lib/drivers/arygon.c index b63c2b9..2722e78 100644 --- a/src/lib/drivers/arygon.c +++ b/src/lib/drivers/arygon.c @@ -25,12 +25,12 @@ #include "arygon.h" -#include "nfc-messages.h" +#include #include "../drivers.h" #include "../bitutils.h" // Bus -#include "uart.h" +#include "../buses/uart.h" #ifdef _WIN32 #define SERIAL_STRING "COM" diff --git a/src/lib/drivers/arygon.h b/src/lib/drivers/arygon.h index b6fffc9..01f80b3 100644 --- a/src/lib/drivers/arygon.h +++ b/src/lib/drivers/arygon.h @@ -24,7 +24,7 @@ #ifndef __NFC_DRIVER_ARYGON_H__ #define __NFC_DRIVER_ARYGON_H__ -#include "nfc-types.h" +#include #define ARYGON_DRIVER_NAME "ARYGON" diff --git a/src/lib/drivers/pn531_usb.c b/src/lib/drivers/pn531_usb.c index 7c96266..17e6f24 100644 --- a/src/lib/drivers/pn531_usb.c +++ b/src/lib/drivers/pn531_usb.c @@ -35,7 +35,7 @@ Thanks to d18c7db and Okko for example code #include "pn531_usb.h" #include "../drivers.h" -#include "nfc-messages.h" +#include #include "../bitutils.h" #define BUFFER_LENGTH 256 diff --git a/src/lib/drivers/pn531_usb.h b/src/lib/drivers/pn531_usb.h index e7b0a45..cbef32f 100644 --- a/src/lib/drivers/pn531_usb.h +++ b/src/lib/drivers/pn531_usb.h @@ -27,7 +27,7 @@ #include #include -#include "nfc-types.h" +#include #define PN531_USB_DRIVER_NAME "PN531_USB" diff --git a/src/lib/drivers/pn532_uart.c b/src/lib/drivers/pn532_uart.c index d4d06c5..0227aab 100644 --- a/src/lib/drivers/pn532_uart.c +++ b/src/lib/drivers/pn532_uart.c @@ -25,7 +25,7 @@ #include "pn532_uart.h" -#include "nfc-messages.h" +#include #include "../drivers.h" #include "../bitutils.h" diff --git a/src/lib/drivers/pn532_uart.h b/src/lib/drivers/pn532_uart.h index 944058c..a49aad2 100644 --- a/src/lib/drivers/pn532_uart.h +++ b/src/lib/drivers/pn532_uart.h @@ -24,7 +24,7 @@ #ifndef __NFC_DRIVER_PN532_UART_H__ #define __NFC_DRIVER_PN532_UART_H__ -#include "nfc-types.h" +#include #define PN532_UART_DRIVER_NAME "PN532_UART" diff --git a/src/lib/drivers/pn533_usb.c b/src/lib/drivers/pn533_usb.c index 80d3df0..5bba127 100644 --- a/src/lib/drivers/pn533_usb.c +++ b/src/lib/drivers/pn533_usb.c @@ -33,7 +33,7 @@ Thanks to d18c7db and Okko for example code #include "pn533_usb.h" #include "../drivers.h" -#include "nfc-messages.h" +#include #define BUFFER_LENGTH 256 #define USB_TIMEOUT 30000 diff --git a/src/lib/drivers/pn533_usb.h b/src/lib/drivers/pn533_usb.h index ce662f2..4103e9a 100644 --- a/src/lib/drivers/pn533_usb.h +++ b/src/lib/drivers/pn533_usb.h @@ -24,7 +24,7 @@ #ifndef __NFC_DRIVER_PN533_USB_H__ #define __NFC_DRIVER_PN533_USB_H__ -#include "nfc-types.h" +#include #define PN533_USB_DRIVER_NAME "PN533_USB" diff --git a/src/lib/nfc.c b/src/lib/nfc.c index 605f854..2293460 100644 --- a/src/lib/nfc.c +++ b/src/lib/nfc.c @@ -26,12 +26,12 @@ #include #include -#include "nfc.h" +#include #include "chips.h" #include "drivers.h" -#include "nfc-messages.h" +#include #include "../../config.h"