1 | dnl These m4 macros are whitespace sensitive and break if moved around much.
|
---|
2 | m4_define([LU_VERSION_H], m4_include([libusb/version.h]))
|
---|
3 | m4_define([LU_DEFINE_VERSION_ATOM],
|
---|
4 | [m4_define([$1], m4_bregexp(LU_VERSION_H,
|
---|
5 | [^#define\s*$1\s*\([0-9]*\).*], [\1]))])
|
---|
6 | m4_define([LU_DEFINE_VERSION_RC_ATOM],
|
---|
7 | [m4_define([$1], m4_bregexp(LU_VERSION_H,
|
---|
8 | [^#define\s*$1\s*"\(-rc[0-9]*\)".*], [\1]))])
|
---|
9 | dnl The m4_bregexp() returns (only) the numbers following the #define named
|
---|
10 | dnl in the first macro parameter. m4_define() then defines the name for use
|
---|
11 | dnl in AC_INIT.
|
---|
12 |
|
---|
13 | LU_DEFINE_VERSION_ATOM([LIBUSB_MAJOR])
|
---|
14 | LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR])
|
---|
15 | LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO])
|
---|
16 | LU_DEFINE_VERSION_RC_ATOM([LIBUSB_RC])
|
---|
17 |
|
---|
18 | AC_INIT([libusb],[LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC],[libusb-devel@lists.sourceforge.net],[libusb],[http://libusb.info])
|
---|
19 |
|
---|
20 | # Library versioning
|
---|
21 | # These numbers should be tweaked on every release. Read carefully:
|
---|
22 | # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
---|
23 | # http://sourceware.org/autobook/autobook/autobook_91.html
|
---|
24 | lt_current="1"
|
---|
25 | lt_revision="0"
|
---|
26 | lt_age="1"
|
---|
27 | LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}"
|
---|
28 |
|
---|
29 | AM_INIT_AUTOMAKE
|
---|
30 |
|
---|
31 | AC_CONFIG_SRCDIR([libusb/core.c])
|
---|
32 | AC_CONFIG_MACRO_DIR([m4])
|
---|
33 | AC_CONFIG_HEADERS([config.h])
|
---|
34 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
---|
35 |
|
---|
36 | AC_PREREQ([2.69])
|
---|
37 | AC_PROG_CC
|
---|
38 | AC_PROG_CXX
|
---|
39 | LT_INIT
|
---|
40 | LT_LANG([Windows Resource])
|
---|
41 | AC_C_INLINE
|
---|
42 | AM_PROG_CC_C_O
|
---|
43 | AC_DEFINE([_GNU_SOURCE], 1, [Use GNU extensions])
|
---|
44 |
|
---|
45 | LTLDFLAGS="${LTLDFLAGS} -no-undefined"
|
---|
46 |
|
---|
47 | AC_MSG_CHECKING([operating system])
|
---|
48 |
|
---|
49 | dnl on linux-android platform, some functions are in different places
|
---|
50 | case $host in
|
---|
51 | *-linux-android*)
|
---|
52 | AC_MSG_RESULT([This is a Linux-Android system])
|
---|
53 | is_backend_android="yes"
|
---|
54 | ;;
|
---|
55 | *)
|
---|
56 | is_backend_android="no"
|
---|
57 | esac
|
---|
58 |
|
---|
59 | case $host in
|
---|
60 | *-linux* | *-uclinux*)
|
---|
61 | AC_MSG_RESULT([Linux])
|
---|
62 | backend="linux"
|
---|
63 | threads="posix"
|
---|
64 | ;;
|
---|
65 | *-darwin*)
|
---|
66 | AC_MSG_RESULT([Darwin/Mac OS X])
|
---|
67 | backend="darwin"
|
---|
68 | threads="posix"
|
---|
69 | ;;
|
---|
70 | *-openbsd*)
|
---|
71 | AC_MSG_RESULT([OpenBSD])
|
---|
72 | backend="openbsd"
|
---|
73 | threads="posix"
|
---|
74 | ;;
|
---|
75 | *-netbsd*)
|
---|
76 | AC_MSG_RESULT([NetBSD])
|
---|
77 | backend="netbsd"
|
---|
78 | threads="posix"
|
---|
79 | ;;
|
---|
80 | *-mingw* | *msys*)
|
---|
81 | AC_MSG_RESULT([Windows])
|
---|
82 | backend="windows"
|
---|
83 | threads="windows"
|
---|
84 | create_import_lib="yes"
|
---|
85 | AM_CFLAGS="${AM_CFLAGS} -fno-omit-frame-pointer"
|
---|
86 | ;;
|
---|
87 | *-os2-emx*)
|
---|
88 | AC_MSG_RESULT([OS2])
|
---|
89 | backend="os2"
|
---|
90 | threads="posix"
|
---|
91 | ;;
|
---|
92 | *-cygwin*)
|
---|
93 | AC_MSG_RESULT([Cygwin (using Windows backend)])
|
---|
94 | backend="windows"
|
---|
95 | threads="posix"
|
---|
96 | ;;
|
---|
97 | *-haiku*)
|
---|
98 | AC_MSG_RESULT([Haiku])
|
---|
99 | backend="haiku"
|
---|
100 | threads="posix"
|
---|
101 | ;;
|
---|
102 | *-solaris*)
|
---|
103 | AC_MSG_RESULT([SunOS])
|
---|
104 | backend="sunos"
|
---|
105 | threads="posix"
|
---|
106 | ;;
|
---|
107 | *)
|
---|
108 | AC_MSG_ERROR([unsupported operating system $host])
|
---|
109 | esac
|
---|
110 |
|
---|
111 | case $backend in
|
---|
112 | linux)
|
---|
113 | AC_DEFINE(OS_LINUX, 1, [Linux backend])
|
---|
114 | AC_SUBST(OS_LINUX)
|
---|
115 | AC_SEARCH_LIBS(clock_gettime, rt, [], [], -pthread)
|
---|
116 | AC_ARG_ENABLE([udev],
|
---|
117 | [AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended) [default=yes]])],
|
---|
118 | [], [enable_udev="yes"])
|
---|
119 | if test "x$enable_udev" = "xyes" ; then
|
---|
120 | # system has udev. use it or fail!
|
---|
121 | AC_CHECK_HEADERS([libudev.h],[],[AC_ERROR(["udev support requested but libudev not installed"])])
|
---|
122 | AC_CHECK_LIB([udev], [udev_new], [], [AC_ERROR(["udev support requested but libudev not installed"])])
|
---|
123 | AC_DEFINE(USE_UDEV, 1, [Use udev for device enumeration/hotplug])
|
---|
124 | else
|
---|
125 | AC_CHECK_HEADERS([asm/types.h], [], [])
|
---|
126 | AC_CHECK_HEADERS([sys/socket.h linux/netlink.h], [], [AC_ERROR(["Linux netlink headers not found"])], [
|
---|
127 | #ifdef HAVE_ASM_TYPES_H
|
---|
128 | #include <asm/types.h>
|
---|
129 | #endif
|
---|
130 | #include <sys/socket.h>
|
---|
131 | ])
|
---|
132 | fi
|
---|
133 | AC_SUBST(USE_UDEV)
|
---|
134 |
|
---|
135 | case $is_backend_android in
|
---|
136 | yes)
|
---|
137 | dnl there are gettimeofday function but configure doesn't seem to be able to find it.
|
---|
138 | AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [Define if you have gettimeofday])
|
---|
139 | ;;
|
---|
140 | *)
|
---|
141 | THREAD_CFLAGS="-pthread"
|
---|
142 | LIBS="${LIBS} -pthread"
|
---|
143 | esac
|
---|
144 |
|
---|
145 | AC_CHECK_HEADERS([poll.h])
|
---|
146 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
|
---|
147 | ;;
|
---|
148 | darwin)
|
---|
149 | AC_DEFINE(OS_DARWIN, 1, [Darwin backend])
|
---|
150 | AC_SUBST(OS_DARWIN)
|
---|
151 | LIBS="-lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation"
|
---|
152 | LTLDFLAGS="${LTLDFLAGS} -Wl,-prebind"
|
---|
153 | AC_CHECK_HEADERS([poll.h])
|
---|
154 | AC_CHECK_TYPE([nfds_t],
|
---|
155 | [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])],
|
---|
156 | [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])],
|
---|
157 | [#include <poll.h>])
|
---|
158 | ;;
|
---|
159 | openbsd)
|
---|
160 | AC_DEFINE(OS_OPENBSD, 1, [OpenBSD backend])
|
---|
161 | AC_SUBST(OS_OPENBSD)
|
---|
162 | THREAD_CFLAGS="-pthread"
|
---|
163 | LIBS="-pthread"
|
---|
164 | AC_CHECK_HEADERS([poll.h])
|
---|
165 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
|
---|
166 | ;;
|
---|
167 | sunos)
|
---|
168 | AC_DEFINE(OS_SUNOS, 1, [SunOS backend])
|
---|
169 | AC_SUBST(OS_SUNOS)
|
---|
170 | THREAD_CFLAGS="-pthread"
|
---|
171 | LIBS="-pthread -ldevinfo"
|
---|
172 | AC_CHECK_HEADERS([poll.h])
|
---|
173 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
|
---|
174 | ;;
|
---|
175 | netbsd)
|
---|
176 | AC_DEFINE(OS_NETBSD, 1, [NetBSD backend])
|
---|
177 | AC_SUBST(OS_NETBSD)
|
---|
178 | THREAD_CFLAGS="-pthread"
|
---|
179 | LIBS="-pthread"
|
---|
180 | AC_CHECK_HEADERS([poll.h])
|
---|
181 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
|
---|
182 | ;;
|
---|
183 | windows)
|
---|
184 | AC_DEFINE(OS_WINDOWS, 1, [Windows backend])
|
---|
185 | AC_SUBST(OS_WINDOWS)
|
---|
186 | LIBS=""
|
---|
187 | LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
|
---|
188 | AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])
|
---|
189 | AC_DEFINE([WINVER], 0x0501, [Oldest Windows version supported])
|
---|
190 |
|
---|
191 | AC_ARG_ENABLE([usbdk],
|
---|
192 | [AC_HELP_STRING([--enable-usbdk], [use UsbDk Windows backend [default=no]])],
|
---|
193 | [], [enable_usbdk="no"])
|
---|
194 | if test "x$enable_usbdk" = "xyes" ; then
|
---|
195 | AC_DEFINE(USE_USBDK, 1, [Use UsbDk Windows backend])
|
---|
196 | fi
|
---|
197 | AC_SUBST(USE_USBDK)
|
---|
198 | ;;
|
---|
199 | os2)
|
---|
200 | AC_DEFINE(OS_OS2, 1, [OS/2 backend])
|
---|
201 | AC_SUBST(OS_OS2)
|
---|
202 | LIBS="${LIBS} -lpthread"
|
---|
203 | AC_CHECK_HEADERS([poll.h])
|
---|
204 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
|
---|
205 | ;;
|
---|
206 | haiku)
|
---|
207 | AC_DEFINE(OS_HAIKU, 1, [Haiku backend])
|
---|
208 | AC_SUBST(OS_HAIKU)
|
---|
209 | LIBS="${LIBS} -lbe"
|
---|
210 | AC_CHECK_HEADERS([poll.h])
|
---|
211 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
|
---|
212 | ;;
|
---|
213 | esac
|
---|
214 |
|
---|
215 | AC_SUBST(LIBS)
|
---|
216 |
|
---|
217 | AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux)
|
---|
218 | AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin)
|
---|
219 | AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xopenbsd)
|
---|
220 | AM_CONDITIONAL(OS_SUNOS, test "x$backend" = xsunos)
|
---|
221 | AM_CONDITIONAL(OS_NETBSD, test "x$backend" = xnetbsd)
|
---|
222 | AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows)
|
---|
223 | AM_CONDITIONAL(OS_OS2, test "x$backend" = xos2)
|
---|
224 | AM_CONDITIONAL(OS_HAIKU, test "x$backend" = xhaiku)
|
---|
225 | AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix)
|
---|
226 | AM_CONDITIONAL(CREATE_IMPORT_LIB, test "x$create_import_lib" = "xyes")
|
---|
227 | AM_CONDITIONAL(USE_UDEV, test "x$enable_udev" = xyes)
|
---|
228 | AM_CONDITIONAL(USE_USBDK, test "x$enable_usbdk" = xyes)
|
---|
229 | if test "$threads" = posix; then
|
---|
230 | AC_DEFINE(THREADS_POSIX, 1, [Use POSIX Threads])
|
---|
231 | fi
|
---|
232 |
|
---|
233 | # timerfd
|
---|
234 | AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
|
---|
235 | AC_ARG_ENABLE([timerfd],
|
---|
236 | [AS_HELP_STRING([--enable-timerfd],
|
---|
237 | [use timerfd for timing [default=auto]])],
|
---|
238 | [use_timerfd=$enableval], [use_timerfd='auto'])
|
---|
239 |
|
---|
240 | if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then
|
---|
241 | AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
|
---|
242 | fi
|
---|
243 |
|
---|
244 | AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>])
|
---|
245 | if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then
|
---|
246 | AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
|
---|
247 | fi
|
---|
248 |
|
---|
249 | AC_MSG_CHECKING([whether to use timerfd for timing])
|
---|
250 | if test "x$use_timerfd" = "xno"; then
|
---|
251 | AC_MSG_RESULT([no (disabled by user)])
|
---|
252 | else
|
---|
253 | if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then
|
---|
254 | AC_MSG_RESULT([yes])
|
---|
255 | AC_DEFINE(USBI_TIMERFD_AVAILABLE, 1, [timerfd headers available])
|
---|
256 | else
|
---|
257 | AC_MSG_RESULT([no (header not available)])
|
---|
258 | fi
|
---|
259 | fi
|
---|
260 |
|
---|
261 | AC_CHECK_TYPES(struct timespec)
|
---|
262 |
|
---|
263 | # Message logging
|
---|
264 | AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
|
---|
265 | [log_enabled=$enableval],
|
---|
266 | [log_enabled='yes'])
|
---|
267 | if test "x$log_enabled" != "xno"; then
|
---|
268 | AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
|
---|
269 | fi
|
---|
270 |
|
---|
271 | AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
|
---|
272 | [start with debug message logging enabled [default=no]])],
|
---|
273 | [debug_log_enabled=$enableval],
|
---|
274 | [debug_log_enabled='no'])
|
---|
275 | if test "x$debug_log_enabled" != "xno"; then
|
---|
276 | AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Start with debug message logging enabled])
|
---|
277 | fi
|
---|
278 |
|
---|
279 | AC_ARG_ENABLE([system-log], [AS_HELP_STRING([--enable-system-log],
|
---|
280 | [output logging messages to system wide log, if supported by the OS [default=no]])],
|
---|
281 | [system_log_enabled=$enableval],
|
---|
282 | [system_log_enabled='no'])
|
---|
283 | if test "x$system_log_enabled" != "xno"; then
|
---|
284 | AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], 1, [Enable output to system log])
|
---|
285 | fi
|
---|
286 |
|
---|
287 | # Check if syslog is available in standard C library
|
---|
288 | AC_CHECK_HEADERS(syslog.h)
|
---|
289 | AC_CHECK_FUNC([syslog], [have_syslog=yes], [have_syslog=no])
|
---|
290 | if test "x$have_syslog" != "xno"; then
|
---|
291 | AC_DEFINE([HAVE_SYSLOG_FUNC], 1, [syslog() function available])
|
---|
292 | fi
|
---|
293 |
|
---|
294 | # Examples build
|
---|
295 | AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
|
---|
296 | [build example applications [default=no]])],
|
---|
297 | [build_examples=$enableval],
|
---|
298 | [build_examples='no'])
|
---|
299 | AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
|
---|
300 |
|
---|
301 | # Tests build
|
---|
302 | AC_ARG_ENABLE([tests-build], [AS_HELP_STRING([--enable-tests-build],
|
---|
303 | [build test applications [default=no]])],
|
---|
304 | [build_tests=$enableval],
|
---|
305 | [build_tests='no'])
|
---|
306 | AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != "xno"])
|
---|
307 |
|
---|
308 | # check for -fvisibility=hidden compiler support (GCC >= 3.4)
|
---|
309 | saved_cflags="$CFLAGS"
|
---|
310 | # -Werror required for cygwin
|
---|
311 | CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
|
---|
312 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
|
---|
313 | [VISIBILITY_CFLAGS="-fvisibility=hidden"
|
---|
314 | AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility]) ],
|
---|
315 | [ VISIBILITY_CFLAGS=""
|
---|
316 | AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility]) ],
|
---|
317 | ])
|
---|
318 | CFLAGS="$saved_cflags"
|
---|
319 |
|
---|
320 | # check for -Wno-pointer-sign compiler support (GCC >= 4)
|
---|
321 | saved_cflags="$CFLAGS"
|
---|
322 | CFLAGS="$CFLAGS -Wno-pointer-sign"
|
---|
323 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
|
---|
324 | nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
|
---|
325 | CFLAGS="$saved_cflags"
|
---|
326 |
|
---|
327 | # sigaction not available on MinGW
|
---|
328 | AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no])
|
---|
329 | AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = "xyes"])
|
---|
330 |
|
---|
331 | # headers not available on all platforms but required on others
|
---|
332 | AC_CHECK_HEADERS([sys/time.h])
|
---|
333 | AC_CHECK_FUNCS(gettimeofday)
|
---|
334 | AC_CHECK_HEADERS([signal.h])
|
---|
335 |
|
---|
336 | # check for -std=gnu99 compiler support
|
---|
337 | saved_cflags="$CFLAGS"
|
---|
338 | CFLAGS="-std=gnu99"
|
---|
339 | AC_MSG_CHECKING([whether CC supports -std=gnu99])
|
---|
340 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
|
---|
341 | [AC_MSG_RESULT([yes])]
|
---|
342 | [AM_CFLAGS="${AM_CFLAGS} -std=gnu99"],
|
---|
343 | [AC_MSG_RESULT([no])]
|
---|
344 | )
|
---|
345 | CFLAGS="$saved_cflags"
|
---|
346 |
|
---|
347 | AM_CFLAGS="${AM_CFLAGS} -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow ${THREAD_CFLAGS} ${VISIBILITY_CFLAGS}"
|
---|
348 |
|
---|
349 | AC_SUBST(AM_CFLAGS)
|
---|
350 | AC_SUBST(LTLDFLAGS)
|
---|
351 |
|
---|
352 | AC_CONFIG_FILES([libusb-1.0.pc])
|
---|
353 | AC_CONFIG_FILES([Makefile])
|
---|
354 | AC_CONFIG_FILES([libusb/Makefile])
|
---|
355 | AC_CONFIG_FILES([examples/Makefile])
|
---|
356 | AC_CONFIG_FILES([tests/Makefile])
|
---|
357 | AC_CONFIG_FILES([doc/Makefile])
|
---|
358 | AC_CONFIG_FILES([doc/doxygen.cfg])
|
---|
359 | AC_OUTPUT
|
---|