Windows support contribution:
- Move CMake modules from cmake_modules/ to cmake/modules/ - CMake now use cmake/config_windows.h.cmake to create config.h on Windows platform - contrib/windows.h header is automagically included by config.h - Put missing NFC_EXPORT macro on front of emulation API - nfc-mfclassic and nfc-mfcultralight examples are now compiled under Windows Many thanks to Glenn Ergeerts which provide the initial patch.
This commit is contained in:
parent
b471f56c52
commit
5db8be908b
20 changed files with 37 additions and 31 deletions
|
@ -11,22 +11,20 @@ SET(PACKAGE_VERSION ${VERSION})
|
|||
SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
||||
|
||||
# config.h
|
||||
IF(NOT WIN32)
|
||||
IF(WIN32)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_windows.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/contrib/win32)
|
||||
ELSE(WIN32)
|
||||
SET(_XOPEN_SOURCE 600)
|
||||
ENDIF(NOT WIN32)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_posix.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
|
||||
ENDIF(WIN32)
|
||||
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
|
||||
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
# Win32
|
||||
IF(WIN32)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/contrib/win32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# make it easy to locate CMake modules for finding libraries
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
||||
|
||||
# Options
|
||||
SET(LIBNFC_DEBUG_OUTPUT OFF CACHE BOOL "Debug output of communication with the NFC chip")
|
||||
|
@ -78,9 +76,9 @@ IF(NOT WIN32)
|
|||
SET(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
SET(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
||||
SET(PACKAGE "libnfc")
|
||||
IF(LIBNFC_DRIVER_PN531_USB OR LIBNFC_DRIVER_PN533_USB)
|
||||
IF(LIBNFC_DRIVER_PN53X_USB)
|
||||
SET(PKG_REQ ${PKG_REQ} "libusb")
|
||||
ENDIF(LIBNFC_DRIVER_PN531_USB OR LIBNFC_DRIVER_PN533_USB)
|
||||
ENDIF(LIBNFC_DRIVER_PN53X_USB)
|
||||
IF(LIBNFC_DRIVER_ACR122)
|
||||
SET(PKG_REQ ${PKG_REQ} "libpcsclite")
|
||||
ENDIF(LIBNFC_DRIVER_ACR122)
|
||||
|
|
5
cmake/config_windows.h.cmake
Normal file
5
cmake/config_windows.h.cmake
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include "contrib/windows.h"
|
||||
|
||||
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
|
|
@ -14,6 +14,6 @@
|
|||
exit (code); \
|
||||
} while (0)
|
||||
|
||||
#define err(code, ...) errx(code, ...)
|
||||
#define err errx
|
||||
|
||||
#endif /* !_ERR_H_ */
|
||||
|
|
|
@ -27,11 +27,15 @@
|
|||
#define __WINDOWS_H__
|
||||
|
||||
# include <windows.h>
|
||||
# include <winerror.h>
|
||||
# include "win32/err.h"
|
||||
# if defined (__MINGW32__)
|
||||
# define snprintf(S, n, F, ...) sprintf(S, F, __VA_ARGS__)
|
||||
# define MAX(a,b) max(a,b)
|
||||
# define MIN(a,b) min(a,b)
|
||||
# define pipe(fds) _pipe(fds, 5000, _O_BINARY)
|
||||
# define ETIMEDOUT WSAETIMEDOUT
|
||||
# define ENOTSUP 134
|
||||
# else
|
||||
# define snprintf sprintf_s
|
||||
# define strdup _strdup
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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)
|
||||
#TODO nfc-mfclassic nfc-mfultralight pn53x-diagnose pn53x-sam pn53x-tamashell
|
||||
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
|
||||
|
||||
# XXX: Examples should not use private API!
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libnfc)
|
||||
|
@ -8,19 +8,19 @@ INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS})
|
|||
LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS} ${PCSC_LIBRARY_DIRS})
|
||||
|
||||
ADD_LIBRARY(nfc-utils nfc-utils)
|
||||
#ADD_LIBRARY(mifare mifare)
|
||||
|
||||
# Examples
|
||||
FOREACH(source ${EXAMPLES-SOURCES})
|
||||
ADD_EXECUTABLE(${source} ${source}.c)
|
||||
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} nfc-utils)
|
||||
INSTALL(TARGETS ${source} RUNTIME DESTINATION bin COMPONENT examples)
|
||||
ENDFOREACH(source)
|
||||
|
||||
#TARGET_LINK_LIBRARIES(nfc-mfclassic mifare)
|
||||
#TARGET_LINK_LIBRARIES(nfc-mfultralight mifare)
|
||||
|
||||
IF(NOT WIN32)
|
||||
# Manuals for the examples
|
||||
FILE(GLOB manuals "${CMAKE_CURRENT_SOURCE_DIR}/*.1")
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
#include "nfc-utils.h"
|
||||
|
||||
// TODO Move this Windows conditional code in contrib/win32/ or contrib/windows.h
|
||||
#ifndef _WIN32
|
||||
// Needed by sleep() under Unix
|
||||
# include <unistd.h>
|
||||
|
@ -59,7 +60,6 @@
|
|||
# define SUSP_TIME 1 // secs.
|
||||
#else
|
||||
// Needed by Sleep() under Windows
|
||||
# include "../contrib/windows.h"
|
||||
# include <winbase.h>
|
||||
# define sleep Sleep
|
||||
# define SUSP_TIME 1000 // msecs.
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
# define SUSP_TIME 1 // secs.
|
||||
#else
|
||||
// Needed by Sleep() under Windows
|
||||
# include "../contrib/windows.h"
|
||||
# include <winbase.h>
|
||||
# define sleep Sleep
|
||||
# define SUSP_TIME 1000 // msecs.
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define __NFC_EMULATION_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nfc/nfc.h>
|
||||
|
||||
struct nfc_emulator;
|
||||
struct nfc_emulation_state_machine;
|
||||
|
@ -37,6 +38,6 @@ struct nfc_emulation_state_machine {
|
|||
void *data;
|
||||
};
|
||||
|
||||
int nfc_emulate_target (nfc_device_t* pnd, struct nfc_emulator *emulator);
|
||||
NFC_EXPORT int nfc_emulate_target (nfc_device_t* pnd, struct nfc_emulator *emulator);
|
||||
|
||||
#endif /* __NFC_EMULATION_H__ */
|
||||
|
|
|
@ -22,6 +22,9 @@ SET(LIBRARY_SOURCES nfc nfc-device nfc-emulation iso14443-subr mirror-subr ${DRI
|
|||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
ADD_LIBRARY(nfc SHARED ${LIBRARY_SOURCES})
|
||||
TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES} ${PCSC_LIBRARIES})
|
||||
IF(WIN32)
|
||||
TARGET_LINK_LIBRARIES(nfc wsock32)
|
||||
ENDIF(WIN32)
|
||||
SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 0)
|
||||
|
||||
IF(WIN32)
|
||||
|
|
|
@ -149,7 +149,7 @@ uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, int iAbortFd)
|
|||
if (!ReadFile (((serial_port_windows *) sp)->hPort, pbtRx, dwRxLen, &dwRxLen, NULL)) {
|
||||
return DEIO;
|
||||
}
|
||||
return (dwRwLen == (DWORD) szRx) ? 0 : DEIO;
|
||||
return (dwRxLen == (DWORD) szRx) ? 0 : DEIO;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -43,10 +43,6 @@
|
|||
#include "mirror-subr.h"
|
||||
#include "nfc-internal.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# include "contrib/windows.h"
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#define CHIP_DATA(pnd) ((struct pn53x_data*)(pnd->chip_data))
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "nfc-internal.h"
|
||||
|
||||
nfc_device_t *
|
||||
|
|
|
@ -39,10 +39,6 @@
|
|||
|
||||
#include <nfc/nfc.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include "contrib/windows.h"
|
||||
#endif
|
||||
|
||||
#include "drivers.h"
|
||||
#include "nfc-internal.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue