mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-02-18 02:55:49 +00:00
fixed windows compilation with autotools
This commit is contained in:
parent
fd76395b81
commit
9a78e96e79
11
configure.ac
11
configure.ac
@ -22,6 +22,7 @@ AC_LANG([C])
|
|||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_MAKE_SET
|
AC_PROG_MAKE_SET
|
||||||
|
|
||||||
|
WIN32=0
|
||||||
WITH_POSIX_ONLY_EXAMPLES=1
|
WITH_POSIX_ONLY_EXAMPLES=1
|
||||||
# Libtool
|
# Libtool
|
||||||
LT_INIT
|
LT_INIT
|
||||||
@ -35,8 +36,10 @@ case "$host" in
|
|||||||
AC_MSG_RESULT([Disable extended examples due to target Windows system.])
|
AC_MSG_RESULT([Disable extended examples due to target Windows system.])
|
||||||
# Undefine __STRICT_ANSI__ to allow to use strdup, putenv, etc. without warnings
|
# Undefine __STRICT_ANSI__ to allow to use strdup, putenv, etc. without warnings
|
||||||
CFLAGS="$CFLAGS -U__STRICT_ANSI__"
|
CFLAGS="$CFLAGS -U__STRICT_ANSI__"
|
||||||
|
WIN32=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
AM_CONDITIONAL(WIN32, [test "$WIN32" = "1"])
|
||||||
AM_CONDITIONAL(POSIX_ONLY_EXAMPLES_ENABLED, [test "$WITH_POSIX_ONLY_EXAMPLES" = "1"])
|
AM_CONDITIONAL(POSIX_ONLY_EXAMPLES_ENABLED, [test "$WITH_POSIX_ONLY_EXAMPLES" = "1"])
|
||||||
|
|
||||||
AC_PATH_PROG(PKG_CONFIG, pkg-config)
|
AC_PATH_PROG(PKG_CONFIG, pkg-config)
|
||||||
@ -68,6 +71,14 @@ AC_TYPE_INT16_T
|
|||||||
AC_TYPE_INT32_T
|
AC_TYPE_INT32_T
|
||||||
AC_TYPE_OFF_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'
|
LIBNFC_CFLAGS='-I$(top_srcdir)/libnfc -I$(top_builddir)/include -I$(top_srcdir)/include'
|
||||||
AC_SUBST(LIBNFC_CFLAGS)
|
AC_SUBST(LIBNFC_CFLAGS)
|
||||||
|
|
||||||
|
|||||||
@ -28,61 +28,61 @@ AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS)
|
|||||||
AM_CFLAGS = -I$(top_srcdir)/libnfc -I$(top_srcdir)
|
AM_CFLAGS = -I$(top_srcdir)/libnfc -I$(top_srcdir)
|
||||||
|
|
||||||
nfc_poll_SOURCES = nfc-poll.c
|
nfc_poll_SOURCES = nfc-poll.c
|
||||||
nfc_poll_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_poll_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_anticol_SOURCES = nfc-anticol.c
|
nfc_anticol_SOURCES = nfc-anticol.c
|
||||||
nfc_anticol_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_anticol_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_relay_SOURCES = nfc-relay.c
|
nfc_relay_SOURCES = nfc-relay.c
|
||||||
nfc_relay_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_relay_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_emulate_forum_tag2_SOURCES = nfc-emulate-forum-tag2.c
|
nfc_emulate_forum_tag2_SOURCES = nfc-emulate-forum-tag2.c
|
||||||
nfc_emulate_forum_tag2_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_emulate_forum_tag2_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_emulate_tag_SOURCES = nfc-emulate-tag.c
|
nfc_emulate_tag_SOURCES = nfc-emulate-tag.c
|
||||||
nfc_emulate_tag_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_emulate_tag_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_emulate_uid_SOURCES = nfc-emulate-uid.c
|
nfc_emulate_uid_SOURCES = nfc-emulate-uid.c
|
||||||
nfc_emulate_uid_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_emulate_uid_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_dep_target_SOURCES = nfc-dep-target.c
|
nfc_dep_target_SOURCES = nfc-dep-target.c
|
||||||
nfc_dep_target_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_dep_target_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_dep_initiator_SOURCES = nfc-dep-initiator.c
|
nfc_dep_initiator_SOURCES = nfc-dep-initiator.c
|
||||||
nfc_dep_initiator_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_dep_initiator_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_mfsetuid_SOURCES = nfc-mfsetuid.c
|
nfc_mfsetuid_SOURCES = nfc-mfsetuid.c
|
||||||
nfc_mfsetuid_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_mfsetuid_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
pn53x_diagnose_SOURCES = pn53x-diagnose.c
|
pn53x_diagnose_SOURCES = pn53x-diagnose.c
|
||||||
pn53x_diagnose_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
pn53x_diagnose_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
pn53x_sam_SOURCES = pn53x-sam.c
|
pn53x_sam_SOURCES = pn53x-sam.c
|
||||||
pn53x_sam_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
pn53x_sam_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
pn53x_tamashell_SOURCES = pn53x-tamashell.c
|
pn53x_tamashell_SOURCES = pn53x-tamashell.c
|
||||||
pn53x_tamashell_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
pn53x_tamashell_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
pn53x_tamashell_LDFLAGS = @READLINE_LIBS@
|
pn53x_tamashell_LDFLAGS = @READLINE_LIBS@
|
||||||
|
|
||||||
quick_start_example1_SOURCES = doc/quick_start_example1.c
|
quick_start_example1_SOURCES = doc/quick_start_example1.c
|
||||||
quick_start_example1_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
quick_start_example1_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
quick_start_example2_SOURCES = doc/quick_start_example2.c
|
quick_start_example2_SOURCES = doc/quick_start_example2.c
|
||||||
quick_start_example2_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
quick_start_example2_LDADD = $(top_builddir)/utils/libnfcutils.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
|
|
||||||
dist_man_MANS = \
|
dist_man_MANS = \
|
||||||
|
|||||||
@ -29,6 +29,10 @@ libnfc_la_LIBADD = \
|
|||||||
$(top_builddir)/libnfc/buses/libnfcbuses.la \
|
$(top_builddir)/libnfc/buses/libnfcbuses.la \
|
||||||
$(top_builddir)/libnfc/drivers/libnfcdrivers.la
|
$(top_builddir)/libnfc/drivers/libnfcdrivers.la
|
||||||
|
|
||||||
|
if WIN32
|
||||||
|
libnfc_la_SOURCES += stdlib-win32.c
|
||||||
|
endif
|
||||||
|
|
||||||
if PCSC_ENABLED
|
if PCSC_ENABLED
|
||||||
libnfc_la_CFLAGS += @libpcsclite_CFLAGS@ -DHAVE_PCSC
|
libnfc_la_CFLAGS += @libpcsclite_CFLAGS@ -DHAVE_PCSC
|
||||||
libnfc_la_LIBADD += @libpcsclite_LIBS@
|
libnfc_la_LIBADD += @libpcsclite_LIBS@
|
||||||
@ -40,7 +44,12 @@ if LIBUSB_ENABLED
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if WITH_LOG
|
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
|
endif
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
|
|||||||
@ -16,11 +16,16 @@ endif
|
|||||||
EXTRA_DIST += spi.c spi.h
|
EXTRA_DIST += spi.c spi.h
|
||||||
|
|
||||||
if UART_ENABLED
|
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_CFLAGS +=
|
||||||
libnfcbuses_la_LIBADD +=
|
libnfcbuses_la_LIBADD +=
|
||||||
endif
|
endif
|
||||||
EXTRA_DIST += uart.c uart.h
|
EXTRA_DIST += uart.c uart.h uart-win32.c
|
||||||
|
|
||||||
if LIBUSB_ENABLED
|
if LIBUSB_ENABLED
|
||||||
libnfcbuses_la_SOURCES += usbbus.c usbbus.h
|
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
|
||||||
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
|
# Stop compilation on first error
|
||||||
export CFLAGS="-Wfatal-errors"
|
export CFLAGS="-Wfatal-errors"
|
||||||
|
|
||||||
# Include default MinGW include directory, and libnfc's win32 files
|
# Include default MinGW include directory
|
||||||
export CFLAGS="$CFLAGS -I$MINGW_DIR/include -I$PWD/contrib/win32"
|
export CFLAGS="$CFLAGS -I$MINGW_DIR/include"
|
||||||
|
|
||||||
if [ "$MINGW" = "i686-w64-mingw32" ]; then
|
if [ "$MINGW" = "i686-w64-mingw32" ]; then
|
||||||
# mingw-64 includes winscard.a and winscard.h
|
# 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
|
# 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
|
# forgotten when libnfc is created with libtool. That's why we are setting
|
||||||
# LIBS.
|
# LIBS.
|
||||||
export LIBS="-lwinscard"
|
if echo -n "$*" | grep acr122_pcsc 2>&1 > /dev/null; then
|
||||||
|
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..."
|
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
if [ ! -x configure ]; then
|
if [ ! -x configure ]; then
|
||||||
@ -80,12 +50,6 @@ if [ ! -x configure ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
./configure --target=$MINGW --host=$MINGW \
|
./configure --target=$MINGW --host=$MINGW \
|
||||||
--with-drivers=$DRIVERS \
|
--disable-conffiles --disable-log \
|
||||||
--with-libusb-win32=$PWD/$LIBUSB_WIN32_BIN_DIR \
|
--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
|
libnfcutils_la_SOURCES = nfc-utils.c
|
||||||
|
|
||||||
nfc_emulate_forum_tag4_SOURCES = nfc-emulate-forum-tag4.c nfc-utils.h
|
nfc_emulate_forum_tag4_SOURCES = nfc-emulate-forum-tag4.c nfc-utils.h
|
||||||
nfc_emulate_forum_tag4_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_emulate_forum_tag4_LDADD = libnfcutils.la \
|
||||||
libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_list_SOURCES = nfc-list.c nfc-utils.h
|
nfc_list_SOURCES = nfc-list.c nfc-utils.h
|
||||||
nfc_list_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_list_LDADD = libnfcutils.la \
|
||||||
libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_mfclassic_SOURCES = nfc-mfclassic.c mifare.c mifare.h nfc-utils.h
|
nfc_mfclassic_SOURCES = nfc-mfclassic.c mifare.c mifare.h nfc-utils.h
|
||||||
nfc_mfclassic_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_mfclassic_LDADD = libnfcutils.la \
|
||||||
libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_mfultralight_SOURCES = nfc-mfultralight.c mifare.c mifare.h nfc-utils.h
|
nfc_mfultralight_SOURCES = nfc-mfultralight.c mifare.c mifare.h nfc-utils.h
|
||||||
nfc_mfultralight_LDADD = $(top_builddir)/libnfc/libnfc.la
|
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_SOURCES = nfc-read-forum-tag3.c nfc-utils.h
|
||||||
nfc_read_forum_tag3_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_read_forum_tag3_LDADD = libnfcutils.la \
|
||||||
libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_relay_picc_SOURCES = nfc-relay-picc.c nfc-utils.h
|
nfc_relay_picc_SOURCES = nfc-relay-picc.c nfc-utils.h
|
||||||
nfc_relay_picc_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_relay_picc_LDADD = libnfcutils.la \
|
||||||
libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
nfc_scan_device_SOURCES = nfc-scan-device.c nfc-utils.h
|
nfc_scan_device_SOURCES = nfc-scan-device.c nfc-utils.h
|
||||||
nfc_scan_device_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_scan_device_LDADD = libnfcutils.la \
|
||||||
libnfcutils.la
|
$(top_builddir)/libnfc/libnfc.la
|
||||||
|
|
||||||
|
if WIN32
|
||||||
|
nfc_scan_device_SOURCES += stdlib-win32.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
dist_man_MANS = \
|
dist_man_MANS = \
|
||||||
nfc-emulate-forum-tag4.1 \
|
nfc-emulate-forum-tag4.1 \
|
||||||
|
|||||||
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