Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 1 | m4_define(LIBUSB_MAJOR, [1]) |
| 2 | m4_define(LIBUSB_MINOR, [0]) |
| 3 | m4_define(LIBUSB_MICRO, [8]) |
| 4 | |
Daniel Drake | d192c5b | 2010-10-04 18:45:18 +0100 | [diff] [blame^] | 5 | # 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 |
| 9 | lt_current="1" |
| 10 | lt_revision="0" |
| 11 | lt_age="1" |
| 12 | |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 13 | AC_INIT([libusb], LIBUSB_MAJOR.LIBUSB_MINOR.LIBUSB_MICRO, [libusb-devel@lists.sourceforge.net], [libusb], [http://www.libusb.org/]) |
| 14 | |
| 15 | AC_SUBST([LIBUSB_VERSION_MAJOR], [LIBUSB_MAJOR]) |
| 16 | AC_SUBST([LIBUSB_VERSION_MINOR], [LIBUSB_MINOR]) |
| 17 | AC_SUBST([LIBUSB_VERSION_MICRO], [LIBUSB_MICRO]) |
Daniel Drake | d192c5b | 2010-10-04 18:45:18 +0100 | [diff] [blame^] | 18 | AC_SUBST(lt_current) |
| 19 | AC_SUBST(lt_revision) |
| 20 | AC_SUBST(lt_age) |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 21 | |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 22 | AM_INIT_AUTOMAKE |
Daniel Drake | e9364d7 | 2008-01-04 00:40:49 +0000 | [diff] [blame] | 23 | AC_CONFIG_SRCDIR([libusb/core.c]) |
Daniel Drake | 8be2560 | 2009-06-13 17:19:07 +0100 | [diff] [blame] | 24 | AC_CONFIG_MACRO_DIR([m4]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 25 | AM_CONFIG_HEADER([config.h]) |
Daniel Drake | 9b120c2 | 2009-11-07 10:03:07 +0000 | [diff] [blame] | 26 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 27 | |
| 28 | AC_PREREQ([2.50]) |
| 29 | AC_PROG_CC |
| 30 | AC_PROG_LIBTOOL |
| 31 | AC_C_INLINE |
| 32 | AM_PROG_CC_C_O |
Daniel Drake | 637a8d7 | 2008-01-30 13:19:10 +0000 | [diff] [blame] | 33 | AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 34 | |
Ludovic Rousseau | 351c062 | 2010-04-21 16:49:33 +0200 | [diff] [blame] | 35 | AM_MAINTAINER_MODE |
| 36 | |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 37 | AC_MSG_CHECKING([operating system]) |
| 38 | case $host in |
| 39 | *-linux*) |
| 40 | AC_DEFINE(OS_LINUX, [], [Linux backend]) |
| 41 | AC_SUBST(OS_LINUX) |
Pete Batard | 33cd2f6 | 2010-07-30 00:23:05 +0100 | [diff] [blame] | 42 | AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads]) |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 43 | AC_MSG_RESULT([Linux]) |
| 44 | backend="linux" |
Nathan Hjelm | ccf6d3d | 2009-02-16 21:13:52 -0300 | [diff] [blame] | 45 | AC_CHECK_LIB(rt, clock_gettime) |
Peter Stuge | 23b5db8 | 2010-05-11 00:51:43 +0100 | [diff] [blame] | 46 | threads="posix" |
| 47 | THREAD_CFLAGS="-pthread" |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 48 | AM_LDFLAGS="" |
| 49 | ;; |
| 50 | *-darwin*) |
| 51 | AC_DEFINE(OS_DARWIN, [], [Darwin backend]) |
| 52 | AC_SUBST(OS_DARWIN) |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 53 | AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads]) |
Nathan Hjelm | 86f79fb | 2009-06-19 22:18:44 +0100 | [diff] [blame] | 54 | AC_DEFINE(USBI_OS_HANDLES_TIMEOUT, [], [Backend handles timeout]) |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 55 | AC_MSG_RESULT([Darwin/MacOS X]) |
| 56 | backend="darwin" |
Peter Stuge | 23b5db8 | 2010-05-11 00:51:43 +0100 | [diff] [blame] | 57 | threads="posix" |
| 58 | THREAD_CFLAGS="-pthread" |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 59 | AM_LDFLAGS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -no-undefined" |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 60 | ;; |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 61 | *-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 Drake | bd623f7 | 2010-09-19 14:21:01 +0100 | [diff] [blame] | 69 | AM_LDFLAGS="-no-undefined -avoid-version --add-stdcall-alias" |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 70 | 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 Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 83 | *) |
| 84 | AC_MSG_ERROR([unsupported operating system]) |
| 85 | esac |
| 86 | |
Aurelien Jarno | a1d831e | 2010-05-25 09:32:19 +0200 | [diff] [blame] | 87 | AM_CONDITIONAL([OS_LINUX], [test "x$backend" = "xlinux"]) |
| 88 | AM_CONDITIONAL([OS_DARWIN], [test "x$backend" = "xdarwin"]) |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 89 | AM_CONDITIONAL([OS_WINDOWS], [test "x$backend" = "xwindows"]) |
Aurelien Jarno | a1d831e | 2010-05-25 09:32:19 +0200 | [diff] [blame] | 90 | AM_CONDITIONAL([THREADS_POSIX], [test "x$threads" = "xposix"]) |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 91 | |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 92 | # timerfd |
| 93 | AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0]) |
| 94 | AC_ARG_ENABLE([timerfd], |
| 95 | [AS_HELP_STRING([--enable-timerfd], |
| 96 | [use timerfd for timing (default auto)])], |
| 97 | [use_timerfd=$enableval], [use_timerfd='auto']) |
| 98 | |
| 99 | if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then |
Daniel Drake | 0bd7ef5 | 2009-11-21 16:57:25 +0000 | [diff] [blame] | 100 | AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required]) |
| 101 | fi |
| 102 | |
| 103 | AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>]) |
| 104 | if 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 Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 106 | fi |
| 107 | |
| 108 | AC_MSG_CHECKING([whether to use timerfd for timing]) |
| 109 | if test "x$use_timerfd" = "xno"; then |
| 110 | AC_MSG_RESULT([no (disabled by user)]) |
| 111 | else |
Daniel Drake | 0bd7ef5 | 2009-11-21 16:57:25 +0000 | [diff] [blame] | 112 | if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 113 | 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 |
| 118 | fi |
| 119 | |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 120 | AC_CHECK_TYPES(struct timespec) |
| 121 | |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 122 | # Message logging |
| 123 | AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])], |
| 124 | [log_enabled=$enableval], |
| 125 | [log_enabled='yes']) |
| 126 | if test "x$log_enabled" != "xno"; then |
| 127 | AC_DEFINE([ENABLE_LOGGING], 1, [Message logging]) |
| 128 | fi |
| 129 | |
| 130 | AC_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']) |
| 134 | if test "x$debug_log_enabled" != "xno"; then |
| 135 | AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging]) |
| 136 | fi |
| 137 | |
| 138 | # Examples build |
| 139 | AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build], |
| 140 | [build example applications (default n)])], |
| 141 | [build_examples=$enableval], |
| 142 | [build_examples='no']) |
| 143 | AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"]) |
| 144 | |
Daniel Drake | 37b7f9a | 2008-01-26 14:03:43 +0000 | [diff] [blame] | 145 | # Restore gnu89 inline semantics on gcc 4.3 and newer |
| 146 | saved_cflags="$CFLAGS" |
| 147 | CFLAGS="$CFLAGS -fgnu89-inline" |
| 148 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="") |
| 149 | CFLAGS="$saved_cflags" |
| 150 | |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 151 | # check for -fvisibility=hidden compiler support (GCC >= 3.4) |
| 152 | saved_cflags="$CFLAGS" |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 153 | # -Werror required for cygwin |
| 154 | CFLAGS="$CFLAGS -Werror -fvisibility=hidden" |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 155 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), |
| 156 | [VISIBILITY_CFLAGS="-fvisibility=hidden" |
Pete Batard | 29f9f9e | 2010-08-13 11:59:49 +0100 | [diff] [blame] | 157 | AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility]) ], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 158 | [ VISIBILITY_CFLAGS="" |
Pete Batard | 29f9f9e | 2010-08-13 11:59:49 +0100 | [diff] [blame] | 159 | AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility]) ], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 160 | ]) |
| 161 | CFLAGS="$saved_cflags" |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 162 | |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 163 | # check for -Wno-pointer-sign compiler support (GCC >= 4) |
| 164 | saved_cflags="$CFLAGS" |
| 165 | CFLAGS="$CFLAGS -Wno-pointer-sign" |
| 166 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), |
| 167 | nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="") |
| 168 | CFLAGS="$saved_cflags" |
| 169 | |
Daniel Drake | a516fcb | 2010-07-21 17:49:21 -0600 | [diff] [blame] | 170 | # sigaction not available on MinGW |
| 171 | AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no]) |
| 172 | AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = "xyes"]) |
| 173 | |
Daniel Drake | 7211aba | 2010-06-25 12:01:58 -0500 | [diff] [blame] | 174 | # headers not available on all platforms but required on others |
| 175 | AC_CHECK_HEADERS([sys/time.h]) |
| 176 | |
Peter Stuge | 23b5db8 | 2010-05-11 00:51:43 +0100 | [diff] [blame] | 177 | AC_SUBST([THREAD_CFLAGS]) |
| 178 | |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 179 | AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow" |
| 180 | |
| 181 | AC_SUBST(VISIBILITY_CFLAGS) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 182 | AC_SUBST(AM_CFLAGS) |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 183 | AC_SUBST(AM_LDFLAGS) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 184 | |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 185 | AC_CONFIG_FILES([libusb-1.0.pc] [Makefile] [libusb/Makefile] [libusb/libusb-1.0.rc] [examples/Makefile] [doc/Makefile] [doc/doxygen.cfg]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 186 | AC_OUTPUT |
| 187 | |