forked from nfc-tools/ifdnfc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
156 lines (136 loc) · 4.63 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.68])
AC_INIT([ifdnfc],[0.1.4],[http://sourceforge.net/projects/ifdnfc/support])
AC_CONFIG_SRCDIR([src/ifd-nfc.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
LT_INIT
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
# Checks for programs.
AC_PROG_CXX
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AM_PROG_CC_C_O
PKG_PROG_PKG_CONFIG
# Checks for libraries.
PKG_CHECK_EXISTS([libnfc >= 1.6.0],
[PKG_CHECK_MODULES([LIBNFC], [libnfc >= 1.6.0])],
[AC_MSG_WARN([libnfc >= 1.6.0 not found by pkg-config])])
PKG_CHECK_EXISTS([libpcsclite > 1.4.102],
[PKG_CHECK_MODULES([PCSC], [libpcsclite > 1.4.102])],
[AC_MSG_WARN([libpcsclite > 1.4.102 not found by pkg-config])
case "$host" in
*-*-darwin*)
SDKS_PATH="$(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs"
SDK_PATH="${SDK_PATH:-$SDKS_PATH/$(ls -1 ${SDKS_PATH} | sort -n -t. -k2 -r | head -1)}"
# and set the PC/SC include path
PCSC_CFLAGS="-I$SDK_PATH/System/Library/Frameworks/PCSC.framework/Versions/Current/Headers -DRESPONSECODE_DEFINED_IN_WINTYPES_H -I`pwd`/${top_srcdir}/MacOSX"
PCSC_LIBS="-framework PCSC"
esac
])
saved_CPPFLAGS="$CPPFLAGS"
saved_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $PCSC_CFLAGS $LIBNFC_CFLAGS"
LIBS="$LDFLAGS $PCSC_LIBS $LIBNFC_LIBS"
AC_CHECK_HEADERS(winscard.h,,
[ AC_MSG_ERROR([winscard.h not found, install libpcsclite > 1.4.102 or use ./configure PCSC_CFLAGS=...]) ])
AC_CHECK_HEADERS([debuglog.h syslog.h ifdhandler.h])
AC_CHECK_DECLS([TAG_IFD_POLLING_THREAD_WITH_TIMEOUT], [], [], [#include <ifdhandler..h>])
AC_CHECK_DECLS([TAG_IFD_STOP_POLLING_THREAD], [], [], [#include <ifdhandler..h>])
AC_MSG_CHECKING([for SCardEstablishContext])
AC_TRY_LINK_FUNC(SCardEstablishContext, [ AC_MSG_RESULT([yes]) ],
[ AC_MSG_ERROR([libpcsclite > 1.4.102 not found, use ./configure PCSC_LIBS=...]) ])
AC_CHECK_HEADERS(nfc/nfc.h,,
[ AC_MSG_ERROR([nfc/nfc.h not found, install libnfc >= 1.6.0 or use ./configure LIBNFC_CFLAGS=...]) ])
AC_MSG_CHECKING([for nfc_initiator_select_passive_target])
AC_TRY_LINK_FUNC(nfc_initiator_select_passive_target, [ AC_MSG_RESULT([yes]) ],
[ AC_MSG_ERROR([libnfc >= 1.6.0 not found, use ./configure LIBNFC_LIBS=...]) ])
CPPFLAGS="$saved_CPPFLAGS"
LIBS="$saved_LIBS"
# --enable-usbdropdir=DIR
AC_ARG_ENABLE(usbdropdir,
AS_HELP_STRING([--enable-usbdropdir=DIR],[directory containing USB
drivers (default to pcscd config or $(prefix)/pcsc/drivers)]),
[usbdropdir="${enableval}"], [usbdropdir=false])
if test "${usbdropdir}" = false ; then
usbdropdir=`$PKG_CONFIG libpcsclite --variable=usbdropdir`
fi
AC_DEFINE_UNQUOTED(PCSCLITE_HP_DROPDIR, "$usbdropdir", [directory containing USB drivers])
if test "${usbdropdir}" = "" ; then
case "$host" in
*-*-darwin*)
MAC_VERSION=$(sw_vers -productVersion | awk -F '.' '{print $1 * 1000 + $2}')
if [ 10011 -gt $MAC_VERSION ]; then
usbdropdir=/usr/local/libexec/SmartCardServices/drivers;
else
usbdropdir=/usr/libexec/SmartCardServices/drivers;
fi
;;
*) AC_MSG_ERROR([use --enable-usbdropdir=DIR])
esac
fi
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
# Checks for library functions.
AC_CHECK_FUNCS([memset])
# Select OS specific versions of source files.
AC_SUBST(BUNDLE_HOST)
AC_SUBST(DYN_LIB_EXT)
AC_SUBST(usbdropdir)
case "$host" in
*-*-darwin*)
BUNDLE_HOST="MacOS"
DYN_LIB_EXT="dylib"
;;
*-*-freebsd*)
BUNDLE_HOST="FreeBSD"
DYN_LIB_EXT="so"
;;
*-*-openbsd*)
BUNDLE_HOST="OpenBSD"
DYN_LIB_EXT="so.0.0"
;;
*-*-solaris*)
BUNDLE_HOST="Solaris"
DYN_LIB_EXT="so"
;;
*-*-dragonfly*)
BUNDLE_HOST="DragonFly"
DYN_LIB_EXT="so"
;;
*)
BUNDLE_HOST="Linux"
DYN_LIB_EXT="so"
esac
CFLAGS="$CFLAGS -std=c99"
cat << EOF
${PACKAGE} has been configured with following options:
Version: ${PACKAGE_VERSION}
Host: ${host}
Compiler: ${CC}
Preprocessor flags: ${CPPFLAGS}
Compiler flags: ${CFLAGS}
Preprocessor flags: ${CPPFLAGS}
Linker flags: ${LDFLAGS}
Libraries: ${LIBS}
LIBNFC_CFLAGS: ${LIBNFC_CFLAGS}
LIBNFC_LIBS: ${LIBNFC_LIBS}
PCSC_CFLAGS: ${PCSC_CFLAGS}
PCSC_LIBS: ${PCSC_LIBS}
BUNDLE_HOST: ${BUNDLE_HOST}
DYN_LIB_EXT: ${DYN_LIB_EXT}
EOF
AC_CONFIG_FILES([Makefile
src/Info.plist
src/Makefile])
AC_OUTPUT