Darwin: Add support for control requests on endpoints other than 0
[libusbx.git] / configure.ac
blob3dcb02d72c140d0ec0be799634dceba039a135c1
1 m4_define(LIBUSB_MAJOR, [1])
2 m4_define(LIBUSB_MINOR, [0])
3 m4_define(LIBUSB_MICRO, [8])
5 AC_INIT([libusb], LIBUSB_MAJOR.LIBUSB_MINOR.LIBUSB_MICRO, [libusb-devel@lists.sourceforge.net], [libusb], [http://www.libusb.org/])
7 AC_SUBST([LIBUSB_VERSION_MAJOR], [LIBUSB_MAJOR])
8 AC_SUBST([LIBUSB_VERSION_MINOR], [LIBUSB_MINOR])
9 AC_SUBST([LIBUSB_VERSION_MICRO], [LIBUSB_MICRO])
11 # Library versioning
12 # These numbers should be tweaked on every release. Read carefully:
13 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
14 # http://sourceware.org/autobook/autobook/autobook_91.html
15 lt_current="1"
16 lt_revision="0"
17 lt_age="1"
18 AC_SUBST(lt_current)
19 AC_SUBST(lt_revision)
20 AC_SUBST(lt_age)
22 AM_INIT_AUTOMAKE
23 AC_CONFIG_SRCDIR([libusb/core.c])
24 AC_CONFIG_MACRO_DIR([m4])
25 AM_CONFIG_HEADER([config.h])
26 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
28 AC_PREREQ([2.50])
29 AC_PROG_CC
30 AC_PROG_LIBTOOL
31 AC_C_INLINE
32 AM_PROG_CC_C_O
33 AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions])
35 AM_MAINTAINER_MODE
37 AC_MSG_CHECKING([operating system])
38 PC_LIBS_PRIVATE=
39 case $host in
40 *-linux*)
41         AC_DEFINE(OS_LINUX, [], [Linux backend])
42         AC_SUBST(OS_LINUX)
43         AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads])
44         AC_MSG_RESULT([Linux])
45         backend="linux"
46         AC_CHECK_LIB(rt, clock_gettime, PC_LIBS_PRIVATE="-lrt")
47         LIBS="${LIBS} ${PC_LIBS_PRIVATE}"
48         threads="posix"
49         THREAD_CFLAGS="-pthread"
50         PC_LIBS_PRIVATE="${PC_LIBS_PRIVATE} -pthread"
51         AM_LDFLAGS=""
52         ;;
53 *-darwin*)
54         AC_DEFINE(OS_DARWIN, [], [Darwin backend])
55         AC_SUBST(OS_DARWIN)
56         AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads])
57         AC_MSG_RESULT([Darwin/MacOS X])
58         backend="darwin"
59         threads="posix"
60         THREAD_CFLAGS="-pthread"
61         PC_LIBS_PRIVATE="-Wl,-framework,IOKit -Wl,-framework,CoreFoundation -Wl,-prebind -no-undefined -pthread"
62         AM_LDFLAGS=${PC_LIBS_PRIVATE}
64 *-mingw*)
65         AC_DEFINE(OS_WINDOWS, [], [Windows backend])
66         AC_SUBST(OS_WINDOWS)
67         AC_MSG_RESULT([Windows])
68         backend="windows"
69         threads="windows"
70         PC_LIBS_PRIVATE="-lsetupapi -lole32 -ladvapi32"
71         LIBS="${LIBS} ${PC_LIBS_PRIVATE}"
72         # -avoid-version to avoid a naming scheme such as libusb-0.dll
73         AM_LDFLAGS="-no-undefined -avoid-version --add-stdcall-alias"
74         AC_CHECK_TOOL(RC, windres, no)
75         ;;
76 *-cygwin*)
77         AC_DEFINE(OS_WINDOWS, [], [Windows backend])
78         AC_SUBST(OS_WINDOWS)
79         AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads])
80         AC_MSG_RESULT([Windows])
81         backend="windows"
82         threads="posix"
83         PC_LIBS_PRIVATE="-lsetupapi -lole32 -ladvapi32"
84         LIBS="${LIBS} ${PC_LIBS_PRIVATE}"
85         AM_LDFLAGS="-no-undefined -avoid-version"
86         AC_CHECK_TOOL(RC, windres, no)
87         ;;
89         AC_MSG_ERROR([unsupported operating system])
90 esac
91 AC_SUBST(PC_LIBS_PRIVATE)
93 AM_CONDITIONAL([OS_LINUX], [test "x$backend" = "xlinux"])
94 AM_CONDITIONAL([OS_DARWIN], [test "x$backend" = "xdarwin"])
95 AM_CONDITIONAL([OS_WINDOWS], [test "x$backend" = "xwindows"])
96 AM_CONDITIONAL([THREADS_POSIX], [test "x$threads" = "xposix"])
98 # timerfd
99 AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
100 AC_ARG_ENABLE([timerfd],
101         [AS_HELP_STRING([--enable-timerfd],
102                 [use timerfd for timing (default auto)])],
103         [use_timerfd=$enableval], [use_timerfd='auto'])
105 if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then
106         AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
109 AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>])
110 if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then
111         AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
114 AC_MSG_CHECKING([whether to use timerfd for timing])
115 if test "x$use_timerfd" = "xno"; then
116         AC_MSG_RESULT([no (disabled by user)])
117 else
118         if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then
119                 AC_MSG_RESULT([yes])
120                 AC_DEFINE(USBI_TIMERFD_AVAILABLE, [], [timerfd headers available])
121         else
122                 AC_MSG_RESULT([no (header not available)])
123         fi
126 AC_CHECK_TYPES(struct timespec)
128 # Message logging
129 AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
130         [log_enabled=$enableval],
131         [log_enabled='yes'])
132 if test "x$log_enabled" != "xno"; then
133         AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
136 AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
137         [enable debug logging (default n)])],
138         [debug_log_enabled=$enableval],
139         [debug_log_enabled='no'])
140 if test "x$debug_log_enabled" != "xno"; then
141         AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging])
144 # Examples build
145 AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
146         [build example applications (default n)])],
147         [build_examples=$enableval],
148         [build_examples='no'])
149 AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
151 # Restore gnu89 inline semantics on gcc 4.3 and newer
152 saved_cflags="$CFLAGS"
153 CFLAGS="$CFLAGS -fgnu89-inline"
154 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="")
155 CFLAGS="$saved_cflags"
157 # check for -fvisibility=hidden compiler support (GCC >= 3.4)
158 saved_cflags="$CFLAGS"
159 # -Werror required for cygwin
160 CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
161 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
162         [VISIBILITY_CFLAGS="-fvisibility=hidden"
163          AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility]) ],
164         [ VISIBILITY_CFLAGS=""
165          AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility]) ],
166         ])
167 CFLAGS="$saved_cflags"
169 # check for -Wno-pointer-sign compiler support (GCC >= 4)
170 saved_cflags="$CFLAGS"
171 CFLAGS="$CFLAGS -Wno-pointer-sign"
172 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
173         nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
174 CFLAGS="$saved_cflags"
176 # sigaction not available on MinGW
177 AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no])
178 AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = "xyes"])
180 # headers not available on all platforms but required on others
181 AC_CHECK_HEADERS([sys/time.h])
183 AC_SUBST([THREAD_CFLAGS])
185 AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow"
187 AC_SUBST(VISIBILITY_CFLAGS)
188 AC_SUBST(AM_CFLAGS)
189 AC_SUBST(AM_LDFLAGS)
191 AC_CONFIG_FILES([libusb-1.0.pc] [Makefile] [libusb/Makefile] [libusb/libusb-1.0.rc] [examples/Makefile] [doc/Makefile] [doc/doxygen.cfg])
192 AC_OUTPUT