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])
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
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])])
33 AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions])
37 AC_MSG_CHECKING([operating system])
41 AC_DEFINE(OS_LINUX, [], [Linux backend])
43 AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads])
44 AC_MSG_RESULT([Linux])
46 AC_CHECK_LIB(rt, clock_gettime, PC_LIBS_PRIVATE="-lrt")
47 LIBS="${LIBS} ${PC_LIBS_PRIVATE}"
49 THREAD_CFLAGS="-pthread"
50 PC_LIBS_PRIVATE="${PC_LIBS_PRIVATE} -pthread"
54 AC_DEFINE(OS_DARWIN, [], [Darwin backend])
56 AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads])
57 AC_MSG_RESULT([Darwin/MacOS X])
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}
65 AC_DEFINE(OS_WINDOWS, [], [Windows backend])
67 AC_MSG_RESULT([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)
77 AC_DEFINE(OS_WINDOWS, [], [Windows backend])
79 AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads])
80 AC_MSG_RESULT([Windows])
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)
89 AC_MSG_ERROR([unsupported operating system])
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"])
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)])
118 if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then
120 AC_DEFINE(USBI_TIMERFD_AVAILABLE, [], [timerfd headers available])
122 AC_MSG_RESULT([no (header not available)])
126 AC_CHECK_TYPES(struct timespec)
129 AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
130 [log_enabled=$enableval],
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])
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]) ],
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)
191 AC_CONFIG_FILES([libusb-1.0.pc] [Makefile] [libusb/Makefile] [libusb/libusb-1.0.rc] [examples/Makefile] [doc/Makefile] [doc/doxygen.cfg])