blob: 4668cf0539c453b73f8f243d83ec572c73401b06 [file] [log] [blame]
Yavor Goulishevbda86ae2011-05-23 11:56:53 -07001AC_INIT([libusb], [1.0.8])
2AM_INIT_AUTOMAKE
3AC_CONFIG_SRCDIR([libusb/core.c])
4AC_CONFIG_MACRO_DIR([m4])
5AM_CONFIG_HEADER([config.h])
6m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
7
8AC_PREREQ([2.50])
9AC_PROG_CC
10AC_PROG_LIBTOOL
11AC_C_INLINE
12AM_PROG_CC_C_O
13AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions])
14
15AC_MSG_CHECKING([operating system])
16case $host in
17*-linux*)
18 AC_DEFINE(OS_LINUX, [], [Linux backend])
19 AC_SUBST(OS_LINUX)
20 AC_MSG_RESULT([Linux])
21 backend="linux"
22 AC_CHECK_LIB(rt, clock_gettime)
23 AM_LDFLAGS=""
24 ;;
25*-darwin*)
26 AC_DEFINE(OS_DARWIN, [], [Darwin backend])
27 AC_SUBST(OS_DARWIN)
28 AC_DEFINE(USBI_OS_HANDLES_TIMEOUT, [], [Backend handles timeout])
29 AC_MSG_RESULT([Darwin/MacOS X])
30 backend="darwin"
31 AM_LDFLAGS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -no-undefined"
32 ;;
33*)
34 AC_MSG_ERROR([unsupported operating system])
35esac
36
37AM_CONDITIONAL([OS_LINUX], [test "x$backend" == "xlinux"])
38AM_CONDITIONAL([OS_DARWIN], [test "x$backend" == "xdarwin"])
39
40# Library versioning
41lt_major="0"
42lt_revision="0"
43lt_age="0"
44AC_SUBST(lt_major)
45AC_SUBST(lt_revision)
46AC_SUBST(lt_age)
47
48# timerfd
49AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
50AC_ARG_ENABLE([timerfd],
51 [AS_HELP_STRING([--enable-timerfd],
52 [use timerfd for timing (default auto)])],
53 [use_timerfd=$enableval], [use_timerfd='auto'])
54
55if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then
56 AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
57fi
58
59AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>])
60if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then
61 AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
62fi
63
64AC_MSG_CHECKING([whether to use timerfd for timing])
65if test "x$use_timerfd" = "xno"; then
66 AC_MSG_RESULT([no (disabled by user)])
67else
68 if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then
69 AC_MSG_RESULT([yes])
70 AC_DEFINE(USBI_TIMERFD_AVAILABLE, [], [timerfd headers available])
71 else
72 AC_MSG_RESULT([no (header not available)])
73 fi
74fi
75
76# Message logging
77AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
78 [log_enabled=$enableval],
79 [log_enabled='yes'])
80if test "x$log_enabled" != "xno"; then
81 AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
82fi
83
84AC_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'])
88if test "x$debug_log_enabled" != "xno"; then
89 AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging])
90fi
91
92# Examples build
93AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
94 [build example applications (default n)])],
95 [build_examples=$enableval],
96 [build_examples='no'])
97AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
98
99# Restore gnu89 inline semantics on gcc 4.3 and newer
100saved_cflags="$CFLAGS"
101CFLAGS="$CFLAGS -fgnu89-inline"
102AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="")
103CFLAGS="$saved_cflags"
104
105# check for -fvisibility=hidden compiler support (GCC >= 3.4)
106saved_cflags="$CFLAGS"
107CFLAGS="$CFLAGS -fvisibility=hidden"
108AC_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]) ],
113 ])
114CFLAGS="$saved_cflags"
115
116# check for -Wno-pointer-sign compiler support (GCC >= 4)
117saved_cflags="$CFLAGS"
118CFLAGS="$CFLAGS -Wno-pointer-sign"
119AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
120 nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
121CFLAGS="$saved_cflags"
122
123AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow"
124
125AC_SUBST(VISIBILITY_CFLAGS)
126AC_SUBST(AM_CFLAGS)
127AC_SUBST(AM_LDFLAGS)
128
129AC_CONFIG_FILES([libusb-1.0.pc] [Makefile] [libusb/Makefile] [examples/Makefile] [doc/Makefile] [doc/doxygen.cfg])
130AC_OUTPUT
131