1 AC_INIT([libusb], [1.0.5])
3 AC_CONFIG_SRCDIR([libusb/core.c])
4 AC_CONFIG_MACRO_DIR([m4])
5 AM_CONFIG_HEADER([config.h])
6 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
13 AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions])
15 AC_MSG_CHECKING([operating system])
18 AC_DEFINE(OS_LINUX, [], [Linux backend])
20 AC_MSG_RESULT([Linux])
22 AC_CHECK_LIB(rt, clock_gettime)
26 AC_DEFINE(OS_DARWIN, [], [Darwin backend])
28 AC_DEFINE(USBI_OS_HANDLES_TIMEOUT, [], [Backend handles timeout])
29 AC_MSG_RESULT([Darwin/MacOS X])
31 AM_LDFLAGS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -no-undefined"
34 AC_MSG_ERROR([unsupported operating system])
37 AM_CONDITIONAL([OS_LINUX], [test "x$backend" == "xlinux"])
38 AM_CONDITIONAL([OS_DARWIN], [test "x$backend" == "xdarwin"])
49 AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
50 AC_ARG_ENABLE([timerfd],
51 [AS_HELP_STRING([--enable-timerfd],
52 [use timerfd for timing (default auto)])],
53 [use_timerfd=$enableval], [use_timerfd='auto'])
55 if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then
56 AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
59 AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>])
60 if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then
61 AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
64 AC_MSG_CHECKING([whether to use timerfd for timing])
65 if test "x$use_timerfd" = "xno"; then
66 AC_MSG_RESULT([no (disabled by user)])
68 if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then
70 AC_DEFINE(USBI_TIMERFD_AVAILABLE, [], [timerfd headers available])
72 AC_MSG_RESULT([no (header not available)])
77 AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
78 [log_enabled=$enableval],
80 if test "x$log_enabled" != "xno"; then
81 AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
84 AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
85 [enable debug logging (default n)])],
86 [debug_log_enabled=$enableval],
87 [debug_log_enabled='no'])
88 if test "x$debug_log_enabled" != "xno"; then
89 AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging])
93 AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
94 [build example applications (default n)])],
95 [build_examples=$enableval],
96 [build_examples='no'])
97 AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
99 # Restore gnu89 inline semantics on gcc 4.3 and newer
100 saved_cflags="$CFLAGS"
101 CFLAGS="$CFLAGS -fgnu89-inline"
102 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="")
103 CFLAGS="$saved_cflags"
105 # check for -fvisibility=hidden compiler support (GCC >= 3.4)
106 saved_cflags="$CFLAGS"
107 CFLAGS="$CFLAGS -fvisibility=hidden"
108 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
109 [VISIBILITY_CFLAGS="-fvisibility=hidden"
110 AC_DEFINE([API_EXPORTED], [__attribute__((visibility("default")))], [Default visibility]) ],
111 [ VISIBILITY_CFLAGS=""
112 AC_DEFINE([API_EXPORTED], [], [Default visibility]) ],
114 CFLAGS="$saved_cflags"
116 # check for -Wno-pointer-sign compiler support (GCC >= 4)
117 saved_cflags="$CFLAGS"
118 CFLAGS="$CFLAGS -Wno-pointer-sign"
119 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
120 nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
121 CFLAGS="$saved_cflags"
123 AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow"
125 AC_SUBST(VISIBILITY_CFLAGS)
129 AC_CONFIG_FILES([libusb-1.0.pc] [Makefile] [libusb/Makefile] [examples/Makefile] [doc/Makefile] [doc/doxygen.cfg])