-
Notifications
You must be signed in to change notification settings - Fork 438
/
configure.ac
229 lines (184 loc) · 6.5 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# General init
# /!\ Don't forget to update 'CMakeLists.txt' too /!\
AC_INIT([libnfc],[1.8.0],[[email protected]])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADER(config.h)
# GIT revison
GIT_REVISION=`which git > /dev/null && git describe`
if test x"$GIT_REVISION" != x""; then
AC_DEFINE_UNQUOTED([GIT_REVISION], ["$GIT_REVISION"], [GIT revision])
fi
AM_INIT_AUTOMAKE(subdir-objects dist-bzip2 no-dist-gzip foreign)
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_LANG([C])
AC_PROG_CC
AC_PROG_MAKE_SET
WITH_POSIX_ONLY_EXAMPLES=1
# Libtool
LT_INIT
case "$host" in
*-pc-linux-gnu)
AC_MSG_RESULT([Fixing libtool for -rpath problems.])
sed -i -r 's/(hardcode_into_libs)=.*$/\1=no/' libtool
;;
*-pc-mingw32msvc)
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__"
;;
esac
AM_CONDITIONAL(POSIX_ONLY_EXAMPLES_ENABLED, [test "$WITH_POSIX_ONLY_EXAMPLES" = "1"])
PKG_PROG_PKG_CONFIG
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([fcntl.h limits.h stdio.h stdlib.h stdint.h stddef.h stdbool.h sys/ioctl.h sys/param.h sys/time.h termios.h])
AC_CHECK_HEADERS([linux/spi/spidev.h], [spi_available="yes"])
AC_CHECK_HEADERS([linux/i2c-dev.h], [i2c_available="yes"])
AC_CHECK_HEADERS([linux_nfc_api.h], [nfc_nci_available="yes"])
AC_CHECK_FUNCS([memmove memset select strdup strerror strstr strtol usleep],
[AC_DEFINE([_XOPEN_SOURCE], [600], [Enable POSIX extensions if present])])
AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
# Note: malloc function should be tested but it produces some error while cross-compiling with MinGW
# AC_FUNC_MALLOC
# Checks for types
AC_TYPE_SIZE_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_OFF_T
LIBNFC_CFLAGS='-I$(top_srcdir)/libnfc -I$(top_builddir)/include -I$(top_srcdir)/include'
AC_SUBST(LIBNFC_CFLAGS)
# Log support (default:yes)
AC_ARG_ENABLE([log],AS_HELP_STRING([--disable-log],[Disable any logs]),[enable_log=$enableval],[enable_log="yes"])
AC_MSG_CHECKING(for log flag)
AC_MSG_RESULT($enable_log)
AM_CONDITIONAL([WITH_LOG], [test "$enable_log" != "no"])
if test x"$enable_log" = "xyes"
then
AC_DEFINE([LOG], [1], [Enable log])
fi
# Conffiles support (default:yes)
AC_ARG_ENABLE([conffiles],AS_HELP_STRING([--disable-conffiles],[Disable use of config files]),[enable_conffiles=$enableval],[enable_conffiles="yes"])
AC_MSG_CHECKING(for conffiles flag)
AC_MSG_RESULT($enable_conffiles)
AM_CONDITIONAL([WITH_CONFFILES], [test "$enable_conffiles" != "no"])
if test x"$enable_conffiles" = "xyes"
then
AC_DEFINE([CONFFILES], [1], [Enable conffiles])
fi
# Envvars support (default:yes)
AC_ARG_ENABLE([envvars],AS_HELP_STRING([--disable-envvars],[Disable use of environment variables]),[enable_envvars=$enableval],[enable_envvars="yes"])
AC_MSG_CHECKING(for envvars flag)
AC_MSG_RESULT($enable_envvars)
AM_CONDITIONAL([WITH_ENVVARS], [test "$enable_envvars" != "no"])
if test x"$enable_envvars" = "xyes"
then
AC_DEFINE([ENVVARS], [1], [Enable envvars])
fi
# Debug support (default:no)
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Enable debug mode]),[enable_debug=$enableval],[enable_debug="no"])
AC_MSG_CHECKING(for debug flag)
AC_MSG_RESULT($enable_debug)
AM_CONDITIONAL([WITH_DEBUG], [test "$enable_debug" != "no"])
if test x"$enable_debug" = "xyes"
then
AC_DEFINE([DEBUG], [1], [Enable debug flag])
CFLAGS="$CFLAGS -g -O0 -ggdb"
fi
# Handle --with-drivers option
LIBNFC_ARG_WITH_DRIVERS
# Enable UART if
AM_CONDITIONAL(UART_ENABLED, [test x"$uart_required" = x"yes"])
# Enable SPI if
AM_CONDITIONAL(SPI_ENABLED, [test x"$spi_required" = x"yes"])
# Enable I2C if
AM_CONDITIONAL(I2C_ENABLED, [test x"$i2c_required" = x"yes"])
if test x"$i2c_required" = x"yes"
then
AC_SEARCH_LIBS([clock_gettime], [rt])
fi
# Enable Libnfc-NCI if required
if test x"$nfc_nci_required" = x"yes"
then
PKG_CHECK_MODULES([LIBNFC_NCI], [libnfc-nci],
[AC_MSG_NOTICE([libnfc-nci present])],
[AC_MSG_ERROR([libnfc-nci not present but required for some drivers configuration])]
)
CFLAGS="$CFLAGS $LIBNFC_NCI_CFLAGS"
fi
# Documentation (default: no)
AC_ARG_ENABLE([doc],AS_HELP_STRING([--enable-doc],[Enable documentation generation.]),[enable_doc=$enableval],[enable_doc="no"])
AC_MSG_CHECKING(for documentation request)
AC_MSG_RESULT($enable_doc)
if test x"$enable_doc" = "xyes"
then
AC_PATH_PROG([DOXYGEN], [doxygen])
if test x$DOXYGEN = x
then
AC_MSG_ERROR([doxygen is mandatory.])
fi
fi
AM_CONDITIONAL(DOC_ENABLED, [test x"$enable_doc" = xyes])
# Example build (default: yes)
AC_ARG_ENABLE([example],AS_HELP_STRING([--enable-example],[Enable example build.]),[enable_example=$enableval],[enable_example="yes"])
AC_MSG_CHECKING(for example build)
AC_MSG_RESULT($enable_example)
AM_CONDITIONAL(EXAMPLE_ENABLED, [test x"$enable_example" = xyes])
# Dependencies
PKG_CONFIG_REQUIRES=""
LIBNFC_CHECK_LIBUSB
LIBNFC_CHECK_PCSC
AC_SUBST(PKG_CONFIG_REQUIRES)
AM_CONDITIONAL(LIBUSB_ENABLED, [test "$HAVE_LIBUSB" = "1"])
AM_CONDITIONAL(PCSC_ENABLED, [test "$HAVE_PCSC" = "1"])
CUTTER_REQUIRED_VERSION=1.1.7
m4_ifdef([AC_CHECK_CUTTER], [AC_CHECK_CUTTER([>= $CUTTER_REQUIRED_VERSION])], [ac_cv_use_cutter="no"])
if test x$ac_cv_with_cutter = xyes -a x$ac_cv_use_cutter = xno; then
AC_MSG_ERROR([cutter >= $CUTTER_REQUIRED_VERSION is mandatory.])
fi
AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"])
if test x"$enable_example" = "xyes"
then
AC_CHECK_READLINE
fi
# Help us to write great code ;-)
CFLAGS="$CFLAGS -Wall -pedantic -Wextra"
# Defines and C flags
CFLAGS="$CFLAGS -std=c99"
# Workarounds for libusb in c99
CFLAGS="$CFLAGS -Du_int8_t=uint8_t -Du_int16_t=uint16_t"
AC_CONFIG_FILES([
Doxyfile
Makefile
cmake/Makefile
cmake/modules/Makefile
contrib/Makefile
contrib/devd/Makefile
contrib/libnfc/Makefile
contrib/linux/Makefile
contrib/udev/Makefile
contrib/win32/Makefile
contrib/win32/sys/Makefile
contrib/win32/libnfc/Makefile
contrib/win32/libnfc/buses/Makefile
examples/Makefile
examples/pn53x-tamashell-scripts/Makefile
include/Makefile
include/nfc/Makefile
libnfc.pc
libnfc/Makefile
libnfc/buses/Makefile
libnfc/chips/Makefile
libnfc/drivers/Makefile
test/Makefile
utils/Makefile
])
AC_OUTPUT
LIBNFC_DRIVERS_SUMMARY