1 AC_INIT([libusb], [1.0.2])
3 AC_CONFIG_SRCDIR([libusb/core.c])
4 AC_CONFIG_MACRO_DIR([m4])
5 AM_CONFIG_HEADER([config.h])
12 AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions])
14 AC_MSG_CHECKING([operating system])
17 AC_DEFINE(OS_LINUX, [], [Linux backend])
19 AC_MSG_RESULT([Linux])
21 AC_CHECK_LIB(rt, clock_gettime)
25 AC_DEFINE(OS_DARWIN, [], [Darwin backend])
27 AC_MSG_RESULT([Darwin/MacOS X])
29 AM_LDFLAGS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -no-undefined"
32 AC_MSG_ERROR([unsupported operating system])
35 AM_CONDITIONAL([OS_LINUX], [test "x$backend" == "xlinux"])
36 AM_CONDITIONAL([OS_DARWIN], [test "x$backend" == "xdarwin"])
47 AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
48 [log_enabled=$enableval],
50 if test "x$log_enabled" != "xno"; then
51 AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
54 AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
55 [enable debug logging (default n)])],
56 [debug_log_enabled=$enableval],
57 [debug_log_enabled='no'])
58 if test "x$debug_log_enabled" != "xno"; then
59 AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging])
63 AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
64 [build example applications (default n)])],
65 [build_examples=$enableval],
66 [build_examples='no'])
67 AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
69 # Restore gnu89 inline semantics on gcc 4.3 and newer
70 saved_cflags="$CFLAGS"
71 CFLAGS="$CFLAGS -fgnu89-inline"
72 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="")
73 CFLAGS="$saved_cflags"
75 # check for -fvisibility=hidden compiler support (GCC >= 3.4)
76 saved_cflags="$CFLAGS"
77 CFLAGS="$CFLAGS -fvisibility=hidden"
78 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
79 [VISIBILITY_CFLAGS="-fvisibility=hidden"
80 AC_DEFINE([API_EXPORTED], [__attribute__((visibility("default")))], [Default visibility]) ],
81 [ VISIBILITY_CFLAGS=""
82 AC_DEFINE([API_EXPORTED], [], [Default visibility]) ],
84 CFLAGS="$saved_cflags"
86 # check for -Wno-pointer-sign compiler support (GCC >= 4)
87 saved_cflags="$CFLAGS"
88 CFLAGS="$CFLAGS -Wno-pointer-sign"
89 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
90 nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
91 CFLAGS="$saved_cflags"
93 AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow"
95 AC_SUBST(VISIBILITY_CFLAGS)
99 AC_CONFIG_FILES([libusb-1.0.pc] [Makefile] [libusb/Makefile] [examples/Makefile] [doc/Makefile] [doc/doxygen.cfg])