blob: 38e9ce7431b4ae3e27fbc67d358c902f095f751b [file] [log] [blame]
Pete Batard9a4249f2010-07-10 17:51:13 -06001m4_define(LIBUSB_MAJOR, [1])
2m4_define(LIBUSB_MINOR, [0])
3m4_define(LIBUSB_MICRO, [8])
4
Daniel Draked192c5b2010-10-04 18:45:18 +01005# Library versioning
6# These numbers should be tweaked on every release. Read carefully:
7# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
8# http://sourceware.org/autobook/autobook/autobook_91.html
9lt_current="1"
10lt_revision="0"
11lt_age="1"
12
Pete Batard9a4249f2010-07-10 17:51:13 -060013AC_INIT([libusb], LIBUSB_MAJOR.LIBUSB_MINOR.LIBUSB_MICRO, [libusb-devel@lists.sourceforge.net], [libusb], [http://www.libusb.org/])
14
15AC_SUBST([LIBUSB_VERSION_MAJOR], [LIBUSB_MAJOR])
16AC_SUBST([LIBUSB_VERSION_MINOR], [LIBUSB_MINOR])
17AC_SUBST([LIBUSB_VERSION_MICRO], [LIBUSB_MICRO])
Daniel Draked192c5b2010-10-04 18:45:18 +010018AC_SUBST(lt_current)
19AC_SUBST(lt_revision)
20AC_SUBST(lt_age)
Pete Batard9a4249f2010-07-10 17:51:13 -060021
Daniel Drake852bba42007-11-28 13:48:45 +000022AM_INIT_AUTOMAKE
Daniel Drakee9364d72008-01-04 00:40:49 +000023AC_CONFIG_SRCDIR([libusb/core.c])
Daniel Drake8be25602009-06-13 17:19:07 +010024AC_CONFIG_MACRO_DIR([m4])
Daniel Drake852bba42007-11-28 13:48:45 +000025AM_CONFIG_HEADER([config.h])
Daniel Drake9b120c22009-11-07 10:03:07 +000026m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
Daniel Drake852bba42007-11-28 13:48:45 +000027
28AC_PREREQ([2.50])
29AC_PROG_CC
30AC_PROG_LIBTOOL
31AC_C_INLINE
32AM_PROG_CC_C_O
Daniel Drake637a8d72008-01-30 13:19:10 +000033AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions])
Daniel Drake852bba42007-11-28 13:48:45 +000034
Ludovic Rousseau351c0622010-04-21 16:49:33 +020035AM_MAINTAINER_MODE
36
Daniel Drakec0c94322008-03-13 12:36:56 +000037AC_MSG_CHECKING([operating system])
38case $host in
39*-linux*)
40 AC_DEFINE(OS_LINUX, [], [Linux backend])
41 AC_SUBST(OS_LINUX)
Pete Batard33cd2f62010-07-30 00:23:05 +010042 AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads])
Daniel Drakec0c94322008-03-13 12:36:56 +000043 AC_MSG_RESULT([Linux])
44 backend="linux"
Nathan Hjelmccf6d3d2009-02-16 21:13:52 -030045 AC_CHECK_LIB(rt, clock_gettime)
Peter Stuge23b5db82010-05-11 00:51:43 +010046 threads="posix"
47 THREAD_CFLAGS="-pthread"
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030048 AM_LDFLAGS=""
49 ;;
50*-darwin*)
51 AC_DEFINE(OS_DARWIN, [], [Darwin backend])
52 AC_SUBST(OS_DARWIN)
Pete Batard9a4249f2010-07-10 17:51:13 -060053 AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads])
Nathan Hjelm86f79fb2009-06-19 22:18:44 +010054 AC_DEFINE(USBI_OS_HANDLES_TIMEOUT, [], [Backend handles timeout])
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030055 AC_MSG_RESULT([Darwin/MacOS X])
56 backend="darwin"
Peter Stuge23b5db82010-05-11 00:51:43 +010057 threads="posix"
58 THREAD_CFLAGS="-pthread"
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030059 AM_LDFLAGS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -no-undefined"
Daniel Drakec0c94322008-03-13 12:36:56 +000060 ;;
Pete Batard9a4249f2010-07-10 17:51:13 -060061*-mingw*)
62 AC_DEFINE(OS_WINDOWS, [], [Windows backend])
63 AC_SUBST(OS_WINDOWS)
64 AC_MSG_RESULT([Windows])
65 backend="windows"
66 threads="windows"
67 LIBS="-lsetupapi -lole32 -ladvapi32"
68 # -avoid-version to avoid a naming scheme such as libusb-0.dll
Daniel Drakebd623f72010-09-19 14:21:01 +010069 AM_LDFLAGS="-no-undefined -avoid-version --add-stdcall-alias"
Pete Batard9a4249f2010-07-10 17:51:13 -060070 AC_CHECK_TOOL(RC, windres, no)
71 ;;
72*-cygwin*)
73 AC_DEFINE(OS_WINDOWS, [], [Windows backend])
74 AC_SUBST(OS_WINDOWS)
75 AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads])
76 AC_MSG_RESULT([Windows])
77 backend="windows"
78 threads="posix"
79 LIBS="-lsetupapi -lole32 -ladvapi32"
80 AM_LDFLAGS="-no-undefined -avoid-version"
81 AC_CHECK_TOOL(RC, windres, no)
82 ;;
Daniel Drakec0c94322008-03-13 12:36:56 +000083*)
84 AC_MSG_ERROR([unsupported operating system])
85esac
86
Aurelien Jarnoa1d831e2010-05-25 09:32:19 +020087AM_CONDITIONAL([OS_LINUX], [test "x$backend" = "xlinux"])
88AM_CONDITIONAL([OS_DARWIN], [test "x$backend" = "xdarwin"])
Pete Batard9a4249f2010-07-10 17:51:13 -060089AM_CONDITIONAL([OS_WINDOWS], [test "x$backend" = "xwindows"])
Aurelien Jarnoa1d831e2010-05-25 09:32:19 +020090AM_CONDITIONAL([THREADS_POSIX], [test "x$threads" = "xposix"])
Daniel Drakec0c94322008-03-13 12:36:56 +000091
Daniel Drake47830082009-10-28 20:33:49 +054592# timerfd
93AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
94AC_ARG_ENABLE([timerfd],
95 [AS_HELP_STRING([--enable-timerfd],
96 [use timerfd for timing (default auto)])],
97 [use_timerfd=$enableval], [use_timerfd='auto'])
98
99if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then
Daniel Drake0bd7ef52009-11-21 16:57:25 +0000100 AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
101fi
102
103AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>])
104if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then
105 AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
Daniel Drake47830082009-10-28 20:33:49 +0545106fi
107
108AC_MSG_CHECKING([whether to use timerfd for timing])
109if test "x$use_timerfd" = "xno"; then
110 AC_MSG_RESULT([no (disabled by user)])
111else
Daniel Drake0bd7ef52009-11-21 16:57:25 +0000112 if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then
Daniel Drake47830082009-10-28 20:33:49 +0545113 AC_MSG_RESULT([yes])
114 AC_DEFINE(USBI_TIMERFD_AVAILABLE, [], [timerfd headers available])
115 else
116 AC_MSG_RESULT([no (header not available)])
117 fi
118fi
119
Pete Batard9a4249f2010-07-10 17:51:13 -0600120AC_CHECK_TYPES(struct timespec)
121
Daniel Drake852bba42007-11-28 13:48:45 +0000122# Message logging
123AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
124 [log_enabled=$enableval],
125 [log_enabled='yes'])
126if test "x$log_enabled" != "xno"; then
127 AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
128fi
129
130AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
131 [enable debug logging (default n)])],
132 [debug_log_enabled=$enableval],
133 [debug_log_enabled='no'])
134if test "x$debug_log_enabled" != "xno"; then
135 AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging])
136fi
137
138# Examples build
139AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
140 [build example applications (default n)])],
141 [build_examples=$enableval],
142 [build_examples='no'])
143AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
144
Daniel Drake37b7f9a2008-01-26 14:03:43 +0000145# Restore gnu89 inline semantics on gcc 4.3 and newer
146saved_cflags="$CFLAGS"
147CFLAGS="$CFLAGS -fgnu89-inline"
148AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="")
149CFLAGS="$saved_cflags"
150
Alex Vatchenkob5017952009-05-28 15:58:50 -0400151# check for -fvisibility=hidden compiler support (GCC >= 3.4)
152saved_cflags="$CFLAGS"
Pete Batard9a4249f2010-07-10 17:51:13 -0600153# -Werror required for cygwin
154CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
Alex Vatchenkob5017952009-05-28 15:58:50 -0400155AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
156 [VISIBILITY_CFLAGS="-fvisibility=hidden"
Pete Batard29f9f9e2010-08-13 11:59:49 +0100157 AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility]) ],
Alex Vatchenkob5017952009-05-28 15:58:50 -0400158 [ VISIBILITY_CFLAGS=""
Pete Batard29f9f9e2010-08-13 11:59:49 +0100159 AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility]) ],
Alex Vatchenkob5017952009-05-28 15:58:50 -0400160 ])
161CFLAGS="$saved_cflags"
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -0300162
Alex Vatchenkob5017952009-05-28 15:58:50 -0400163# check for -Wno-pointer-sign compiler support (GCC >= 4)
164saved_cflags="$CFLAGS"
165CFLAGS="$CFLAGS -Wno-pointer-sign"
166AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
167 nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
168CFLAGS="$saved_cflags"
169
Daniel Drakea516fcb2010-07-21 17:49:21 -0600170# sigaction not available on MinGW
171AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no])
172AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = "xyes"])
173
Daniel Drake7211aba2010-06-25 12:01:58 -0500174# headers not available on all platforms but required on others
175AC_CHECK_HEADERS([sys/time.h])
176
Peter Stuge23b5db82010-05-11 00:51:43 +0100177AC_SUBST([THREAD_CFLAGS])
178
Alex Vatchenkob5017952009-05-28 15:58:50 -0400179AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow"
180
181AC_SUBST(VISIBILITY_CFLAGS)
Daniel Drake852bba42007-11-28 13:48:45 +0000182AC_SUBST(AM_CFLAGS)
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -0300183AC_SUBST(AM_LDFLAGS)
Daniel Drake852bba42007-11-28 13:48:45 +0000184
Pete Batard9a4249f2010-07-10 17:51:13 -0600185AC_CONFIG_FILES([libusb-1.0.pc] [Makefile] [libusb/Makefile] [libusb/libusb-1.0.rc] [examples/Makefile] [doc/Makefile] [doc/doxygen.cfg])
Daniel Drake852bba42007-11-28 13:48:45 +0000186AC_OUTPUT
187