diff --git a/CMakeLists.txt b/CMakeLists.txt index 222577b..56a8f54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,7 @@ ENDIF(NOT WIN32) ADD_SUBDIRECTORY(libnfc) ADD_SUBDIRECTORY(include) +ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(examples) # Binary Package diff --git a/Makefile.am b/Makefile.am index 43d4ab6..77d9c2f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4 AM_CFLAGS = $(LIBNFC_CFLAGS) -SUBDIRS = libnfc examples include contrib cmake test +SUBDIRS = libnfc utils examples include contrib cmake test pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libnfc.pc diff --git a/configure.ac b/configure.ac index f09e000..1c58157 100644 --- a/configure.ac +++ b/configure.ac @@ -164,11 +164,11 @@ CFLAGS="$CFLAGS -Du_int8_t=uint8_t -Du_int16_t=uint16_t" AC_CONFIG_FILES([ Doxyfile Makefile + cmake/Makefile + cmake/modules/Makefile contrib/Makefile contrib/win32/Makefile contrib/win32/sys/Makefile - cmake/Makefile - cmake/modules/Makefile examples/Makefile examples/pn53x-tamashell-scripts/Makefile include/Makefile @@ -179,6 +179,7 @@ AC_CONFIG_FILES([ libnfc/chips/Makefile libnfc/drivers/Makefile test/Makefile + utils/Makefile ]) AC_OUTPUT diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 0a63d6a..6e8863f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,23 +1,15 @@ -SET(EXAMPLES-SOURCES nfc-anticol nfc-dep-initiator nfc-dep-target nfc-emulate-forum-tag4 nfc-emulate-tag nfc-emulate-uid nfc-list nfc-poll nfc-relay nfc-relay-picc nfc-mfclassic nfc-mfultralight) -#TODO pn53x-diagnose pn53x-sam pn53x-tamashell +SET(EXAMPLES-SOURCES nfc-anticol nfc-dep-initiator nfc-dep-target nfc-emulate-tag nfc-emulate-uid nfc-poll nfc-relay pn53x-diagnose pn53x-sam pn53x-tamashell) -# 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}) -ADD_LIBRARY(nfc-utils nfc-utils) - # Examples FOREACH(source ${EXAMPLES-SOURCES}) - IF((${source} MATCHES "nfc-mfultralight") OR (${source} MATCHES "nfc-mfclassic")) - ADD_EXECUTABLE(${source} ${source}.c mifare) - ELSE() - ADD_EXECUTABLE(${source} ${source}.c) - ENDIF((${source} MATCHES "nfc-mfultralight") OR (${source} MATCHES "nfc-mfclassic")) + ADD_EXECUTABLE(${source} ${source}.c) TARGET_LINK_LIBRARIES(${source} nfc) - TARGET_LINK_LIBRARIES(${source} nfc-utils) + TARGET_LINK_LIBRARIES(${source} nfcutils) INSTALL(TARGETS ${source} RUNTIME DESTINATION bin COMPONENT examples) ENDFOREACH(source) diff --git a/examples/Makefile.am b/examples/Makefile.am index 958ebd5..61cf459 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -4,17 +4,10 @@ bin_PROGRAMS = \ nfc-anticol \ nfc-dep-initiator \ nfc-dep-target \ - nfc-emulate-forum-tag2 \ - nfc-emulate-forum-tag4 \ nfc-emulate-tag \ nfc-emulate-uid \ - nfc-list \ - nfc-mfclassic \ - nfc-mfsetuid \ - nfc-mfultralight \ nfc-poll \ nfc-relay \ - nfc-relay-picc \ pn53x-diagnose \ pn53x-sam @@ -28,93 +21,55 @@ INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) AM_CFLAGS = -I$(top_srcdir)/libnfc -noinst_HEADERS = mifare.h nfc-utils.h -noinst_LTLIBRARIES = libnfcutils.la - -libnfcutils_la_SOURCES = nfc-utils.c - nfc_poll_SOURCES = nfc-poll.c nfc_poll_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la + $(top_builddir)/utils/libnfcutils.la nfc_anticol_SOURCES = nfc-anticol.c nfc_anticol_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la - -nfc_list_SOURCES = nfc-list.c -nfc_list_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la - -nfc_mfultralight_SOURCES = nfc-mfultralight.c mifare.c mifare.h -nfc_mfultralight_LDADD = $(top_builddir)/libnfc/libnfc.la - -nfc_mfclassic_SOURCES = nfc-mfclassic.c mifare.c mifare.h -nfc_mfclassic_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la - -nfc_mfsetuid_SOURCES = nfc-mfsetuid.c -nfc_mfsetuid_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la + $(top_builddir)/utils/libnfcutils.la nfc_relay_SOURCES = nfc-relay.c nfc_relay_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la - -nfc_relay_picc_SOURCES = nfc-relay-picc.c -nfc_relay_picc_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la - -nfc_emulate_forum_tag2_SOURCES = nfc-emulate-forum-tag2.c -nfc_emulate_forum_tag2_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la - -nfc_emulate_forum_tag4_SOURCES = nfc-emulate-forum-tag4.c -nfc_emulate_forum_tag4_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la + $(top_builddir)/utils/libnfcutils.la nfc_emulate_tag_SOURCES = nfc-emulate-tag.c nfc_emulate_tag_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la + $(top_builddir)/utils/libnfcutils.la nfc_emulate_uid_SOURCES = nfc-emulate-uid.c nfc_emulate_uid_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la + $(top_builddir)/utils/libnfcutils.la nfc_dep_target_SOURCES = nfc-dep-target.c nfc_dep_target_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la + $(top_builddir)/utils/libnfcutils.la nfc_dep_initiator_SOURCES = nfc-dep-initiator.c nfc_dep_initiator_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la + $(top_builddir)/utils/libnfcutils.la pn53x_diagnose_SOURCES = pn53x-diagnose.c pn53x_diagnose_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la + $(top_builddir)/utils/libnfcutils.la pn53x_sam_SOURCES = pn53x-sam.c pn53x_sam_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la + $(top_builddir)/utils/libnfcutils.la pn53x_tamashell_SOURCES = pn53x-tamashell.c pn53x_tamashell_LDADD = $(top_builddir)/libnfc/libnfc.la \ - libnfcutils.la + $(top_builddir)/utils/libnfcutils.la pn53x_tamashell_LDFLAGS = @READLINE_LIBS@ dist_man_MANS = \ nfc-anticol.1 \ nfc-dep-initiator.1 \ nfc-dep-target.1 \ - nfc-emulate-forum-tag4.1 \ nfc-emulate-tag.1 \ nfc-emulate-uid.1 \ - nfc-list.1 \ - nfc-mfclassic.1 \ - nfc-mfsetuid.1 \ - nfc-mfultralight.1 \ nfc-poll.1 \ nfc-relay.1 \ - nfc-relay-picc.1 \ pn53x-diagnose.1 \ pn53x-sam.1 \ pn53x-tamashell.1 diff --git a/examples/nfc-anticol.c b/examples/nfc-anticol.c index 068527b..a1f906f 100644 --- a/examples/nfc-anticol.c +++ b/examples/nfc-anticol.c @@ -45,7 +45,7 @@ #include -#include "nfc-utils.h" +#include "utils/nfc-utils.h" #define SAK_FLAG_ATS_SUPPORTED 0x20 diff --git a/examples/nfc-dep-initiator.c b/examples/nfc-dep-initiator.c index c4a9bcd..db8ac9a 100644 --- a/examples/nfc-dep-initiator.c +++ b/examples/nfc-dep-initiator.c @@ -44,7 +44,7 @@ #include -#include "nfc-utils.h" +#include "utils/nfc-utils.h" #define MAX_FRAME_LEN 264 diff --git a/examples/nfc-dep-target.c b/examples/nfc-dep-target.c index c81edba..d902c56 100644 --- a/examples/nfc-dep-target.c +++ b/examples/nfc-dep-target.c @@ -43,7 +43,7 @@ #include -#include "nfc-utils.h" +#include "utils/nfc-utils.h" #define MAX_FRAME_LEN 264 diff --git a/examples/nfc-emulate-tag.c b/examples/nfc-emulate-tag.c index 4937c54..79792c8 100644 --- a/examples/nfc-emulate-tag.c +++ b/examples/nfc-emulate-tag.c @@ -49,7 +49,7 @@ #include -#include "nfc-utils.h" +#include "utils/nfc-utils.h" #define MAX_FRAME_LEN (264) #define SAK_ISO14443_4_COMPLIANT 0x20 diff --git a/examples/nfc-emulate-uid.c b/examples/nfc-emulate-uid.c index f4f285d..4548dc8 100644 --- a/examples/nfc-emulate-uid.c +++ b/examples/nfc-emulate-uid.c @@ -52,7 +52,7 @@ #include -#include "nfc-utils.h" +#include "utils/nfc-utils.h" #define MAX_FRAME_LEN 264 diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index 5727d0f..2e3f268 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -47,7 +47,7 @@ #include #include -#include "nfc-utils.h" +#include "utils/nfc-utils.h" #define MAX_DEVICE_COUNT 16 diff --git a/examples/nfc-relay.c b/examples/nfc-relay.c index e46c5df..720b094 100644 --- a/examples/nfc-relay.c +++ b/examples/nfc-relay.c @@ -45,7 +45,7 @@ #include -#include "nfc-utils.h" +#include "utils/nfc-utils.h" #define MAX_FRAME_LEN 264 #define MAX_DEVICE_COUNT 2 diff --git a/examples/pn53x-diagnose.c b/examples/pn53x-diagnose.c index 2bfbb2a..c11a236 100644 --- a/examples/pn53x-diagnose.c +++ b/examples/pn53x-diagnose.c @@ -44,8 +44,8 @@ #include -#include "nfc-utils.h" -#include "chips/pn53x.h" +#include "utils/nfc-utils.h" +#include "libnfc/chips/pn53x.h" #define MAX_DEVICE_COUNT 16 diff --git a/examples/pn53x-sam.c b/examples/pn53x-sam.c index 0b40175..ee9d664 100644 --- a/examples/pn53x-sam.c +++ b/examples/pn53x-sam.c @@ -45,8 +45,8 @@ #include -#include "nfc-utils.h" -#include "chips/pn53x.h" +#include "utils/nfc-utils.h" +#include "libnfc/chips/pn53x.h" #define MAX_FRAME_LEN 264 #define TIMEOUT 60 // secs. diff --git a/examples/pn53x-tamashell.c b/examples/pn53x-tamashell.c index fd87bbc..1d3fe94 100644 --- a/examples/pn53x-tamashell.c +++ b/examples/pn53x-tamashell.c @@ -64,9 +64,8 @@ #include -#include "nfc-utils.h" - -#include "chips/pn53x.h" +#include "utils/nfc-utils.h" +#include "libnfc/chips/pn53x.h" #define MAX_FRAME_LEN 264 diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 0000000..5107cd6 --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,36 @@ +SET(UTILS-SOURCES nfc-emulate-forum-tag2 nfc-emulate-forum-tag4 nfc-list nfc-relay-picc nfc-mfclassic nfc-mfultralight) + +# 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}) + +ADD_LIBRARY(nfcutils STATIC + nfc-utils.c +) + +# Examples +FOREACH(source ${UTILS-SOURCES}) + IF((${source} MATCHES "nfc-mfultralight") OR (${source} MATCHES "nfc-mfclassic")) + ADD_EXECUTABLE(${source} ${source}.c mifare) + ELSE() + ADD_EXECUTABLE(${source} ${source}.c) + ENDIF((${source} MATCHES "nfc-mfultralight") OR (${source} MATCHES "nfc-mfclassic")) + TARGET_LINK_LIBRARIES(${source} nfc) + TARGET_LINK_LIBRARIES(${source} nfcutils) + INSTALL(TARGETS ${source} RUNTIME DESTINATION bin COMPONENT utils) +ENDFOREACH(source) + +#install required libraries +IF(WIN32) + INCLUDE(InstallRequiredSystemLibraries) + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/FixBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake @ONLY) + INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake) +ENDIF(WIN32) + +IF(NOT WIN32) + # Manuals for the examples + FILE(GLOB manuals "${CMAKE_CURRENT_SOURCE_DIR}/*.1") + INSTALL(FILES ${manuals} DESTINATION ${SHARE_INSTALL_PREFIX}/man/man1 COMPONENT manuals) +ENDIF(NOT WIN32) diff --git a/utils/Makefile.am b/utils/Makefile.am new file mode 100644 index 0000000..49948c5 --- /dev/null +++ b/utils/Makefile.am @@ -0,0 +1,59 @@ +bin_PROGRAMS = \ + nfc-emulate-forum-tag2 \ + nfc-emulate-forum-tag4 \ + nfc-list \ + nfc-mfclassic \ + nfc-mfsetuid \ + nfc-mfultralight \ + nfc-relay-picc + +# set the include path found by configure +INCLUDES= $(all_includes) $(LIBNFC_CFLAGS) + +AM_CFLAGS = -I$(top_srcdir)/libnfc + +noinst_HEADERS = mifare.h nfc-utils.h +noinst_LTLIBRARIES = libnfcutils.la + +libnfcutils_la_SOURCES = nfc-utils.c + +nfc_emulate_forum_tag2_SOURCES = nfc-emulate-forum-tag2.c +nfc_emulate_forum_tag2_LDADD = $(top_builddir)/libnfc/libnfc.la \ + libnfcutils.la + +nfc_emulate_forum_tag4_SOURCES = nfc-emulate-forum-tag4.c +nfc_emulate_forum_tag4_LDADD = $(top_builddir)/libnfc/libnfc.la \ + libnfcutils.la + +nfc_list_SOURCES = nfc-list.c +nfc_list_LDADD = $(top_builddir)/libnfc/libnfc.la \ + libnfcutils.la + +nfc_mfultralight_SOURCES = nfc-mfultralight.c mifare.c mifare.h +nfc_mfultralight_LDADD = $(top_builddir)/libnfc/libnfc.la + +nfc_mfclassic_SOURCES = nfc-mfclassic.c mifare.c mifare.h +nfc_mfclassic_LDADD = $(top_builddir)/libnfc/libnfc.la \ + libnfcutils.la + +nfc_mfsetuid_SOURCES = nfc-mfsetuid.c +nfc_mfsetuid_LDADD = $(top_builddir)/libnfc/libnfc.la \ + libnfcutils.la + +nfc_relay_picc_SOURCES = nfc-relay-picc.c +nfc_relay_picc_LDADD = $(top_builddir)/libnfc/libnfc.la \ + libnfcutils.la + +dist_man_MANS = \ + nfc-emulate-forum-tag4.1 \ + nfc-list.1 \ + nfc-mfclassic.1 \ + nfc-mfsetuid.1 \ + nfc-mfultralight.1 + +if HAS_LOG4C + AM_CFLAGS += @log4c_CFLAGS@ + LIBADD = @log4c_LIBS@ +endif + +EXTRA_DIST = CMakeLists.txt diff --git a/examples/mifare.c b/utils/mifare.c similarity index 100% rename from examples/mifare.c rename to utils/mifare.c diff --git a/examples/mifare.h b/utils/mifare.h similarity index 100% rename from examples/mifare.h rename to utils/mifare.h diff --git a/examples/nfc-emulate-forum-tag2.c b/utils/nfc-emulate-forum-tag2.c similarity index 100% rename from examples/nfc-emulate-forum-tag2.c rename to utils/nfc-emulate-forum-tag2.c diff --git a/examples/nfc-emulate-forum-tag4.1 b/utils/nfc-emulate-forum-tag4.1 similarity index 100% rename from examples/nfc-emulate-forum-tag4.1 rename to utils/nfc-emulate-forum-tag4.1 diff --git a/examples/nfc-emulate-forum-tag4.c b/utils/nfc-emulate-forum-tag4.c similarity index 100% rename from examples/nfc-emulate-forum-tag4.c rename to utils/nfc-emulate-forum-tag4.c diff --git a/examples/nfc-list.1 b/utils/nfc-list.1 similarity index 100% rename from examples/nfc-list.1 rename to utils/nfc-list.1 diff --git a/examples/nfc-list.c b/utils/nfc-list.c similarity index 100% rename from examples/nfc-list.c rename to utils/nfc-list.c diff --git a/examples/nfc-mfclassic.1 b/utils/nfc-mfclassic.1 similarity index 100% rename from examples/nfc-mfclassic.1 rename to utils/nfc-mfclassic.1 diff --git a/examples/nfc-mfclassic.c b/utils/nfc-mfclassic.c similarity index 100% rename from examples/nfc-mfclassic.c rename to utils/nfc-mfclassic.c diff --git a/examples/nfc-mfsetuid.1 b/utils/nfc-mfsetuid.1 similarity index 100% rename from examples/nfc-mfsetuid.1 rename to utils/nfc-mfsetuid.1 diff --git a/examples/nfc-mfsetuid.c b/utils/nfc-mfsetuid.c similarity index 100% rename from examples/nfc-mfsetuid.c rename to utils/nfc-mfsetuid.c diff --git a/examples/nfc-mfultralight.1 b/utils/nfc-mfultralight.1 similarity index 100% rename from examples/nfc-mfultralight.1 rename to utils/nfc-mfultralight.1 diff --git a/examples/nfc-mfultralight.c b/utils/nfc-mfultralight.c similarity index 100% rename from examples/nfc-mfultralight.c rename to utils/nfc-mfultralight.c diff --git a/examples/nfc-relay-picc.1 b/utils/nfc-relay-picc.1 similarity index 100% rename from examples/nfc-relay-picc.1 rename to utils/nfc-relay-picc.1 diff --git a/examples/nfc-relay-picc.c b/utils/nfc-relay-picc.c similarity index 100% rename from examples/nfc-relay-picc.c rename to utils/nfc-relay-picc.c diff --git a/examples/nfc-utils.c b/utils/nfc-utils.c similarity index 100% rename from examples/nfc-utils.c rename to utils/nfc-utils.c diff --git a/examples/nfc-utils.h b/utils/nfc-utils.h similarity index 100% rename from examples/nfc-utils.h rename to utils/nfc-utils.h