forked from KristianMika/vsmartcard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
196 lines (163 loc) · 5.88 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65])
AC_INIT([PC/SC Relay], [0.5], [https://github.com/frankmorgner/vsmartcard/issues], [pcsc-relay], [http://frankmorgner.github.io/vsmartcard/pcsc-relay/README.html])
AC_CONFIG_SRCDIR([src/pcsc-relay.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE(foreign)
dnl Check for windows build
case "${host}" in
*-mingw*|*-winnt*)
WIN32="yes"
;;
*-cygwin*)
WIN32="yes"
;;
esac
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AM_PATH_PYTHON
AC_PROG_SED
PKG_PROG_PKG_CONFIG
AX_PTHREAD
AC_ARG_VAR([HELP2MAN],
[absolute path to help2man used for man page generation of pcsc-relay])
AC_PATH_PROG(HELP2MAN, help2man, not found)
if test ! -r src/pcsc-relay.1 -a "${HELP2MAN}" = "not found"
then
if test "${HELP2MAN}" = "not found"
then
AC_MSG_ERROR([Need help2man to generate man page for pcsc-relay])
fi
else
# make sure these files are the most recent
touch src/pcsc-relay.1
fi
AC_ARG_VAR([GENGETOPT],
[absolute path to gengetopt used for command line parsing of pcsc-relay])
AC_PATH_PROG(GENGETOPT, gengetopt, not found)
if test ! -r src/cmdline.h -o ! -r src/cmdline.c
then
if test "${GENGETOPT}" = "not found"
then
AC_MSG_ERROR([Need gengetopt for parsing command line of pcsc-relay])
fi
else
# make sure these files are the most recent
touch src/pcsc-relay.ggo
touch src/cmdline.h src/cmdline.h
fi
# If you need to see the details, just run make V=1.
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_ARG_ENABLE(
[libnfc],
[AS_HELP_STRING([--enable-libnfc],[enable emulation hardware supported via libnfc @<:@detect@:>@])],
,
[enable_libnfc="detect"]
)
# Checks for libraries.
PKG_CHECK_EXISTS([libpcsclite],
[PKG_CHECK_MODULES([PCSC], [libpcsclite])],
[AC_MSG_WARN([libpcsclite 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
])
# Checks for libraries.
PKG_CHECK_EXISTS([libnfc >= 1.6],
[PKG_CHECK_MODULES([LIBNFC], [libnfc >= 1.6])])
saved_CPPFLAGS="$CPPFLAGS"
saved_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $PCSC_CFLAGS"
LIBS="$LIBS $PCSC_LIBS"
AC_CHECK_HEADERS(winscard.h, [], [ AC_MSG_ERROR([winscard.h not found, install PC/SC Lite or similar or use ./configure PCSC_CFLAGS=...]) ])
AC_CHECK_HEADERS(reader.h, [AC_DEFINE(HAVE_READER_H, 1, [use reader.h from PC/SC Lite])], [])
AC_CHECK_HEADERS(wintypes.h, [AC_DEFINE(HAVE_WINTYPES_H, 1, [use wintypes.h from PC/SC Lite])], [])
AC_CHECK_HEADERS(pcsclite.h, [AC_DEFINE(HAVE_PCSCLITE_H, 1, [use pcsclite.h from PC/SC Lite])], [])
AC_MSG_CHECKING([for SCardEstablishContext])
AC_TRY_LINK_FUNC(SCardEstablishContext, [ AC_MSG_RESULT([yes]) ],
[ AC_MSG_ERROR([libpcsclite not found, use ./configure PCSC_LIBS=...]) ])
have_libnfc="yes"
CPPFLAGS="$saved_CPPFLAGS $LIBNFC_CFLAGS"
LIBS="$saved_LIBS $LIBNFC_LIBS"
AC_CHECK_HEADERS(nfc/nfc.h, , [have_libnfc="no"])
AC_MSG_CHECKING([for nfc_initiator_select_passive_target])
AC_TRY_LINK_FUNC(nfc_initiator_select_passive_target,
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
have_libnfc="no" ])
CPPFLAGS="$saved_CPPFLAGS"
LIBS="$saved_LIBS"
case "${enable_libnfc}" in
no)
have_libnfc="no"
;;
detect)
if test "${have_libnfc}" = "yes"; then
enable_libnfc="yes"
else
enable_libnfc="no"
fi
;;
esac
if test "${enable_libnfc}" = "yes"; then
if test "${have_libnfc}" = "yes"; then
AC_DEFINE([ENABLE_LIBNFC], [1], [Use emulation hardware supported via libnfc])
else
AC_MSG_ERROR([libnfc >= 1.6 not found, use ./configure LIBNFC_LIBS=... LIBNFC_CFLAGS=...])
fi
fi
AM_CONDITIONAL([ENABLE_LIBNFC], [test "${enable_libnfc}" = "yes"])
# --enable-piccdev=DEV
AC_ARG_ENABLE(piccdev,
AC_HELP_STRING([--enable-piccdev=DEV],[OpenPICC character device (default: /dev/ttyACM0)]),
[piccdev="${enableval}"], [piccdev="/dev/ttyACM0"])
AC_DEFINE_UNQUOTED(PICCDEV, "${piccdev}", [OpenPICC character device])
PACKAGE_SUMMARY="Relay a smart card to a contactless interface"
AC_SUBST(PACKAGE_SUMMARY)
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h unistd.h termios.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT8_T
AC_CHECK_DECLS([SO_NOSIGPIPE], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([MSG_NOSIGNAL], [], [], [#include <sys/socket.h>])
# Checks for library functions.
AC_CHECK_FUNCS([sigaction tcgetattr strerror strtol strtoul])
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CONFIG_FILES([Makefile
doc/Makefile
src/Makefile])
AC_OUTPUT
cat << EOF
pcsc-relay has been configured with following options:
Version: ${PACKAGE_VERSION}
User binaries: $(eval eval eval echo "${bindir}")
Enable libnfc: ${enable_libnfc}
OpenPICC device: ${piccdev}
Host: ${host}
Compiler: ${CC}
Preprocessor flags: ${CPPFLAGS}
Compiler flags: ${CFLAGS}
Linker flags: ${LDFLAGS}
Libraries: ${LIBS}
PTHREAD_LIBS: ${PTHREAD_LIBS}
PTHREAD_CFLAGS: ${PTHREAD_CFLAGS}
PCSC_CFLAGS: ${PCSC_CFLAGS}
PCSC_LIBS: ${PCSC_LIBS}
LIBNFC_CFLAGS: ${LIBNFC_CFLAGS}
LIBNFC_LIBS: ${LIBNFC_LIBS}
HELP2MAN: ${HELP2MAN}
GENGETOPT: ${GENGETOPT}
EOF