mirror of
https://github.com/nfc-tools/libnfc.git
synced 2025-12-23 18:50:05 +00:00
Merge remote-tracking branch 'frank/master'
* frank/master: distributing mingw-cross-configure.sh fixed windows compilation with autotools fixed missing error codes for windows fixd compiler warnings fixed recognition of windows environment
This commit is contained in:
commit
a5a03fae13
@ -11,7 +11,8 @@ EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
Doxyfile \
|
||||
README-Windows.txt \
|
||||
libnfc.conf.sample
|
||||
libnfc.conf.sample \
|
||||
mingw-cross-configure.sh
|
||||
|
||||
CLEANFILES = Doxygen.log coverage.info libnfc.pc
|
||||
|
||||
|
||||
13
configure.ac
13
configure.ac
@ -22,6 +22,7 @@ AC_LANG([C])
|
||||
AC_PROG_CC
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
WIN32=0
|
||||
WITH_POSIX_ONLY_EXAMPLES=1
|
||||
# Libtool
|
||||
LT_INIT
|
||||
@ -30,13 +31,15 @@ case "$host" in
|
||||
AC_MSG_RESULT([Fixing libtool for -rpath problems.])
|
||||
sed -i -r 's/(hardcode_into_libs)=.*$/\1=no/' libtool
|
||||
;;
|
||||
*-pc-mingw32msvc)
|
||||
*-mingw32*)
|
||||
WITH_POSIX_ONLY_EXAMPLES=0
|
||||
AC_MSG_RESULT([Disable extended examples due to target Windows system.])
|
||||
# Undefine __STRICT_ANSI__ to allow to use strdup, putenv, etc. without warnings
|
||||
CFLAGS="$CFLAGS -U__STRICT_ANSI__"
|
||||
WIN32=1
|
||||
;;
|
||||
esac
|
||||
AM_CONDITIONAL(WIN32, [test "$WIN32" = "1"])
|
||||
AM_CONDITIONAL(POSIX_ONLY_EXAMPLES_ENABLED, [test "$WITH_POSIX_ONLY_EXAMPLES" = "1"])
|
||||
|
||||
PKG_PROG_PKG_CONFIG
|
||||
@ -66,6 +69,14 @@ AC_TYPE_INT16_T
|
||||
AC_TYPE_INT32_T
|
||||
AC_TYPE_OFF_T
|
||||
|
||||
if test "$WIN32" = "1"
|
||||
then
|
||||
CFLAGS="$CFLAGS -I`pwd` -I`pwd`/contrib/win32"
|
||||
# act as if we were cmake
|
||||
CFLAGS="$CFLAGS -D_WINDLL"
|
||||
# libtool generated source files seem not to be mingw-aware, so add _MSC_VER
|
||||
CFLAGS="$CFLAGS -D_MSC_VER"
|
||||
fi
|
||||
LIBNFC_CFLAGS='-I$(top_srcdir)/libnfc -I$(top_builddir)/include -I$(top_srcdir)/include'
|
||||
AC_SUBST(LIBNFC_CFLAGS)
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@ uart_receive(serial_port sp, uint8_t *pbtRx, const size_t szRx, void *abort_p, i
|
||||
timeouts.WriteTotalTimeoutConstant = timeout_ms;
|
||||
|
||||
if (!SetCommTimeouts(((struct serial_port_windows *) sp)->hPort, &timeouts)) {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to apply new timeout settings.");
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Unable to apply new timeout settings.");
|
||||
return NFC_EIO;
|
||||
}
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Timeouts are set to %lu ms", timeout_ms);
|
||||
@ -185,7 +185,7 @@ uart_receive(serial_port sp, uint8_t *pbtRx, const size_t szRx, void *abort_p, i
|
||||
// - According to MSDN, it could be better to implement nfc_abort_command() mecanism using Cancello()
|
||||
volatile bool *abort_flag_p = (volatile bool *)abort_p;
|
||||
do {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "ReadFile");
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "ReadFile");
|
||||
res = ReadFile(((struct serial_port_windows *) sp)->hPort, pbtRx + dwTotalBytesReceived,
|
||||
dwBytesToGet,
|
||||
&dwBytesReceived, NULL);
|
||||
@ -226,7 +226,7 @@ uart_send(serial_port sp, const uint8_t *pbtTx, const size_t szTx, int timeout)
|
||||
timeouts.WriteTotalTimeoutConstant = timeout;
|
||||
|
||||
if (!SetCommTimeouts(((struct serial_port_windows *) sp)->hPort, &timeouts)) {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to apply new timeout settings.");
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Unable to apply new timeout settings.");
|
||||
return NFC_EIO;
|
||||
}
|
||||
|
||||
|
||||
@ -28,61 +28,61 @@ AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS)
|
||||
AM_CFLAGS = -I$(top_srcdir)/libnfc -I$(top_srcdir)
|
||||
|
||||
nfc_poll_SOURCES = nfc-poll.c
|
||||
nfc_poll_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
nfc_poll_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_anticol_SOURCES = nfc-anticol.c
|
||||
nfc_anticol_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
nfc_anticol_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_relay_SOURCES = nfc-relay.c
|
||||
nfc_relay_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
nfc_relay_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_emulate_forum_tag2_SOURCES = nfc-emulate-forum-tag2.c
|
||||
nfc_emulate_forum_tag2_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
nfc_emulate_forum_tag2_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_emulate_tag_SOURCES = nfc-emulate-tag.c
|
||||
nfc_emulate_tag_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
nfc_emulate_tag_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_emulate_uid_SOURCES = nfc-emulate-uid.c
|
||||
nfc_emulate_uid_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
nfc_emulate_uid_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_dep_target_SOURCES = nfc-dep-target.c
|
||||
nfc_dep_target_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
nfc_dep_target_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_dep_initiator_SOURCES = nfc-dep-initiator.c
|
||||
nfc_dep_initiator_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
nfc_dep_initiator_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_mfsetuid_SOURCES = nfc-mfsetuid.c
|
||||
nfc_mfsetuid_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
nfc_mfsetuid_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
pn53x_diagnose_SOURCES = pn53x-diagnose.c
|
||||
pn53x_diagnose_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
pn53x_diagnose_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
pn53x_sam_SOURCES = pn53x-sam.c
|
||||
pn53x_sam_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
pn53x_sam_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
pn53x_tamashell_SOURCES = pn53x-tamashell.c
|
||||
pn53x_tamashell_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
pn53x_tamashell_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
pn53x_tamashell_LDFLAGS = @READLINE_LIBS@
|
||||
|
||||
quick_start_example1_SOURCES = doc/quick_start_example1.c
|
||||
quick_start_example1_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
quick_start_example1_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
quick_start_example2_SOURCES = doc/quick_start_example2.c
|
||||
quick_start_example2_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
$(top_builddir)/utils/libnfcutils.la
|
||||
quick_start_example2_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
|
||||
dist_man_MANS = \
|
||||
|
||||
@ -70,6 +70,11 @@
|
||||
# include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#ifdef _WIN32
|
||||
// ECONNABORTED
|
||||
# include "contrib/windows.h"
|
||||
#endif // _WIN32
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -29,6 +29,10 @@ libnfc_la_LIBADD = \
|
||||
$(top_builddir)/libnfc/buses/libnfcbuses.la \
|
||||
$(top_builddir)/libnfc/drivers/libnfcdrivers.la
|
||||
|
||||
if WIN32
|
||||
libnfc_la_SOURCES += stdlib-win32.c
|
||||
endif
|
||||
|
||||
if PCSC_ENABLED
|
||||
libnfc_la_CFLAGS += @libpcsclite_CFLAGS@ -DHAVE_PCSC
|
||||
libnfc_la_LIBADD += @libpcsclite_LIBS@
|
||||
@ -40,7 +44,12 @@ if LIBUSB_ENABLED
|
||||
endif
|
||||
|
||||
if WITH_LOG
|
||||
libnfc_la_SOURCES += log.c log-internal.c
|
||||
libnfc_la_SOURCES += log.c
|
||||
if WIN32
|
||||
libnfc_la_SOURCES += log-internal-win32.c
|
||||
else
|
||||
libnfc_la_SOURCES += log-internal.c
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
|
||||
@ -16,11 +16,16 @@ endif
|
||||
EXTRA_DIST += spi.c spi.h
|
||||
|
||||
if UART_ENABLED
|
||||
libnfcbuses_la_SOURCES += uart.c uart.h
|
||||
if WIN32
|
||||
libnfcbuses_la_SOURCES += uart-win32.c
|
||||
else
|
||||
libnfcbuses_la_SOURCES += uart.c
|
||||
endif
|
||||
libnfcbuses_la_SOURCES += uart.h
|
||||
libnfcbuses_la_CFLAGS +=
|
||||
libnfcbuses_la_LIBADD +=
|
||||
endif
|
||||
EXTRA_DIST += uart.c uart.h
|
||||
EXTRA_DIST += uart.c uart.h uart-win32.c
|
||||
|
||||
if LIBUSB_ENABLED
|
||||
libnfcbuses_la_SOURCES += usbbus.c usbbus.h
|
||||
|
||||
1
libnfc/buses/uart-win32.c
Symbolic link
1
libnfc/buses/uart-win32.c
Symbolic link
@ -0,0 +1 @@
|
||||
../../contrib/win32/libnfc/buses/uart.c
|
||||
@ -198,11 +198,12 @@ acr122s_send_frame(nfc_device *pnd, uint8_t *frame, int timeout)
|
||||
uint8_t positive_ack[4] = { STX, 0, 0, ETX };
|
||||
serial_port port = DRIVER_DATA(pnd)->port;
|
||||
int ret;
|
||||
void *abort_p;
|
||||
|
||||
#ifndef WIN32
|
||||
void *abort_p;
|
||||
abort_p = &(DRIVER_DATA(pnd)->abort_fds[1]);
|
||||
#else
|
||||
volatile void *abort_p;
|
||||
abort_p = &(DRIVER_DATA(pnd)->abort_flag);
|
||||
#endif
|
||||
|
||||
|
||||
1
libnfc/log-internal-win32.c
Symbolic link
1
libnfc/log-internal-win32.c
Symbolic link
@ -0,0 +1 @@
|
||||
../contrib/win32/libnfc/log-internal.c
|
||||
1
libnfc/stdlib-win32.c
Symbolic link
1
libnfc/stdlib-win32.c
Symbolic link
@ -0,0 +1 @@
|
||||
../contrib/win32/stdlib.c
|
||||
46
mingw-cross-configure.sh
Normal file → Executable file
46
mingw-cross-configure.sh
Normal file → Executable file
@ -31,8 +31,8 @@ export PKG_CONFIG_LIBDIR=$MINGW_DIR/lib/pkgconfig
|
||||
# Stop compilation on first error
|
||||
export CFLAGS="-Wfatal-errors"
|
||||
|
||||
# Include default MinGW include directory, and libnfc's win32 files
|
||||
export CFLAGS="$CFLAGS -I$MINGW_DIR/include -I$PWD/contrib/win32"
|
||||
# Include default MinGW include directory
|
||||
export CFLAGS="$CFLAGS -I$MINGW_DIR/include"
|
||||
|
||||
if [ "$MINGW" = "i686-w64-mingw32" ]; then
|
||||
# mingw-64 includes winscard.a and winscard.h
|
||||
@ -40,39 +40,9 @@ if [ "$MINGW" = "i686-w64-mingw32" ]; then
|
||||
# It is not enough to set libpcsclite_LIBS to "-lwinscard", because it is
|
||||
# forgotten when libnfc is created with libtool. That's why we are setting
|
||||
# LIBS.
|
||||
export LIBS="-lwinscard"
|
||||
|
||||
echo "MinGW-w64 ships all requirements libnfc."
|
||||
echo "Unfortunately the MinGW-w64 header are currently"
|
||||
echo "buggy. Also, Libtool doesn't support MinGW-w64"
|
||||
echo "very well."
|
||||
echo ""
|
||||
echo "Warning ________________________________________"
|
||||
echo "You will only be able to compile libnfc.dll, but"
|
||||
echo "none of the executables (see utils and examples)."
|
||||
echo ""
|
||||
# You can fix winbase.h by adding the following lines:
|
||||
# #include <basetsd.h>
|
||||
# #include <windef.h>
|
||||
# But the problem with Libtool remains.
|
||||
else
|
||||
if [ -z "$libpcsclite_LIBS$libpcsclite_CFLAGS" ]; then
|
||||
echo "Error __________________________________________"
|
||||
echo "You need to get the PC/SC library from a Windows"
|
||||
echo "machine and the appropriate header files. Then"
|
||||
echo "specify libpcsclite_LIBS=.../WinScard.dll and"
|
||||
echo "libpcsclite_CFLAGS=-I..."
|
||||
if echo -n "$*" | grep acr122_pcsc 2>&1 > /dev/null; then
|
||||
export LIBS="-lwinscard"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Configure to cross-compile using mingw32msvc
|
||||
if [ "$WITH_USB" = "1" ]; then
|
||||
# with direct-USB drivers (use libusb-win32)
|
||||
DRIVERS="all"
|
||||
else
|
||||
# with UART divers only (can be tested under wine)
|
||||
DRIVERS="pn532_uart,arygon"
|
||||
fi
|
||||
|
||||
if [ ! -x configure ]; then
|
||||
@ -80,12 +50,6 @@ if [ ! -x configure ]; then
|
||||
fi
|
||||
|
||||
./configure --target=$MINGW --host=$MINGW \
|
||||
--with-drivers=$DRIVERS \
|
||||
--disable-conffiles --disable-log \
|
||||
--with-libusb-win32=$PWD/$LIBUSB_WIN32_BIN_DIR \
|
||||
$*
|
||||
|
||||
if [ "$MINGW" = "i686-w64-mingw32" ]; then
|
||||
# due to the buggy headers from MINGW-64 we always add "contrib/windows.h",
|
||||
# otherwise some windows types won't be available.
|
||||
echo "#include \"contrib/windows.h\"" >> config.h
|
||||
fi
|
||||
|
||||
@ -15,31 +15,36 @@ noinst_LTLIBRARIES = libnfcutils.la
|
||||
libnfcutils_la_SOURCES = nfc-utils.c
|
||||
|
||||
nfc_emulate_forum_tag4_SOURCES = nfc-emulate-forum-tag4.c nfc-utils.h
|
||||
nfc_emulate_forum_tag4_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
libnfcutils.la
|
||||
nfc_emulate_forum_tag4_LDADD = libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_list_SOURCES = nfc-list.c nfc-utils.h
|
||||
nfc_list_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
libnfcutils.la
|
||||
nfc_list_LDADD = libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_mfclassic_SOURCES = nfc-mfclassic.c mifare.c mifare.h nfc-utils.h
|
||||
nfc_mfclassic_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
libnfcutils.la
|
||||
nfc_mfclassic_LDADD = libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_mfultralight_SOURCES = nfc-mfultralight.c mifare.c mifare.h nfc-utils.h
|
||||
nfc_mfultralight_LDADD = $(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_read_forum_tag3_SOURCES = nfc-read-forum-tag3.c nfc-utils.h
|
||||
nfc_read_forum_tag3_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
libnfcutils.la
|
||||
nfc_read_forum_tag3_LDADD = libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_relay_picc_SOURCES = nfc-relay-picc.c nfc-utils.h
|
||||
nfc_relay_picc_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
libnfcutils.la
|
||||
nfc_relay_picc_LDADD = libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
nfc_scan_device_SOURCES = nfc-scan-device.c nfc-utils.h
|
||||
nfc_scan_device_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||
libnfcutils.la
|
||||
nfc_scan_device_LDADD = libnfcutils.la \
|
||||
$(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
if WIN32
|
||||
nfc_scan_device_SOURCES += stdlib-win32.c
|
||||
endif
|
||||
|
||||
|
||||
dist_man_MANS = \
|
||||
nfc-emulate-forum-tag4.1 \
|
||||
|
||||
@ -58,6 +58,11 @@
|
||||
# include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#ifdef _WIN32
|
||||
// ENOTSUP
|
||||
# include "contrib/windows.h"
|
||||
#endif // _WIN32
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
1
utils/stdlib-win32.c
Symbolic link
1
utils/stdlib-win32.c
Symbolic link
@ -0,0 +1 @@
|
||||
../contrib/win32/stdlib.c
|
||||
Loading…
x
Reference in New Issue
Block a user