Darwin: Provide libusb_get_device_speed() data
[libusbx.git] / configure.ac
blobff3a2597bda3943e64a63b783b0fe7576678c132
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 dnl The m4_bregexp() returns (only) the numbers following the #define named
7 dnl in the first macro parameter. m4_define() then defines the name for use
8 dnl in AC_INIT().
10 LU_DEFINE_VERSION_ATOM([LIBUSB_MAJOR])
11 LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR])
12 LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO])
14 AC_INIT([libusb], LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO, [libusb-devel@lists.sourceforge.net], [libusb], [http://www.libusb.org/])
16 # Library versioning
17 # These numbers should be tweaked on every release. Read carefully:
18 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
19 # http://sourceware.org/autobook/autobook/autobook_91.html
20 lt_current="1"
21 lt_revision="0"
22 lt_age="1"
23 LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}"
25 AM_INIT_AUTOMAKE
26 AM_MAINTAINER_MODE
28 AC_CONFIG_SRCDIR([libusb/core.c])
29 AC_CONFIG_MACRO_DIR([m4])
30 AM_CONFIG_HEADER([config.h])
31 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
33 AC_PREREQ([2.50])
34 AC_PROG_CC
35 AC_PROG_LIBTOOL
36 AC_C_INLINE
37 AM_PROG_CC_C_O
38 AC_DEFINE([_GNU_SOURCE], 1, [Use GNU extensions])
40 LTLDFLAGS="${LTLDFLAGS} -no-undefined"
42 AC_MSG_CHECKING([operating system])
43 case $host in
44 *-linux*)
45         AC_DEFINE(OS_LINUX, 1, [Linux backend])
46         AC_SUBST(OS_LINUX)
47         AC_MSG_RESULT([Linux])
48         backend="linux"
49         AC_CHECK_LIB(rt, clock_gettime, PC_LIBS_PRIVATE="-lrt")
50         threads="posix"
51         THREAD_CFLAGS="-pthread"
52         PC_LIBS_PRIVATE="${PC_LIBS_PRIVATE} -pthread"
53         AC_CHECK_HEADERS([poll.h])
54         AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
55         ;;
56 *-darwin*)
57         AC_DEFINE(OS_DARWIN, 1, [Darwin backend])
58         AC_SUBST(OS_DARWIN)
59         AC_MSG_RESULT([Darwin/Mac OS X])
60         backend="darwin"
61         threads="posix"
62         LIBS="${LIBS} -lobjc"
63         PC_LIBS_PRIVATE="-Wl,-framework,IOKit -Wl,-framework,CoreFoundation"
64         LTLDFLAGS="${LTLDFLAGS} -Wl,-prebind"
65         AC_CHECK_HEADERS([poll.h])
66         AC_CHECK_TYPE([nfds_t],
67                 [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])],
68                 [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])],
69                 [#include <poll.h>])
70         ;;
71 *-mingw*)
72         AC_MSG_RESULT([Windows])
73         backend="windows"
74         ;;
75 *-cygwin*)
76         AC_MSG_RESULT([Cygwin (using Windows backend)])
77         backend="windows"
78         threads="posix"
79         ;;
81         AC_MSG_ERROR([unsupported operating system])
82 esac
83 if test "$backend" = windows; then
84         AC_DEFINE(OS_WINDOWS, 1, [Windows backend])
85         AC_SUBST(OS_WINDOWS)
86         PC_LIBS_PRIVATE=""
87         LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
88         AC_CHECK_TOOL(RC, windres, no)
89         AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])
91 AC_SUBST(THREAD_CFLAGS)
92 AC_SUBST(PC_LIBS_PRIVATE)
93 LIBS="${LIBS} ${PC_LIBS_PRIVATE}"
95 AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux)
96 AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin)
97 AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows)
98 AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix)
99 if test "$threads" = posix; then
100         AC_DEFINE(THREADS_POSIX, 1, [Use POSIX Threads])
103 # timerfd
104 AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
105 AC_ARG_ENABLE([timerfd],
106         [AS_HELP_STRING([--enable-timerfd],
107                 [use timerfd for timing (default auto)])],
108         [use_timerfd=$enableval], [use_timerfd='auto'])
110 if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then
111         AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
114 AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>])
115 if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then
116         AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
119 AC_MSG_CHECKING([whether to use timerfd for timing])
120 if test "x$use_timerfd" = "xno"; then
121         AC_MSG_RESULT([no (disabled by user)])
122 else
123         if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then
124                 AC_MSG_RESULT([yes])
125                 AC_DEFINE(USBI_TIMERFD_AVAILABLE, 1, [timerfd headers available])
126         else
127                 AC_MSG_RESULT([no (header not available)])
128         fi
131 AC_CHECK_TYPES(struct timespec)
133 # Message logging
134 AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
135         [log_enabled=$enableval],
136         [log_enabled='yes'])
137 if test "x$log_enabled" != "xno"; then
138         AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
141 AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
142         [enable debug logging (default n)])],
143         [debug_log_enabled=$enableval],
144         [debug_log_enabled='no'])
145 if test "x$debug_log_enabled" != "xno"; then
146         AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging])
149 # Examples build
150 AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
151         [build example applications (default n)])],
152         [build_examples=$enableval],
153         [build_examples='no'])
154 AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
156 # check for -fvisibility=hidden compiler support (GCC >= 3.4)
157 saved_cflags="$CFLAGS"
158 # -Werror required for cygwin
159 CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
160 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
161         [VISIBILITY_CFLAGS="-fvisibility=hidden"
162          AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility]) ],
163         [ VISIBILITY_CFLAGS=""
164          AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility]) ],
165         ])
166 CFLAGS="$saved_cflags"
168 # check for -Wno-pointer-sign compiler support (GCC >= 4)
169 saved_cflags="$CFLAGS"
170 CFLAGS="$CFLAGS -Wno-pointer-sign"
171 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
172         nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
173 CFLAGS="$saved_cflags"
175 # sigaction not available on MinGW
176 AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no])
177 AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = "xyes"])
179 # headers not available on all platforms but required on others
180 AC_CHECK_HEADERS([sys/time.h])
182 AM_CFLAGS="-std=gnu99 -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow"
184 AC_SUBST(VISIBILITY_CFLAGS)
185 AC_SUBST(AM_CFLAGS)
186 AC_SUBST(LTLDFLAGS)
188 AC_CONFIG_FILES([libusb-1.0.pc])
189 AC_CONFIG_FILES([Makefile])
190 AC_CONFIG_FILES([libusb/Makefile])
191 AC_CONFIG_FILES([examples/Makefile])
192 AC_CONFIG_FILES([doc/Makefile])
193 AC_CONFIG_FILES([doc/doxygen.cfg])
194 AC_OUTPUT