-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.ac
303 lines (257 loc) · 7.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
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([srmio],[0.1.1~git1],[[email protected]])
AM_INIT_AUTOMAKE([-Wall -Werror])
AC_CONFIG_SRCDIR([srmio.h])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
LT_INIT()
# Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
# Checks for libraries.
AC_CHECK_LIB([dl],[dlopen],[
ac_cv_lib_dl=yes
], [
ac_cv_lib_dl=no
])
AM_CONDITIONAL([HAVE_LIBDL], [ test "x$ac_cv_lib_dl" = xyes ])
AS_IF([ test "x$ac_cv_lib_dl" = xyes ],[
AC_SUBST([HAVE_LIBDL],[true])
AC_DEFINE([HAVE_LIBDL],[1],[Define to 1 if you have libdl/dlopen])
])
AC_CHECK_LIB([pthread],[pthread_create],[
ac_cv_lib_pthread=yes
], [
ac_cv_lib_pthread=no
])
AM_CONDITIONAL([HAVE_LIBPTHREAD], [ test "x$ac_cv_lib_pthread" = xyes ])
AS_IF([ test "x$ac_cv_lib_pthread" = xyes ],[
AC_SUBST([HAVE_LIBPTHREAD],[true])
])
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([dlfcn.h fcntl.h getopt.h inttypes.h limits.h malloc.h memory.h stddef.h stdint.h stdlib.h string.h sys/stat.h sys/time.h termios.h unistd.h windows.h])
AC_CHECK_HEADER([ftd2xx.h],[
AC_DEFINE([HAVE_FTD2XX_H],[1],[Define to 1 if you have the <ftd2xx.h> header file.])
], [], AC_INCLUDES_DEFAULT([
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
]))
io_backends=""
AC_SYS_POSIX_TERMIOS
AM_CONDITIONAL([HAVE_TERMIOS],[ test "x$ac_cv_sys_posix_termios" = xyes ])
AS_IF([test "x$ac_cv_sys_posix_termios" = xyes], [
AC_SUBST([HAVE_TERMIOS], true)
AC_DEFINE([HAVE_TERMIOS],[1],[Define if sytem has posix termios for serial device access.])
io_backends="$io_backends termios"
],[])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
for tp in c_int8_t c_int16_t c_int32_t c_int64_t c_uint8_t c_uint16_t c_uint32_t c_uint64_t type_size_t; do
eval have_type=\$ac_cv_$tp
if test "x$have_type" != xyes; then
AC_MSG_WARN([*** missing $tp: $have_type])
fi
done
# Checks for library functions.
dnl AC_FUNC_MALLOC - unneeded, never called with size=0
dnl AC_FUNC_REALLOC - unneeded, never called with size=0
AC_FUNC_MEMCMP
AC_FUNC_MKTIME
AC_CHECK_FUNCS([cfmakeraw localtime_r mkstemps nanosleep ])
AC_CHECK_FUNCS([gettimeofday memset mkdir strcasecmp strdup strrchr strerror getopt_long ])
for func in gettimeofday memset mkdir strcasecmp strdup strrchr strerror getopt_long; do
eval have_func=\$ac_cv_func_$func
if test "x$have_func" != xyes; then
AC_MSG_WARN([*** missing working $func: $have_func])
fi
done
# check for windows mkdir(dir) - stolen from wine
AC_CACHE_CHECK([whether mkdir takes only one argument],
ac_cv_one_arg_mkdir,
AC_LINK_IFELSE([AC_LANG_PROGRAM([[[
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
]]], [[[
mkdir("foo");
]]])],[
ac_cv_one_arg_mkdir=yes
],[
ac_cv_one_arg_mkdir=no
])
)
if test "$ac_cv_one_arg_mkdir" = "yes"
then
AC_DEFINE([HAVE_ONE_ARG_MKDIR], [1], [Define if mkdir takes only one argument])
fi
# check for windows Sleep(msec)
AC_CACHE_CHECK([for windows Sleep using milliseconds],
ac_cv_msec_sleep,
AC_LINK_IFELSE([AC_LANG_PROGRAM([[[
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
]]], [[[
Sleep(1000);
]]])],[
ac_cv_msec_sleep=yes
],[
ac_cv_msec_sleep=no
])
)
if test "$ac_cv_msec_sleep" = "yes"
then
AC_DEFINE([HAVE_MSEC_SLEEP], [1], [Define to use Windows Sleep using milliseconds])
fi
AC_CACHE_CHECK([for windwos comm SetCommState],
ac_cv_func_SetCommState,
AC_LINK_IFELSE([AC_LANG_PROGRAM([[[
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
]]], [[[
HANDLE fh;
DCB dcb;
SetCommState(fh, &dcb);
]]])],[
ac_cv_func_SetCommState=yes
],[
ac_cv_func_SetCommState=no
])
)
AM_CONDITIONAL([HAVE_WINCOM],[ test "x$ac_cv_func_SetCommState" = xyes ])
AS_IF([test "x$ac_cv_func_SetCommState" = xyes], [
AC_SUBST([HAVE_WINCOM], true)
AC_DEFINE([HAVE_WINCOM],[1],[Define if sytem has win32 commport API.])
io_backends="$io_backends wincom"
],[])
# TODO: check for windows LoadLibraryA/FreeLibrary/GetProcAddress
# AC_CPP_FUNC
# ------------------ #
# Checks to see if ANSI C99 CPP variable __func__ works.
# If not, perhaps __FUNCTION__ works instead.
# If not, we'll just define __func__ to "".
AC_DEFUN([AC_CPP_FUNC],
[AC_REQUIRE([AC_PROG_CC_STDC])dnl
AC_CACHE_CHECK([for an ANSI C99-conforming __func__], ac_cv_cpp_func,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[[char *foo = __func__;]])],
[ac_cv_cpp_func=yes],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[[char *foo = __FUNCTION__;]])],
[ac_cv_cpp_func=__FUNCTION__],
[ac_cv_cpp_func=no])])])
if test $ac_cv_cpp_func = __FUNCTION__; then
AC_DEFINE(__func__,__FUNCTION__,
[Define to __FUNCTION__ or "" if __func__ does not conform to ANSI C.])
elif test $ac_cv_cpp_func = no; then
AC_DEFINE(__func__,"",
[Define to __FUNCTION__ or "" if __func__ does not conform to ANSI C.])
fi
])# AC_CPP_FUNC
AC_CPP_FUNC
# TODO: getopt_long alternatives (FreeBSD)
# TODO: provide alternative implementations, use gnulib?
AC_ARG_WITH([ftd2xx], [AS_HELP_STRING([--with-ftd2xx=<filename>],
[support libftd2xx for FTDI device serial access @<:@default=check@:>@])
],[
],[
if test "x$ac_cv_header_ftd2xx_h" = xyes ; then
with_ftd2xx=check
else
with_ftd2xx=no
fi
])
ac_cv_d2xx_libname=""
AC_MSG_CHECKING([for ftd2xx filename])
AS_IF([ test "x$with_ftd2xx" = xno ], [
AC_MSG_RESULT([no])
], [test "x$with_ftd2xx" == xyes || test "x$with_ftd2xx" == xcheck], [
case "$host" in
*cygwin*|*mingw*)
ac_cv_d2xx_libname=ftd2xx.dll
;;
*darwin*)
ac_cv_d2xx_libname=libftd2xx.dylib
;;
*)
ac_cv_d2xx_libname=libftd2xx.so
;;
esac
if test -z "$ac_cv_d2xx_libname" ; then
if test "x$with_ftd2xx" != xcheck; then
AC_MSG_FAILURE([--with-ftd2x was given, but test for ftd2xx failed])
else
AC_MSG_RESULT([none])
fi
else
AC_MSG_RESULT("$ac_cv_d2xx_libname")
fi
], [
ac_cv_d2xx_libname="$with_ftd2xx"
AC_MSG_RESULT("$ac_cv_d2xx_libname" - forced by user)
])
AM_CONDITIONAL([HAVE_D2XX], [ test -n "$ac_cv_d2xx_libname" ])
if test "x$with_ftd2xx" != xcheck && test -n "$ac_cv_d2xx_libname"; then
if test "x$ac_cv_header_ftd2xx_h" != xyes; then
AC_MSG_WARN([*** d2xx requires ftd2xx.h header])
fi
fi
AS_IF([ test -n "$ac_cv_d2xx_libname" ], [
AC_SUBST([HAVE_D2XX],[true])
AC_DEFINE([HAVE_D2XX],[1],[Define if system has libftd2xx.])
AC_DEFINE_UNQUOTED([D2XX_LIBNAME],"$ac_cv_d2xx_libname",[Define to libftd2xx filname for dlopen.])
io_backends="$io_backends ftd2xx"
])
AS_IF([ test -n "$io_backends" ], [
AC_MSG_NOTICE([detected serial IO backends:$io_backends])
], [
AC_MSG_WARN([*** no working serial IO found ])
])
if test "x$ac_cv_func_nanosleep" != xyes && test "x$ac_cv_msec_sleep" != xyes ; then
AC_MSG_WARN([*** no high-precision sleep function found])
fi
AC_CONFIG_FILES([Makefile])
AC_CONFIG_COMMANDS([genconfheader.sh],[
. $srcdir/genconfheader.sh > "$tmp/srmio_config.h"
if diff "$tmp/srmio_config.h" srmio_config.h > /dev/null 2>&1; then
: # unchanged
else
rm -f srmio_config.h
mv "$tmp/srmio_config.h" srmio_config.h
fi
],[
HEADER_STDINT_H=$ac_cv_header_stdint_h
HEADER_INTTYPES_H=$ac_cv_header_inttypes_h
HEADER_STDBOOL_H=$ac_cv_header_stdbool_h
HAVE__BOOL=$ac_cv_type__Bool
HEADER_SYS_TIME_H=$ac_cv_header_sys_time_h
HAVE_TERMIOS=$ac_cv_sys_posix_termios
HAVE_WINCOM=$ac_cv_func_SetCommState
HAVE_D2XX=$HAVE_D2XX
PACKAGE_VERSION=$PACKAGE_VERSION
])
AC_OUTPUT