Peter Stuge | 85a14f4 | 2011-05-09 08:12:24 +0200 | [diff] [blame] | 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]))]) |
Peter Stuge | cbc2d7b | 2011-09-15 16:48:35 +0200 | [diff] [blame] | 6 | m4_define([LU_DEFINE_VERSION_RC_ATOM], |
| 7 | [m4_define([$1], m4_bregexp(LU_VERSION_H, |
| 8 | [^#define\s*$1\s*"\(-rc[0-9]*\)".*], [\1]))]) |
Peter Stuge | 85a14f4 | 2011-05-09 08:12:24 +0200 | [diff] [blame] | 9 | dnl The m4_bregexp() returns (only) the numbers following the #define named |
| 10 | dnl in the first macro parameter. m4_define() then defines the name for use |
| 11 | dnl in AC_INIT(). |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 12 | |
Peter Stuge | 85a14f4 | 2011-05-09 08:12:24 +0200 | [diff] [blame] | 13 | LU_DEFINE_VERSION_ATOM([LIBUSB_MAJOR]) |
| 14 | LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR]) |
| 15 | LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO]) |
Peter Stuge | cbc2d7b | 2011-09-15 16:48:35 +0200 | [diff] [blame] | 16 | LU_DEFINE_VERSION_RC_ATOM([LIBUSB_RC]) |
Daniel Drake | d7c2545 | 2010-10-04 20:03:58 +0100 | [diff] [blame] | 17 | |
Peter Stuge | cbc2d7b | 2011-09-15 16:48:35 +0200 | [diff] [blame] | 18 | AC_INIT([libusb], LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC, [libusb-devel@lists.sourceforge.net], [libusb], [http://www.libusb.org/]) |
Daniel Drake | d7c2545 | 2010-10-04 20:03:58 +0100 | [diff] [blame] | 19 | |
Daniel Drake | d192c5b | 2010-10-04 18:45:18 +0100 | [diff] [blame] | 20 | # Library versioning |
| 21 | # These numbers should be tweaked on every release. Read carefully: |
| 22 | # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html |
| 23 | # http://sourceware.org/autobook/autobook/autobook_91.html |
| 24 | lt_current="1" |
| 25 | lt_revision="0" |
| 26 | lt_age="1" |
Peter Stuge | 717f476 | 2010-11-15 19:58:51 +0100 | [diff] [blame] | 27 | LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}" |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 28 | |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 29 | AM_INIT_AUTOMAKE |
Peter Stuge | 6e52ea0 | 2010-11-21 23:37:27 +0100 | [diff] [blame] | 30 | AM_MAINTAINER_MODE |
| 31 | |
Daniel Drake | e9364d7 | 2008-01-04 00:40:49 +0000 | [diff] [blame] | 32 | AC_CONFIG_SRCDIR([libusb/core.c]) |
Daniel Drake | 8be2560 | 2009-06-13 17:19:07 +0100 | [diff] [blame] | 33 | AC_CONFIG_MACRO_DIR([m4]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 34 | AM_CONFIG_HEADER([config.h]) |
Daniel Drake | 9b120c2 | 2009-11-07 10:03:07 +0000 | [diff] [blame] | 35 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 36 | |
| 37 | AC_PREREQ([2.50]) |
| 38 | AC_PROG_CC |
| 39 | AC_PROG_LIBTOOL |
Peter Stuge | fa9b682 | 2011-09-22 21:17:37 +0200 | [diff] [blame] | 40 | LT_LANG([Windows Resource]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 41 | AC_C_INLINE |
| 42 | AM_PROG_CC_C_O |
Peter Stuge | 19d5882 | 2010-11-21 23:09:02 +0100 | [diff] [blame] | 43 | AC_DEFINE([_GNU_SOURCE], 1, [Use GNU extensions]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 44 | |
Peter Stuge | 717f476 | 2010-11-15 19:58:51 +0100 | [diff] [blame] | 45 | LTLDFLAGS="${LTLDFLAGS} -no-undefined" |
| 46 | |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 47 | AC_MSG_CHECKING([operating system]) |
| 48 | case $host in |
| 49 | *-linux*) |
Peter Stuge | 19d5882 | 2010-11-21 23:09:02 +0100 | [diff] [blame] | 50 | AC_DEFINE(OS_LINUX, 1, [Linux backend]) |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 51 | AC_SUBST(OS_LINUX) |
| 52 | AC_MSG_RESULT([Linux]) |
| 53 | backend="linux" |
Mike Frysinger | a6fb54e | 2010-10-04 20:01:07 +0100 | [diff] [blame] | 54 | AC_CHECK_LIB(rt, clock_gettime, PC_LIBS_PRIVATE="-lrt") |
Peter Stuge | 23b5db8 | 2010-05-11 00:51:43 +0100 | [diff] [blame] | 55 | threads="posix" |
| 56 | THREAD_CFLAGS="-pthread" |
Mike Frysinger | a6fb54e | 2010-10-04 20:01:07 +0100 | [diff] [blame] | 57 | PC_LIBS_PRIVATE="${PC_LIBS_PRIVATE} -pthread" |
Peter Stuge | a120747 | 2010-10-30 22:07:37 +0200 | [diff] [blame] | 58 | AC_CHECK_HEADERS([poll.h]) |
| 59 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument]) |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 60 | ;; |
| 61 | *-darwin*) |
Peter Stuge | 19d5882 | 2010-11-21 23:09:02 +0100 | [diff] [blame] | 62 | AC_DEFINE(OS_DARWIN, 1, [Darwin backend]) |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 63 | AC_SUBST(OS_DARWIN) |
Peter Stuge | 0bd4a4d | 2011-02-26 04:08:38 +0100 | [diff] [blame] | 64 | AC_MSG_RESULT([Darwin/Mac OS X]) |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 65 | backend="darwin" |
Peter Stuge | 23b5db8 | 2010-05-11 00:51:43 +0100 | [diff] [blame] | 66 | threads="posix" |
Xiaofan Chen | d228574 | 2012-01-13 18:07:34 +0100 | [diff] [blame] | 67 | PC_LIBS_PRIVATE="-lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation" |
Peter Stuge | 717f476 | 2010-11-15 19:58:51 +0100 | [diff] [blame] | 68 | LTLDFLAGS="${LTLDFLAGS} -Wl,-prebind" |
Peter Stuge | a120747 | 2010-10-30 22:07:37 +0200 | [diff] [blame] | 69 | AC_CHECK_HEADERS([poll.h]) |
| 70 | AC_CHECK_TYPE([nfds_t], |
| 71 | [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])], |
| 72 | [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])], |
| 73 | [#include <poll.h>]) |
Peter Stuge | 6e52ea0 | 2010-11-21 23:37:27 +0100 | [diff] [blame] | 74 | ;; |
Martin Pieuchot | c568288 | 2012-01-30 09:59:30 +0100 | [diff] [blame] | 75 | *-openbsd*) |
| 76 | AC_DEFINE(OS_OPENBSD, 1, [OpenBSD backend]) |
| 77 | AC_SUBST(OS_OPENBSD) |
| 78 | AC_MSG_RESULT([OpenBSD]) |
| 79 | backend="openbsd" |
| 80 | threads="posix" |
| 81 | THREAD_CFLAGS="-pthread" |
| 82 | PC_LIBS_PRIVATE="-pthread" |
| 83 | AC_CHECK_HEADERS([poll.h]) |
| 84 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument]) |
| 85 | ;; |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 86 | *-mingw*) |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 87 | AC_MSG_RESULT([Windows]) |
| 88 | backend="windows" |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 89 | ;; |
| 90 | *-cygwin*) |
Peter Stuge | 0bd4a4d | 2011-02-26 04:08:38 +0100 | [diff] [blame] | 91 | AC_MSG_RESULT([Cygwin (using Windows backend)]) |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 92 | backend="windows" |
| 93 | threads="posix" |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 94 | ;; |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 95 | *) |
| 96 | AC_MSG_ERROR([unsupported operating system]) |
| 97 | esac |
Peter Stuge | 1a2d21f | 2011-02-26 04:21:05 +0100 | [diff] [blame] | 98 | if test "$backend" = windows; then |
| 99 | AC_DEFINE(OS_WINDOWS, 1, [Windows backend]) |
| 100 | AC_SUBST(OS_WINDOWS) |
Pete Batard | ae675c1 | 2011-03-08 17:16:23 +0000 | [diff] [blame] | 101 | PC_LIBS_PRIVATE="" |
Peter Stuge | 1a2d21f | 2011-02-26 04:21:05 +0100 | [diff] [blame] | 102 | LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias" |
| 103 | AC_CHECK_TOOL(RC, windres, no) |
| 104 | AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument]) |
| 105 | fi |
Peter Stuge | 6e52ea0 | 2010-11-21 23:37:27 +0100 | [diff] [blame] | 106 | AC_SUBST(THREAD_CFLAGS) |
Mike Frysinger | a6fb54e | 2010-10-04 20:01:07 +0100 | [diff] [blame] | 107 | AC_SUBST(PC_LIBS_PRIVATE) |
Peter Stuge | c24649d | 2010-10-30 22:28:59 +0200 | [diff] [blame] | 108 | LIBS="${LIBS} ${PC_LIBS_PRIVATE}" |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 109 | |
Peter Stuge | c24649d | 2010-10-30 22:28:59 +0200 | [diff] [blame] | 110 | AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux) |
| 111 | AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin) |
Martin Pieuchot | c568288 | 2012-01-30 09:59:30 +0100 | [diff] [blame] | 112 | AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xopenbsd) |
Peter Stuge | c24649d | 2010-10-30 22:28:59 +0200 | [diff] [blame] | 113 | AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows) |
| 114 | AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix) |
| 115 | if test "$threads" = posix; then |
| 116 | AC_DEFINE(THREADS_POSIX, 1, [Use POSIX Threads]) |
| 117 | fi |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 118 | |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 119 | # timerfd |
| 120 | AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0]) |
| 121 | AC_ARG_ENABLE([timerfd], |
| 122 | [AS_HELP_STRING([--enable-timerfd], |
| 123 | [use timerfd for timing (default auto)])], |
| 124 | [use_timerfd=$enableval], [use_timerfd='auto']) |
| 125 | |
| 126 | if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then |
Daniel Drake | 0bd7ef5 | 2009-11-21 16:57:25 +0000 | [diff] [blame] | 127 | AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required]) |
| 128 | fi |
| 129 | |
| 130 | AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>]) |
| 131 | if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then |
| 132 | AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required]) |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 133 | fi |
| 134 | |
| 135 | AC_MSG_CHECKING([whether to use timerfd for timing]) |
| 136 | if test "x$use_timerfd" = "xno"; then |
| 137 | AC_MSG_RESULT([no (disabled by user)]) |
| 138 | else |
Daniel Drake | 0bd7ef5 | 2009-11-21 16:57:25 +0000 | [diff] [blame] | 139 | 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] | 140 | AC_MSG_RESULT([yes]) |
Peter Stuge | 19d5882 | 2010-11-21 23:09:02 +0100 | [diff] [blame] | 141 | AC_DEFINE(USBI_TIMERFD_AVAILABLE, 1, [timerfd headers available]) |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 142 | else |
| 143 | AC_MSG_RESULT([no (header not available)]) |
| 144 | fi |
| 145 | fi |
| 146 | |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 147 | AC_CHECK_TYPES(struct timespec) |
| 148 | |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 149 | # Message logging |
| 150 | AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])], |
| 151 | [log_enabled=$enableval], |
| 152 | [log_enabled='yes']) |
| 153 | if test "x$log_enabled" != "xno"; then |
| 154 | AC_DEFINE([ENABLE_LOGGING], 1, [Message logging]) |
| 155 | fi |
| 156 | |
| 157 | AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log], |
| 158 | [enable debug logging (default n)])], |
| 159 | [debug_log_enabled=$enableval], |
| 160 | [debug_log_enabled='no']) |
| 161 | if test "x$debug_log_enabled" != "xno"; then |
| 162 | AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging]) |
| 163 | fi |
| 164 | |
| 165 | # Examples build |
| 166 | AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build], |
| 167 | [build example applications (default n)])], |
| 168 | [build_examples=$enableval], |
| 169 | [build_examples='no']) |
| 170 | AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"]) |
| 171 | |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 172 | # check for -fvisibility=hidden compiler support (GCC >= 3.4) |
| 173 | saved_cflags="$CFLAGS" |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 174 | # -Werror required for cygwin |
| 175 | CFLAGS="$CFLAGS -Werror -fvisibility=hidden" |
Peter Stuge | 44b85da | 2010-11-21 23:10:35 +0100 | [diff] [blame] | 176 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 177 | [VISIBILITY_CFLAGS="-fvisibility=hidden" |
Pete Batard | 29f9f9e | 2010-08-13 11:59:49 +0100 | [diff] [blame] | 178 | AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility]) ], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 179 | [ VISIBILITY_CFLAGS="" |
Pete Batard | 29f9f9e | 2010-08-13 11:59:49 +0100 | [diff] [blame] | 180 | AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility]) ], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 181 | ]) |
| 182 | CFLAGS="$saved_cflags" |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 183 | |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 184 | # check for -Wno-pointer-sign compiler support (GCC >= 4) |
| 185 | saved_cflags="$CFLAGS" |
| 186 | CFLAGS="$CFLAGS -Wno-pointer-sign" |
Peter Stuge | 44b85da | 2010-11-21 23:10:35 +0100 | [diff] [blame] | 187 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 188 | nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="") |
| 189 | CFLAGS="$saved_cflags" |
| 190 | |
Daniel Drake | a516fcb | 2010-07-21 17:49:21 -0600 | [diff] [blame] | 191 | # sigaction not available on MinGW |
| 192 | AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no]) |
| 193 | AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = "xyes"]) |
| 194 | |
Daniel Drake | 7211aba | 2010-06-25 12:01:58 -0500 | [diff] [blame] | 195 | # headers not available on all platforms but required on others |
| 196 | AC_CHECK_HEADERS([sys/time.h]) |
| 197 | |
Sean McBride | bb8854f | 2011-06-13 22:26:43 +0200 | [diff] [blame] | 198 | AM_CFLAGS="-std=gnu99 -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow" |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 199 | |
| 200 | AC_SUBST(VISIBILITY_CFLAGS) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 201 | AC_SUBST(AM_CFLAGS) |
Peter Stuge | 717f476 | 2010-11-15 19:58:51 +0100 | [diff] [blame] | 202 | AC_SUBST(LTLDFLAGS) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 203 | |
Peter Stuge | ef39d15 | 2011-02-25 02:33:29 +0100 | [diff] [blame] | 204 | AC_CONFIG_FILES([libusb-1.0.pc]) |
| 205 | AC_CONFIG_FILES([Makefile]) |
| 206 | AC_CONFIG_FILES([libusb/Makefile]) |
Peter Stuge | ef39d15 | 2011-02-25 02:33:29 +0100 | [diff] [blame] | 207 | AC_CONFIG_FILES([examples/Makefile]) |
| 208 | AC_CONFIG_FILES([doc/Makefile]) |
| 209 | AC_CONFIG_FILES([doc/doxygen.cfg]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 210 | AC_OUTPUT |