diff --git a/CMakeLists.txt b/CMakeLists.txt index cd7fa91..3279fed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ IF(NOT MSVC) ENDIF(NOT MSVC) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include) # make it easy to locate CMake modules for finding libraries SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") @@ -84,7 +84,9 @@ IF(NOT MSVC) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) ENDIF(NOT MSVC) -ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(libnfc) +ADD_SUBDIRECTORY(include) +ADD_SUBDIRECTORY(examples) # Binary Package IF(MSVC) diff --git a/Makefile.am b/Makefile.am index 7b88856..1094fcb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,8 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = src cmake_modules +AM_CFLAGS = $(LIBNFC_CFLAGS) + +SUBDIRS = libnfc examples include cmake_modules pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libnfc.pc diff --git a/configure.ac b/configure.ac index 5345d31..209c108 100644 --- a/configure.ac +++ b/configure.ac @@ -46,7 +46,7 @@ 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' +LIBNFC_CFLAGS='-I$(top_srcdir)/libnfc -I$(top_builddir)/include -I$(top_srcdir)/include' AC_SUBST(LIBNFC_CFLAGS) # Debug support (default:no) @@ -189,14 +189,13 @@ CFLAGS="$CFLAGS -Du_int8_t=uint8_t -Du_int16_t=uint16_t" AC_CONFIG_FILES([ Makefile - src/include/Makefile - src/include/nfc/Makefile - src/lib/chips/Makefile - src/lib/buses/Makefile - src/lib/drivers/Makefile - src/lib/Makefile - src/examples/Makefile - src/Makefile + include/Makefile + include/nfc/Makefile + libnfc/chips/Makefile + libnfc/buses/Makefile + libnfc/drivers/Makefile + libnfc/Makefile + examples/Makefile cmake_modules/Makefile libnfc.pc Doxyfile diff --git a/src/examples/CMakeLists.txt b/examples/CMakeLists.txt similarity index 86% rename from src/examples/CMakeLists.txt rename to examples/CMakeLists.txt index 8098be0..2d1bda3 100644 --- a/src/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,7 @@ SET(EXAMPLES-SOURCES nfc-list nfc-mfclassic nfc-mfultralight nfcip-initiator nfcip-target nfc-anticol nfc-emulate nfc-relay) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../lib) +# XXX: Examples should not use private API! +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libnfc) INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS}) LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS} ${PCSC_LIBRARY_DIRS}) diff --git a/src/examples/Makefile.am b/examples/Makefile.am similarity index 61% rename from src/examples/Makefile.am rename to examples/Makefile.am index 1428bb9..333ffd4 100644 --- a/src/examples/Makefile.am +++ b/examples/Makefile.am @@ -6,31 +6,31 @@ INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) nfcinclude_HEADERS = mifaretag.h mifareultag.h nfcincludedir = $(includedir)/nfc -AM_CFLAGS = -I$(top_srcdir)/src/lib +AM_CFLAGS = -I$(top_srcdir)/libnfc nfc_anticol_SOURCES = nfc-anticol.c -nfc_anticol_LDADD = $(top_builddir)/src/lib/libnfc.la +nfc_anticol_LDADD = $(top_builddir)/libnfc/libnfc.la nfc_list_SOURCES = nfc-list.c -nfc_list_LDADD = $(top_builddir)/src/lib/libnfc.la +nfc_list_LDADD = $(top_builddir)/libnfc/libnfc.la nfc_mfultralight_SOURCES = nfc-mfultralight.c mifareultag.h -nfc_mfultralight_LDADD = $(top_builddir)/src/lib/libnfc.la +nfc_mfultralight_LDADD = $(top_builddir)/libnfc/libnfc.la nfc_mfclassic_SOURCES = nfc-mfclassic.c mifaretag.h -nfc_mfclassic_LDADD = $(top_builddir)/src/lib/libnfc.la +nfc_mfclassic_LDADD = $(top_builddir)/libnfc/libnfc.la nfc_relay_SOURCES = nfc-relay.c -nfc_relay_LDADD = $(top_builddir)/src/lib/libnfc.la +nfc_relay_LDADD = $(top_builddir)/libnfc/libnfc.la nfc_emulate_SOURCES = nfc-emulate.c -nfc_emulate_LDADD = $(top_builddir)/src/lib/libnfc.la +nfc_emulate_LDADD = $(top_builddir)/libnfc/libnfc.la nfcip_target_SOURCES = nfcip-target.c -nfcip_target_LDADD = $(top_builddir)/src/lib/libnfc.la +nfcip_target_LDADD = $(top_builddir)/libnfc/libnfc.la nfcip_initiator_SOURCES = nfcip-initiator.c -nfcip_initiator_LDADD = $(top_builddir)/src/lib/libnfc.la +nfcip_initiator_LDADD = $(top_builddir)/libnfc/libnfc.la dist_man_MANS = nfc-anticol.1 nfc-emulate.1 nfc-list.1 nfc-mfclassic.1 nfc-mfultralight.1 nfc-relay.1 diff --git a/src/examples/doc/quick_start_example1.c b/examples/doc/quick_start_example1.c similarity index 100% rename from src/examples/doc/quick_start_example1.c rename to examples/doc/quick_start_example1.c diff --git a/src/examples/mifaretag.h b/examples/mifaretag.h similarity index 100% rename from src/examples/mifaretag.h rename to examples/mifaretag.h diff --git a/src/examples/mifareultag.h b/examples/mifareultag.h similarity index 100% rename from src/examples/mifareultag.h rename to examples/mifareultag.h diff --git a/src/examples/nfc-anticol.1 b/examples/nfc-anticol.1 similarity index 100% rename from src/examples/nfc-anticol.1 rename to examples/nfc-anticol.1 diff --git a/src/examples/nfc-anticol.c b/examples/nfc-anticol.c similarity index 100% rename from src/examples/nfc-anticol.c rename to examples/nfc-anticol.c diff --git a/src/examples/nfc-emulate.1 b/examples/nfc-emulate.1 similarity index 100% rename from src/examples/nfc-emulate.1 rename to examples/nfc-emulate.1 diff --git a/src/examples/nfc-emulate.c b/examples/nfc-emulate.c similarity index 100% rename from src/examples/nfc-emulate.c rename to examples/nfc-emulate.c diff --git a/src/examples/nfc-list.1 b/examples/nfc-list.1 similarity index 100% rename from src/examples/nfc-list.1 rename to examples/nfc-list.1 diff --git a/src/examples/nfc-list.c b/examples/nfc-list.c similarity index 100% rename from src/examples/nfc-list.c rename to examples/nfc-list.c diff --git a/src/examples/nfc-mfclassic.1 b/examples/nfc-mfclassic.1 similarity index 100% rename from src/examples/nfc-mfclassic.1 rename to examples/nfc-mfclassic.1 diff --git a/src/examples/nfc-mfclassic.c b/examples/nfc-mfclassic.c similarity index 100% rename from src/examples/nfc-mfclassic.c rename to examples/nfc-mfclassic.c diff --git a/src/examples/nfc-mfultralight.1 b/examples/nfc-mfultralight.1 similarity index 100% rename from src/examples/nfc-mfultralight.1 rename to examples/nfc-mfultralight.1 diff --git a/src/examples/nfc-mfultralight.c b/examples/nfc-mfultralight.c similarity index 100% rename from src/examples/nfc-mfultralight.c rename to examples/nfc-mfultralight.c diff --git a/src/examples/nfc-relay.1 b/examples/nfc-relay.1 similarity index 100% rename from src/examples/nfc-relay.1 rename to examples/nfc-relay.1 diff --git a/src/examples/nfc-relay.c b/examples/nfc-relay.c similarity index 100% rename from src/examples/nfc-relay.c rename to examples/nfc-relay.c diff --git a/src/examples/nfcip-initiator.c b/examples/nfcip-initiator.c similarity index 100% rename from src/examples/nfcip-initiator.c rename to examples/nfcip-initiator.c diff --git a/src/examples/nfcip-target.c b/examples/nfcip-target.c similarity index 100% rename from src/examples/nfcip-target.c rename to examples/nfcip-target.c diff --git a/src/include/CMakeLists.txt b/include/CMakeLists.txt similarity index 100% rename from src/include/CMakeLists.txt rename to include/CMakeLists.txt diff --git a/src/include/Makefile.am b/include/Makefile.am similarity index 100% rename from src/include/Makefile.am rename to include/Makefile.am diff --git a/src/include/nfc/CMakeLists.txt b/include/nfc/CMakeLists.txt similarity index 100% rename from src/include/nfc/CMakeLists.txt rename to include/nfc/CMakeLists.txt diff --git a/src/include/nfc/Makefile.am b/include/nfc/Makefile.am similarity index 100% rename from src/include/nfc/Makefile.am rename to include/nfc/Makefile.am diff --git a/src/include/nfc/nfc-messages.h b/include/nfc/nfc-messages.h similarity index 100% rename from src/include/nfc/nfc-messages.h rename to include/nfc/nfc-messages.h diff --git a/src/include/nfc/nfc-types.h b/include/nfc/nfc-types.h similarity index 100% rename from src/include/nfc/nfc-types.h rename to include/nfc/nfc-types.h diff --git a/src/include/nfc/nfc.h b/include/nfc/nfc.h similarity index 100% rename from src/include/nfc/nfc.h rename to include/nfc/nfc.h diff --git a/src/lib/CMakeLists.txt b/libnfc/CMakeLists.txt similarity index 100% rename from src/lib/CMakeLists.txt rename to libnfc/CMakeLists.txt diff --git a/src/lib/Makefile.am b/libnfc/Makefile.am similarity index 80% rename from src/lib/Makefile.am rename to libnfc/Makefile.am index a1b7b2b..621bf7a 100644 --- a/src/lib/Makefile.am +++ b/libnfc/Makefile.am @@ -8,9 +8,9 @@ libnfc_la_SOURCES = nfc.c bitutils.c libnfc_la_LDFLAGS = -no-undefined -version-info=0:0:0 libnfc_la_CFLAGS = libnfc_la_LIBADD = \ - $(top_builddir)/src/lib/chips/libnfcchips.la \ - $(top_builddir)/src/lib/buses/libnfcbuses.la \ - $(top_builddir)/src/lib/drivers/libnfcdrivers.la + $(top_builddir)/libnfc/chips/libnfcchips.la \ + $(top_builddir)/libnfc/buses/libnfcbuses.la \ + $(top_builddir)/libnfc/drivers/libnfcdrivers.la if PCSC_LITE_ENABLED libnfc_la_CFLAGS += @LIBPCSCLITE_CFLAGS@ -DHAVE_PCSC_LITE diff --git a/src/lib/bitutils.c b/libnfc/bitutils.c similarity index 100% rename from src/lib/bitutils.c rename to libnfc/bitutils.c diff --git a/src/lib/bitutils.h b/libnfc/bitutils.h similarity index 80% rename from src/lib/bitutils.h rename to libnfc/bitutils.h index 1a9eea1..c3e35dc 100644 --- a/src/lib/bitutils.h +++ b/libnfc/bitutils.h @@ -26,27 +26,20 @@ #include +#include + /* * FIXME: There is no place for this here */ -#ifdef _WIN32 - /* Windows platform */ - #ifndef _WINDLL - /* CMake compilation */ - #ifdef nfc_EXPORTS - #define NFC_EXPORT __declspec(dllexport) - #else /* nfc_EXPORTS */ - #define NFC_EXPORT __declspec(dllimport) - #endif /* nfc_EXPORTS */ - #else /* _WINDLL */ - /* Manual makefile */ - #define NFC_EXPORT - #endif /* _WINDLL */ -#else /* _WIN32 */ - #define NFC_EXPORT -#endif /* _WIN32 */ - -#include +#if defined (_WIN32) + #if defined(nfc_EXPORTS) + #define NFC_EXPORT __declspec(dllexport) + #else + #define NFC_EXPORT __declspec(dllimport) + #endif /* nfc_EXPORTS */ +#else /* defined (_WIN32) */ + #define NFC_EXPORT +#endif 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/libnfc/buses.h similarity index 100% rename from src/lib/buses.h rename to libnfc/buses.h diff --git a/src/lib/buses/Makefile.am b/libnfc/buses/Makefile.am similarity index 78% rename from src/lib/buses/Makefile.am rename to libnfc/buses/Makefile.am index 0458631..cd4b87b 100644 --- a/src/lib/buses/Makefile.am +++ b/libnfc/buses/Makefile.am @@ -5,5 +5,5 @@ INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) noinst_HEADERS = uart.h noinst_LTLIBRARIES = libnfcbuses.la libnfcbuses_la_SOURCES = uart.c -libnfcbuses_la_CFLAGS = -I$(top_srcdir)/src/lib +libnfcbuses_la_CFLAGS = -I$(top_srcdir)/libnfc diff --git a/src/lib/buses/uart.c b/libnfc/buses/uart.c similarity index 100% rename from src/lib/buses/uart.c rename to libnfc/buses/uart.c diff --git a/src/lib/buses/uart.h b/libnfc/buses/uart.h similarity index 100% rename from src/lib/buses/uart.h rename to libnfc/buses/uart.h diff --git a/src/lib/chips.h b/libnfc/chips.h similarity index 100% rename from src/lib/chips.h rename to libnfc/chips.h diff --git a/src/lib/chips/Makefile.am b/libnfc/chips/Makefile.am similarity index 79% rename from src/lib/chips/Makefile.am rename to libnfc/chips/Makefile.am index 7bfd4da..2b8b9ee 100644 --- a/src/lib/chips/Makefile.am +++ b/libnfc/chips/Makefile.am @@ -5,5 +5,5 @@ INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) noinst_HEADERS = pn53x.h noinst_LTLIBRARIES = libnfcchips.la libnfcchips_la_SOURCES = pn53x.c -libnfcchips_la_CFLAGS = -I$(top_srcdir)/src/lib +libnfcchips_la_CFLAGS = -I$(top_srcdir)/libnfc diff --git a/src/lib/chips/pn53x.c b/libnfc/chips/pn53x.c similarity index 100% rename from src/lib/chips/pn53x.c rename to libnfc/chips/pn53x.c diff --git a/src/lib/chips/pn53x.h b/libnfc/chips/pn53x.h similarity index 100% rename from src/lib/chips/pn53x.h rename to libnfc/chips/pn53x.h diff --git a/src/lib/drivers.h b/libnfc/drivers.h similarity index 100% rename from src/lib/drivers.h rename to libnfc/drivers.h diff --git a/src/lib/drivers/Makefile.am b/libnfc/drivers/Makefile.am similarity index 89% rename from src/lib/drivers/Makefile.am rename to libnfc/drivers/Makefile.am index d29be78..d0c8b3a 100644 --- a/src/lib/drivers/Makefile.am +++ b/libnfc/drivers/Makefile.am @@ -4,7 +4,7 @@ INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) noinst_HEADERS = arygon.h pn532_uart.h noinst_LTLIBRARIES = libnfcdrivers.la libnfcdrivers_la_SOURCES = arygon.c pn532_uart.c -libnfcdrivers_la_CFLAGS = -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/buses +libnfcdrivers_la_CFLAGS = -I$(top_srcdir)/libnfc -I$(top_srcdir)/libnfc/buses libnfcdrivers_la_LIBADD = if PCSC_LITE_ENABLED diff --git a/src/lib/drivers/acr122.c b/libnfc/drivers/acr122.c similarity index 100% rename from src/lib/drivers/acr122.c rename to libnfc/drivers/acr122.c diff --git a/src/lib/drivers/acr122.h b/libnfc/drivers/acr122.h similarity index 100% rename from src/lib/drivers/acr122.h rename to libnfc/drivers/acr122.h diff --git a/src/lib/drivers/arygon.c b/libnfc/drivers/arygon.c similarity index 100% rename from src/lib/drivers/arygon.c rename to libnfc/drivers/arygon.c diff --git a/src/lib/drivers/arygon.h b/libnfc/drivers/arygon.h similarity index 100% rename from src/lib/drivers/arygon.h rename to libnfc/drivers/arygon.h diff --git a/src/lib/drivers/pn531_usb.c b/libnfc/drivers/pn531_usb.c similarity index 100% rename from src/lib/drivers/pn531_usb.c rename to libnfc/drivers/pn531_usb.c diff --git a/src/lib/drivers/pn531_usb.h b/libnfc/drivers/pn531_usb.h similarity index 100% rename from src/lib/drivers/pn531_usb.h rename to libnfc/drivers/pn531_usb.h diff --git a/src/lib/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c similarity index 100% rename from src/lib/drivers/pn532_uart.c rename to libnfc/drivers/pn532_uart.c diff --git a/src/lib/drivers/pn532_uart.h b/libnfc/drivers/pn532_uart.h similarity index 100% rename from src/lib/drivers/pn532_uart.h rename to libnfc/drivers/pn532_uart.h diff --git a/src/lib/drivers/pn533_usb.c b/libnfc/drivers/pn533_usb.c similarity index 100% rename from src/lib/drivers/pn533_usb.c rename to libnfc/drivers/pn533_usb.c diff --git a/src/lib/drivers/pn533_usb.h b/libnfc/drivers/pn533_usb.h similarity index 100% rename from src/lib/drivers/pn533_usb.h rename to libnfc/drivers/pn533_usb.h diff --git a/src/lib/drivers/pn53x_usb.c b/libnfc/drivers/pn53x_usb.c similarity index 100% rename from src/lib/drivers/pn53x_usb.c rename to libnfc/drivers/pn53x_usb.c diff --git a/src/lib/drivers/pn53x_usb.h b/libnfc/drivers/pn53x_usb.h similarity index 100% rename from src/lib/drivers/pn53x_usb.h rename to libnfc/drivers/pn53x_usb.h diff --git a/src/lib/nfc.c b/libnfc/nfc.c similarity index 100% rename from src/lib/nfc.c rename to libnfc/nfc.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 9ecb1a2..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -IF(LIBNFC_VERBOSE_OUTPUT) - ADD_DEFINITIONS("-DDEBUG") -ENDIF(LIBNFC_VERBOSE_OUTPUT) - -IF(LIBNFC_SERIAL_AUTOPROBE_ENABLED) - ADD_DEFINITIONS("-DSERIAL_AUTOPROBE_ENABLED") -ENDIF(LIBNFC_SERIAL_AUTOPROBE_ENABLED) - -IF(LIBNFC_LANG_C99 AND NOT MSVC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") -ENDIF(LIBNFC_LANG_C99 AND NOT MSVC) - -IF(MSVC) - # We should fix the code, not hide warning! - ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS") - # Include the stdint headers, because MSVC does not have them - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../win32/stdint) -ENDIF(MSVC) - -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 deleted file mode 100644 index 19f46e9..0000000 --- a/src/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -INCLUDES = $(LIBNFC_CFLAGS) - -SUBDIRS = lib examples include - -EXTRA_DIST = CMakeLists.txt - diff --git a/src/additional-pages.dox b/src/additional-pages.dox deleted file mode 100644 index d6e1f90..0000000 --- a/src/additional-pages.dox +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @mainpage libnfc reference manual - * - * @section intro_sec Introduction - * This is the developer manual for \b libnfc. - * - * @section quick_start_sec Quick start - * If you are looking for libnfc's public API, you should start with nfc.h - * Some commented examples that present how to use \b libnfc can be found here: - * @subpage examples_page - * - * @section upgrading_sec Upgrading from previous version - * If you are upgrading from a previous \b libnfc version, please take care about changes, specially API changes. - * All important changes should be listed in @subpage changelog_page. - */ - -/** - * @page examples_page Examples - * @section intro_sec Introduction - * This page present some examples to help developers which use \b libnfc. - * - * @section example_1_sec Simple tag UID reader. - * This short commented code example should be helpful to quick start development with \b libnfc, it grab the first available NFC device and print the first found ISO14443-A tag (e.g. MIFARE Classic, MIFARE Ultralight). - * @include quick_start_example1.c - */ - -/** - * @page changelog_page ChangeLog from 1.2.1 to 1.3.0 - * @verbinclude ChangeLog - */ -