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 |
Ludovic Rousseau | c9d41fe | 2012-06-01 11:30:00 +0200 | [diff] [blame] | 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 | |
hjelmn@cs.unm.edu | 1eff220 | 2014-01-08 23:50:34 +0000 | [diff] [blame] | 18 | AC_INIT([libusb],[LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC],[libusb-devel@lists.sourceforge.net],[libusb],[http://libusb.info]) |
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]) |
Ludovic Rousseau | c9d41fe | 2012-06-01 11:30:00 +0200 | [diff] [blame] | 34 | AC_CONFIG_HEADERS([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 |
Ludovic Rousseau | c9d41fe | 2012-06-01 11:30:00 +0200 | [diff] [blame] | 39 | LT_INIT |
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]) |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 48 | |
Kuangye Guo | 7e3de5d | 2013-10-21 18:36:15 -0700 | [diff] [blame] | 49 | dnl on linux-android platform, some functions are in different places |
| 50 | case $host in |
| 51 | *-linux-android*) |
| 52 | AC_MSG_RESULT([This is a Linux-Android system]) |
| 53 | is_backend_android="yes" |
| 54 | ;; |
| 55 | *) |
| 56 | is_backend_android="no" |
| 57 | esac |
| 58 | |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 59 | case $host in |
Gustavo Zacarias | 5f36671 | 2013-09-03 10:24:04 -0300 | [diff] [blame] | 60 | *-linux* | *-uclinux*) |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 61 | AC_MSG_RESULT([Linux]) |
| 62 | backend="linux" |
Peter Stuge | 23b5db8 | 2010-05-11 00:51:43 +0100 | [diff] [blame] | 63 | threads="posix" |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 64 | ;; |
| 65 | *-darwin*) |
Peter Stuge | 0bd4a4d | 2011-02-26 04:08:38 +0100 | [diff] [blame] | 66 | AC_MSG_RESULT([Darwin/Mac OS X]) |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 67 | backend="darwin" |
Peter Stuge | 23b5db8 | 2010-05-11 00:51:43 +0100 | [diff] [blame] | 68 | threads="posix" |
Peter Stuge | 6e52ea0 | 2010-11-21 23:37:27 +0100 | [diff] [blame] | 69 | ;; |
Martin Pieuchot | c568288 | 2012-01-30 09:59:30 +0100 | [diff] [blame] | 70 | *-openbsd*) |
Martin Pieuchot | c568288 | 2012-01-30 09:59:30 +0100 | [diff] [blame] | 71 | AC_MSG_RESULT([OpenBSD]) |
Hans de Goede | eb4e7be | 2013-08-21 16:18:39 +0200 | [diff] [blame] | 72 | backend="openbsd" |
Martin Pieuchot | c568288 | 2012-01-30 09:59:30 +0100 | [diff] [blame] | 73 | threads="posix" |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 74 | ;; |
| 75 | *-netbsd*) |
Hans de Goede | eb4e7be | 2013-08-21 16:18:39 +0200 | [diff] [blame] | 76 | AC_MSG_RESULT([NetBSD]) |
| 77 | backend="netbsd" |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 78 | threads="posix" |
Martin Pieuchot | c568288 | 2012-01-30 09:59:30 +0100 | [diff] [blame] | 79 | ;; |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 80 | *-mingw*) |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 81 | AC_MSG_RESULT([Windows]) |
| 82 | backend="windows" |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 83 | threads="windows" |
Pete Batard | 6b33cd4 | 2012-06-08 23:31:56 +0100 | [diff] [blame] | 84 | create_import_lib="yes" |
Pete Batard | ff3259b | 2012-06-07 11:55:30 +0100 | [diff] [blame] | 85 | AM_CFLAGS="${AM_CFLAGS} -fno-omit-frame-pointer" |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 86 | ;; |
| 87 | *-cygwin*) |
Peter Stuge | 0bd4a4d | 2011-02-26 04:08:38 +0100 | [diff] [blame] | 88 | AC_MSG_RESULT([Cygwin (using Windows backend)]) |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 89 | backend="windows" |
| 90 | threads="posix" |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 91 | ;; |
Akshay Jaggi | dc97425 | 2014-09-24 22:46:17 +0100 | [diff] [blame^] | 92 | *-haiku*) |
| 93 | AC_MSG_RESULT([Haiku]) |
| 94 | AC_CONFIG_SUBDIRS([libusb/os/haiku]) |
| 95 | backend="haiku" |
| 96 | threads="posix" |
| 97 | ;; |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 98 | *) |
| 99 | AC_MSG_ERROR([unsupported operating system]) |
| 100 | esac |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 101 | |
| 102 | case $backend in |
| 103 | linux) |
| 104 | AC_DEFINE(OS_LINUX, 1, [Linux backend]) |
| 105 | AC_SUBST(OS_LINUX) |
Peter Stuge | 94b0ccc | 2012-10-23 00:15:23 +0000 | [diff] [blame] | 106 | AC_SEARCH_LIBS(clock_gettime, rt, [], [], -pthread) |
Nathan Hjelm | 6853291 | 2012-11-29 16:14:03 -0700 | [diff] [blame] | 107 | AC_ARG_ENABLE([udev], |
Toby Gray | 9222a54 | 2013-07-09 16:05:39 +0100 | [diff] [blame] | 108 | [AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended) [default=yes]])], |
Nathan Hjelm | 6853291 | 2012-11-29 16:14:03 -0700 | [diff] [blame] | 109 | [], [enable_udev="yes"]) |
| 110 | if test "x$enable_udev" = "xyes" ; then |
| 111 | # system has udev. use it or fail! |
| 112 | AC_CHECK_HEADERS([libudev.h],[],[AC_ERROR(["udev support requested but libudev not installed"])]) |
| 113 | AC_CHECK_LIB([udev], [udev_new], [], [AC_ERROR(["udev support requested but libudev not installed"])]) |
| 114 | AC_DEFINE(USE_UDEV, 1, [Use udev for device enumeration/hotplug]) |
| 115 | else |
Nathan Hjelm | 83021ab | 2013-07-27 12:35:51 -0600 | [diff] [blame] | 116 | AC_CHECK_HEADERS([asm/types.h sys/socket.h], [], []) |
| 117 | AC_CHECK_HEADERS([linux/netlink.h linux/filter.h], [], [AC_ERROR(["Linux netlink headers not found"])], [ |
| 118 | #ifdef HAVE_ASM_TYPES_H |
| 119 | #include <asm/types.h> |
| 120 | #endif |
| 121 | #ifdef HAVE_SYS_SOCKET_H |
| 122 | #include <sys/socket.h> |
| 123 | #endif |
| 124 | ]) |
Nathan Hjelm | 6853291 | 2012-11-29 16:14:03 -0700 | [diff] [blame] | 125 | fi |
| 126 | AC_SUBST(USE_UDEV) |
Kuangye Guo | 7e3de5d | 2013-10-21 18:36:15 -0700 | [diff] [blame] | 127 | |
| 128 | case $is_backend_android in |
| 129 | yes) |
| 130 | dnl some pthread functions is in libc |
| 131 | THREAD_CFLAGS="-c" |
| 132 | LIBS="${LIBS} -c" |
| 133 | dnl there are gettimeofday function but configure doesn't seem to be able to find it. |
| 134 | AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [Define if you have gettimeofday]) |
| 135 | ;; |
| 136 | *) |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 137 | THREAD_CFLAGS="-pthread" |
Peter Stuge | 94b0ccc | 2012-10-23 00:15:23 +0000 | [diff] [blame] | 138 | LIBS="${LIBS} -pthread" |
Kuangye Guo | 7e3de5d | 2013-10-21 18:36:15 -0700 | [diff] [blame] | 139 | esac |
| 140 | |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 141 | AC_CHECK_HEADERS([poll.h]) |
| 142 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument]) |
| 143 | ;; |
| 144 | darwin) |
| 145 | AC_DEFINE(OS_DARWIN, 1, [Darwin backend]) |
| 146 | AC_SUBST(OS_DARWIN) |
Peter Stuge | 94b0ccc | 2012-10-23 00:15:23 +0000 | [diff] [blame] | 147 | LIBS="-lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation" |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 148 | LTLDFLAGS="${LTLDFLAGS} -Wl,-prebind" |
| 149 | AC_CHECK_HEADERS([poll.h]) |
| 150 | AC_CHECK_TYPE([nfds_t], |
| 151 | [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])], |
| 152 | [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])], |
| 153 | [#include <poll.h>]) |
| 154 | ;; |
Hans de Goede | eb4e7be | 2013-08-21 16:18:39 +0200 | [diff] [blame] | 155 | openbsd) |
| 156 | AC_DEFINE(OS_OPENBSD, 1, [OpenBSD backend]) |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 157 | AC_SUBST(OS_OPENBSD) |
| 158 | THREAD_CFLAGS="-pthread" |
Peter Stuge | 94b0ccc | 2012-10-23 00:15:23 +0000 | [diff] [blame] | 159 | LIBS="-pthread" |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 160 | AC_CHECK_HEADERS([poll.h]) |
| 161 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument]) |
| 162 | ;; |
Hans de Goede | eb4e7be | 2013-08-21 16:18:39 +0200 | [diff] [blame] | 163 | netbsd) |
| 164 | AC_DEFINE(OS_NETBSD, 1, [NetBSD backend]) |
| 165 | AC_SUBST(OS_NETBSD) |
| 166 | THREAD_CFLAGS="-pthread" |
| 167 | LIBS="-pthread" |
| 168 | AC_CHECK_HEADERS([poll.h]) |
| 169 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument]) |
| 170 | ;; |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 171 | windows) |
Peter Stuge | 1a2d21f | 2011-02-26 04:21:05 +0100 | [diff] [blame] | 172 | AC_DEFINE(OS_WINDOWS, 1, [Windows backend]) |
| 173 | AC_SUBST(OS_WINDOWS) |
Peter Stuge | 94b0ccc | 2012-10-23 00:15:23 +0000 | [diff] [blame] | 174 | LIBS="" |
Peter Stuge | 1a2d21f | 2011-02-26 04:21:05 +0100 | [diff] [blame] | 175 | LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias" |
Peter Stuge | 1a2d21f | 2011-02-26 04:21:05 +0100 | [diff] [blame] | 176 | AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument]) |
Tormod Volden | 4e95d0e | 2014-09-02 19:25:00 +0100 | [diff] [blame] | 177 | AC_DEFINE([WINVER], 0x0501, [Oldest Windows version supported]) |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 178 | ;; |
Akshay Jaggi | dc97425 | 2014-09-24 22:46:17 +0100 | [diff] [blame^] | 179 | haiku) |
| 180 | AC_DEFINE(OS_HAIKU, 1, [Haiku backend]) |
| 181 | AC_SUBST(OS_HAIKU) |
| 182 | LIBS="${LIBS} -lbe" |
| 183 | AC_CHECK_HEADERS([poll.h]) |
| 184 | AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument]) |
| 185 | ;; |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 186 | esac |
| 187 | |
Peter Stuge | 94b0ccc | 2012-10-23 00:15:23 +0000 | [diff] [blame] | 188 | AC_SUBST(LIBS) |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 189 | |
Peter Stuge | c24649d | 2010-10-30 22:28:59 +0200 | [diff] [blame] | 190 | AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux) |
| 191 | AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin) |
Hans de Goede | eb4e7be | 2013-08-21 16:18:39 +0200 | [diff] [blame] | 192 | AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xopenbsd) |
| 193 | AM_CONDITIONAL(OS_NETBSD, test "x$backend" = xnetbsd) |
Peter Stuge | c24649d | 2010-10-30 22:28:59 +0200 | [diff] [blame] | 194 | AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows) |
Akshay Jaggi | dc97425 | 2014-09-24 22:46:17 +0100 | [diff] [blame^] | 195 | AM_CONDITIONAL(OS_HAIKU, test "x$backend" = xhaiku) |
Peter Stuge | c24649d | 2010-10-30 22:28:59 +0200 | [diff] [blame] | 196 | AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix) |
Nathan Hjelm | 6853291 | 2012-11-29 16:14:03 -0700 | [diff] [blame] | 197 | AM_CONDITIONAL(CREATE_IMPORT_LIB, test "x$create_import_lib" = "xyes") |
| 198 | AM_CONDITIONAL(USE_UDEV, test "x$enable_udev" = xyes) |
Peter Stuge | c24649d | 2010-10-30 22:28:59 +0200 | [diff] [blame] | 199 | if test "$threads" = posix; then |
| 200 | AC_DEFINE(THREADS_POSIX, 1, [Use POSIX Threads]) |
| 201 | fi |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 202 | |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 203 | # timerfd |
| 204 | AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0]) |
| 205 | AC_ARG_ENABLE([timerfd], |
| 206 | [AS_HELP_STRING([--enable-timerfd], |
Toby Gray | 9222a54 | 2013-07-09 16:05:39 +0100 | [diff] [blame] | 207 | [use timerfd for timing [default=auto]])], |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 208 | [use_timerfd=$enableval], [use_timerfd='auto']) |
| 209 | |
| 210 | if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then |
Daniel Drake | 0bd7ef5 | 2009-11-21 16:57:25 +0000 | [diff] [blame] | 211 | AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required]) |
| 212 | fi |
| 213 | |
| 214 | AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>]) |
| 215 | if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then |
| 216 | AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required]) |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 217 | fi |
| 218 | |
| 219 | AC_MSG_CHECKING([whether to use timerfd for timing]) |
| 220 | if test "x$use_timerfd" = "xno"; then |
| 221 | AC_MSG_RESULT([no (disabled by user)]) |
| 222 | else |
Daniel Drake | 0bd7ef5 | 2009-11-21 16:57:25 +0000 | [diff] [blame] | 223 | 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] | 224 | AC_MSG_RESULT([yes]) |
Peter Stuge | 19d5882 | 2010-11-21 23:09:02 +0100 | [diff] [blame] | 225 | AC_DEFINE(USBI_TIMERFD_AVAILABLE, 1, [timerfd headers available]) |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 226 | else |
| 227 | AC_MSG_RESULT([no (header not available)]) |
| 228 | fi |
| 229 | fi |
| 230 | |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 231 | AC_CHECK_TYPES(struct timespec) |
| 232 | |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 233 | # Message logging |
| 234 | AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])], |
| 235 | [log_enabled=$enableval], |
| 236 | [log_enabled='yes']) |
| 237 | if test "x$log_enabled" != "xno"; then |
| 238 | AC_DEFINE([ENABLE_LOGGING], 1, [Message logging]) |
| 239 | fi |
| 240 | |
| 241 | AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log], |
Toby Gray | 9222a54 | 2013-07-09 16:05:39 +0100 | [diff] [blame] | 242 | [start with debug message logging enabled [default=no]])], |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 243 | [debug_log_enabled=$enableval], |
| 244 | [debug_log_enabled='no']) |
| 245 | if test "x$debug_log_enabled" != "xno"; then |
Pete Batard | cf6e68a | 2012-05-31 18:31:34 +0100 | [diff] [blame] | 246 | AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Start with debug message logging enabled]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 247 | fi |
| 248 | |
Toby Gray | 9222a54 | 2013-07-09 16:05:39 +0100 | [diff] [blame] | 249 | AC_ARG_ENABLE([system-log], [AS_HELP_STRING([--enable-system-log], |
| 250 | [output logging messages to system wide log, if supported by the OS [default=no]])], |
| 251 | [system_log_enabled=$enableval], |
| 252 | [system_log_enabled='no']) |
| 253 | if test "x$system_log_enabled" != "xno"; then |
| 254 | AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], 1, [Enable output to system log]) |
| 255 | fi |
| 256 | |
| 257 | # Check if syslog is available in standard C library |
| 258 | AC_CHECK_HEADERS(syslog.h) |
| 259 | AC_CHECK_FUNC([syslog], [have_syslog=yes], [have_syslog=no]) |
| 260 | if test "x$have_syslog" != "xno"; then |
| 261 | AC_DEFINE([HAVE_SYSLOG_FUNC], 1, [syslog() function available]) |
| 262 | fi |
| 263 | |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 264 | # Examples build |
| 265 | AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build], |
Toby Gray | 9222a54 | 2013-07-09 16:05:39 +0100 | [diff] [blame] | 266 | [build example applications [default=no]])], |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 267 | [build_examples=$enableval], |
| 268 | [build_examples='no']) |
| 269 | AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"]) |
| 270 | |
Toby Gray | 21cf6e4 | 2012-11-21 14:00:31 +0000 | [diff] [blame] | 271 | # Tests build |
| 272 | AC_ARG_ENABLE([tests-build], [AS_HELP_STRING([--enable-tests-build], |
Toby Gray | 9222a54 | 2013-07-09 16:05:39 +0100 | [diff] [blame] | 273 | [build test applications [default=no]])], |
Toby Gray | 21cf6e4 | 2012-11-21 14:00:31 +0000 | [diff] [blame] | 274 | [build_tests=$enableval], |
| 275 | [build_tests='no']) |
| 276 | AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != "xno"]) |
| 277 | |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 278 | # check for -fvisibility=hidden compiler support (GCC >= 3.4) |
| 279 | saved_cflags="$CFLAGS" |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 280 | # -Werror required for cygwin |
| 281 | CFLAGS="$CFLAGS -Werror -fvisibility=hidden" |
Peter Stuge | 44b85da | 2010-11-21 23:10:35 +0100 | [diff] [blame] | 282 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 283 | [VISIBILITY_CFLAGS="-fvisibility=hidden" |
Pete Batard | 29f9f9e | 2010-08-13 11:59:49 +0100 | [diff] [blame] | 284 | AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility]) ], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 285 | [ VISIBILITY_CFLAGS="" |
Pete Batard | 29f9f9e | 2010-08-13 11:59:49 +0100 | [diff] [blame] | 286 | AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility]) ], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 287 | ]) |
| 288 | CFLAGS="$saved_cflags" |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 289 | |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 290 | # check for -Wno-pointer-sign compiler support (GCC >= 4) |
| 291 | saved_cflags="$CFLAGS" |
| 292 | CFLAGS="$CFLAGS -Wno-pointer-sign" |
Peter Stuge | 44b85da | 2010-11-21 23:10:35 +0100 | [diff] [blame] | 293 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 294 | nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="") |
| 295 | CFLAGS="$saved_cflags" |
| 296 | |
Daniel Drake | a516fcb | 2010-07-21 17:49:21 -0600 | [diff] [blame] | 297 | # sigaction not available on MinGW |
| 298 | AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no]) |
| 299 | AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = "xyes"]) |
| 300 | |
Daniel Drake | 7211aba | 2010-06-25 12:01:58 -0500 | [diff] [blame] | 301 | # headers not available on all platforms but required on others |
| 302 | AC_CHECK_HEADERS([sys/time.h]) |
Peter Stuge | 463dda0 | 2012-05-06 17:04:00 +0000 | [diff] [blame] | 303 | AC_CHECK_FUNCS(gettimeofday) |
Pete Batard | 1e6928c | 2013-01-15 22:24:32 +0000 | [diff] [blame] | 304 | AC_CHECK_HEADERS([signal.h]) |
Daniel Drake | 7211aba | 2010-06-25 12:01:58 -0500 | [diff] [blame] | 305 | |
Akshay Jaggi | dc97425 | 2014-09-24 22:46:17 +0100 | [diff] [blame^] | 306 | # check for -std=gnu99 compiler support |
| 307 | saved_cflags="$CFLAGS" |
| 308 | CFLAGS="-std=gnu99" |
| 309 | AC_MSG_CHECKING([whether CC supports -std=gnu99]) |
| 310 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
| 311 | [AC_MSG_RESULT([yes])] |
| 312 | [AM_CFLAGS="${AM_CFLAGS} -std=gnu99"], |
| 313 | [AC_MSG_RESULT([no])] |
| 314 | ) |
| 315 | CFLAGS="$saved_cflags" |
| 316 | |
| 317 | AM_CFLAGS="${AM_CFLAGS} -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow ${THREAD_CFLAGS} ${VISIBILITY_CFLAGS}" |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 318 | |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 319 | AC_SUBST(AM_CFLAGS) |
Peter Stuge | 717f476 | 2010-11-15 19:58:51 +0100 | [diff] [blame] | 320 | AC_SUBST(LTLDFLAGS) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 321 | |
Peter Stuge | ef39d15 | 2011-02-25 02:33:29 +0100 | [diff] [blame] | 322 | AC_CONFIG_FILES([libusb-1.0.pc]) |
| 323 | AC_CONFIG_FILES([Makefile]) |
| 324 | AC_CONFIG_FILES([libusb/Makefile]) |
Peter Stuge | ef39d15 | 2011-02-25 02:33:29 +0100 | [diff] [blame] | 325 | AC_CONFIG_FILES([examples/Makefile]) |
Toby Gray | 21cf6e4 | 2012-11-21 14:00:31 +0000 | [diff] [blame] | 326 | AC_CONFIG_FILES([tests/Makefile]) |
Peter Stuge | ef39d15 | 2011-02-25 02:33:29 +0100 | [diff] [blame] | 327 | AC_CONFIG_FILES([doc/Makefile]) |
| 328 | AC_CONFIG_FILES([doc/doxygen.cfg]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 329 | AC_OUTPUT |