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 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 20 | dnl Library versioning |
| 21 | dnl These numbers should be tweaked on every release. Read carefully: |
| 22 | dnl http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html |
| 23 | dnl http://sourceware.org/autobook/autobook/autobook_91.html |
Nathan Hjelm | fde20bb | 2018-12-05 10:36:50 -0700 | [diff] [blame] | 24 | lt_current=2 |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 25 | lt_revision=0 |
Ludovic Rousseau | 767eafb | 2019-08-08 00:13:17 +0200 | [diff] [blame] | 26 | lt_age=2 |
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 | |
Daniel Drake | e9364d7 | 2008-01-04 00:40:49 +0000 | [diff] [blame] | 31 | AC_CONFIG_SRCDIR([libusb/core.c]) |
Daniel Drake | 8be2560 | 2009-06-13 17:19:07 +0100 | [diff] [blame] | 32 | AC_CONFIG_MACRO_DIR([m4]) |
Ludovic Rousseau | c9d41fe | 2012-06-01 11:30:00 +0200 | [diff] [blame] | 33 | AC_CONFIG_HEADERS([config.h]) |
Daniel Drake | 9b120c2 | 2009-11-07 10:03:07 +0000 | [diff] [blame] | 34 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 35 | |
Nathan Hjelm | 2040ab1 | 2016-03-10 12:57:50 -0700 | [diff] [blame] | 36 | AC_PREREQ([2.69]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 37 | AC_PROG_CC |
Chris Dickens | 3dc781c | 2015-12-03 12:59:20 -0800 | [diff] [blame] | 38 | AC_PROG_CXX |
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 |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [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]) |
Kuangye Guo | 7e3de5d | 2013-10-21 18:36:15 -0700 | [diff] [blame] | 48 | case $host in |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 49 | *-darwin*) |
Peter Stuge | 0bd4a4d | 2011-02-26 04:08:38 +0100 | [diff] [blame] | 50 | AC_MSG_RESULT([Darwin/Mac OS X]) |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 51 | backend=darwin |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 52 | poll=posix |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 53 | threads=posix |
Pete Batard | 9a4249f | 2010-07-10 17:51:13 -0600 | [diff] [blame] | 54 | ;; |
Akshay Jaggi | dc97425 | 2014-09-24 22:46:17 +0100 | [diff] [blame] | 55 | *-haiku*) |
| 56 | AC_MSG_RESULT([Haiku]) |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 57 | backend=haiku |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 58 | poll=posix |
| 59 | threads=posix |
| 60 | ;; |
| 61 | *-linux* | *-uclinux*) |
| 62 | dnl on linux-android platform, some functions are in different places |
| 63 | case $host in |
| 64 | *-linux-android*) |
| 65 | AC_MSG_RESULT([Linux (Android system)]) |
| 66 | is_backend_android=yes |
| 67 | ;; |
| 68 | *) |
| 69 | AC_MSG_RESULT([Linux]) |
| 70 | is_backend_android=no |
| 71 | ;; |
| 72 | esac |
| 73 | backend=linux |
| 74 | poll=posix |
| 75 | threads=posix |
| 76 | ;; |
| 77 | *-netbsd*) |
| 78 | AC_MSG_RESULT([NetBSD]) |
| 79 | backend=netbsd |
| 80 | poll=posix |
| 81 | threads=posix |
| 82 | ;; |
| 83 | *-openbsd*) |
| 84 | AC_MSG_RESULT([OpenBSD]) |
| 85 | backend=openbsd |
| 86 | poll=posix |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 87 | threads=posix |
Akshay Jaggi | dc97425 | 2014-09-24 22:46:17 +0100 | [diff] [blame] | 88 | ;; |
Lei Chen | eefd322 | 2016-02-19 11:58:39 +0800 | [diff] [blame] | 89 | *-solaris*) |
| 90 | AC_MSG_RESULT([SunOS]) |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 91 | backend=sunos |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 92 | poll=posix |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 93 | threads=posix |
Lei Chen | eefd322 | 2016-02-19 11:58:39 +0800 | [diff] [blame] | 94 | ;; |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 95 | *-cygwin*) |
| 96 | AC_MSG_RESULT([Windows (using Cygwin)]) |
| 97 | backend=windows |
| 98 | poll=windows |
| 99 | threads=posix |
| 100 | ;; |
| 101 | *-mingw* | *msys*) |
| 102 | AC_MSG_RESULT([Windows]) |
| 103 | backend=windows |
| 104 | poll=windows |
| 105 | threads=windows |
| 106 | create_import_lib=yes |
| 107 | AM_CFLAGS="${AM_CFLAGS} -fno-omit-frame-pointer" |
| 108 | ;; |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 109 | *) |
Pino Toscano | 53572d7 | 2019-12-27 18:41:28 +0100 | [diff] [blame] | 110 | AC_MSG_RESULT([Null]) |
| 111 | backend="null" |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 112 | poll=posix |
Pino Toscano | 53572d7 | 2019-12-27 18:41:28 +0100 | [diff] [blame] | 113 | threads="posix" |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 114 | ;; |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 115 | esac |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 116 | |
| 117 | case $backend in |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 118 | darwin) |
| 119 | AC_DEFINE([OS_DARWIN], [1], [Darwin backend]) |
| 120 | LIBS="-lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation" |
| 121 | LTLDFLAGS="${LTLDFLAGS} -Wl,-prebind" |
| 122 | ;; |
| 123 | haiku) |
| 124 | AC_DEFINE([OS_HAIKU], [1], [Haiku backend]) |
| 125 | LIBS="-lbe" |
| 126 | ;; |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 127 | linux) |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 128 | AC_DEFINE([OS_LINUX], [1], [Linux backend]) |
Baruch Siach | 552a4a4 | 2018-06-05 14:22:21 +0300 | [diff] [blame] | 129 | AC_SEARCH_LIBS([clock_gettime], [rt], [], [], [-pthread]) |
Nathan Hjelm | 6853291 | 2012-11-29 16:14:03 -0700 | [diff] [blame] | 130 | AC_ARG_ENABLE([udev], |
Toby Gray | 9222a54 | 2013-07-09 16:05:39 +0100 | [diff] [blame] | 131 | [AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended) [default=yes]])], |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 132 | [], [enable_udev=yes]) |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 133 | if test "x$enable_udev" = xyes ; then |
| 134 | dnl system has udev. use it or fail! |
| 135 | AC_CHECK_HEADER([libudev.h], [], [AC_MSG_ERROR([udev support requested but libudev header not installed])]) |
| 136 | AC_CHECK_LIB([udev], [udev_new], [], [AC_MSG_ERROR([udev support requested but libudev not installed])]) |
| 137 | else |
| 138 | AC_CHECK_HEADERS([asm/types.h]) |
| 139 | AC_CHECK_HEADER([linux/netlink.h], [], [AC_MSG_ERROR([Linux netlink header not found])]) |
| 140 | AC_CHECK_HEADER([sys/socket.h], [], [AC_MSG_ERROR([Linux socket header not found])]) |
| 141 | fi |
Chris Dickens | 068b594 | 2017-01-12 11:01:59 -0800 | [diff] [blame] | 142 | if test "x$is_backend_android" != xyes; then |
| 143 | THREAD_CFLAGS="-pthread" |
| 144 | LIBS="${LIBS} -pthread" |
| 145 | fi |
Lei Chen | eefd322 | 2016-02-19 11:58:39 +0800 | [diff] [blame] | 146 | ;; |
Hans de Goede | eb4e7be | 2013-08-21 16:18:39 +0200 | [diff] [blame] | 147 | netbsd) |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 148 | AC_DEFINE([OS_NETBSD], [1], [NetBSD backend]) |
Hans de Goede | eb4e7be | 2013-08-21 16:18:39 +0200 | [diff] [blame] | 149 | THREAD_CFLAGS="-pthread" |
| 150 | LIBS="-pthread" |
Akshay Jaggi | dc97425 | 2014-09-24 22:46:17 +0100 | [diff] [blame] | 151 | ;; |
Pino Toscano | 53572d7 | 2019-12-27 18:41:28 +0100 | [diff] [blame] | 152 | null) |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 153 | AC_DEFINE([OS_NULL], [1], [Null backend]) |
Pino Toscano | 53572d7 | 2019-12-27 18:41:28 +0100 | [diff] [blame] | 154 | THREAD_CFLAGS="-pthread" |
| 155 | LIBS="-pthread" |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 156 | ;; |
| 157 | openbsd) |
| 158 | AC_DEFINE([OS_OPENBSD], [1], [OpenBSD backend]) |
| 159 | THREAD_CFLAGS="-pthread" |
| 160 | LIBS="-pthread" |
| 161 | ;; |
| 162 | sunos) |
| 163 | AC_DEFINE([OS_SUNOS], [1], [SunOS backend]) |
| 164 | THREAD_CFLAGS="-pthread" |
| 165 | LIBS="-pthread -ldevinfo" |
| 166 | ;; |
| 167 | windows) |
| 168 | AC_DEFINE([OS_WINDOWS], [1], [Windows backend]) |
| 169 | AC_CHECK_TYPES([struct timespec], [], [], [[#include <time.h>]]) |
| 170 | LIBS="" |
| 171 | LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias" |
| 172 | AC_DEFINE([_WIN32_WINNT], [_WIN32_WINNT_VISTA], [Oldest Windows version supported (Vista)]) |
| 173 | ;; |
| 174 | *) |
| 175 | AC_MSG_ERROR([Unknown backend]) |
Pino Toscano | 53572d7 | 2019-12-27 18:41:28 +0100 | [diff] [blame] | 176 | ;; |
Pete Batard | 968df12 | 2012-04-19 18:01:04 +0100 | [diff] [blame] | 177 | esac |
| 178 | |
Peter Stuge | 94b0ccc | 2012-10-23 00:15:23 +0000 | [diff] [blame] | 179 | AC_SUBST(LIBS) |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 180 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 181 | AM_CONDITIONAL([OS_DARWIN], [test "x$backend" = xdarwin]) |
| 182 | AM_CONDITIONAL([OS_HAIKU], [test "x$backend" = xhaiku]) |
| 183 | AM_CONDITIONAL([OS_LINUX], [test "x$backend" = xlinux]) |
| 184 | AM_CONDITIONAL([OS_NETBSD], [test "x$backend" = xnetbsd]) |
| 185 | AM_CONDITIONAL([OS_NULL], [test "x$backend" = xnull]) |
| 186 | AM_CONDITIONAL([OS_OPENBSD], [test "x$backend" = xopenbsd]) |
| 187 | AM_CONDITIONAL([OS_SUNOS], [test "x$backend" = xsunos]) |
| 188 | AM_CONDITIONAL([OS_WINDOWS], [test "x$backend" = xwindows]) |
| 189 | AM_CONDITIONAL([POLL_POSIX], [test "x$threads" = xposix]) |
| 190 | AM_CONDITIONAL([POLL_WINDOWS], [test "x$threads" = xwindows]) |
| 191 | AM_CONDITIONAL([THREADS_POSIX], [test "x$threads" = xposix]) |
| 192 | AM_CONDITIONAL([THREADS_WINDOWS], [test "x$threads" = xwindows]) |
| 193 | AM_CONDITIONAL([CREATE_IMPORT_LIB], [test "x$create_import_lib" = xyes]) |
| 194 | AM_CONDITIONAL([USE_UDEV], [test "x$enable_udev" = xyes]) |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 195 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 196 | if test "x$poll" = xposix; then |
| 197 | AC_DEFINE([POLL_POSIX], [1], [Use POSIX poll() implementation]) |
| 198 | AC_CHECK_TYPES([nfds_t], [], [], [[#include <poll.h>]]) |
| 199 | AC_CHECK_FUNCS([pipe2]) |
| 200 | elif test "x$poll" = xwindows; then |
| 201 | AC_DEFINE([POLL_WINDOWS], [1], [Use Windows poll() implementation]) |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 202 | else |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 203 | AC_MSG_ERROR([Unknown poll implementation]) |
| 204 | fi |
| 205 | |
| 206 | if test "x$threads" = xposix; then |
| 207 | AC_DEFINE([THREADS_POSIX], [1], [Use POSIX Threads]) |
| 208 | elif test "x$threads" = xwindows; then |
| 209 | AC_DEFINE([THREADS_WINDOWS], [1], [Use Windows Threads]) |
| 210 | else |
| 211 | AC_MSG_ERROR([Unknown threads implementation]) |
| 212 | fi |
| 213 | |
| 214 | dnl headers not available on all platforms but required on others |
| 215 | AC_CHECK_HEADERS([sys/time.h]) |
| 216 | |
| 217 | dnl timerfd support |
| 218 | if test "x$backend" = xlinux || test "x$backend" = xsunos; then |
| 219 | AC_ARG_ENABLE([timerfd], |
| 220 | [AS_HELP_STRING([--enable-timerfd], [use timerfd for timing [default=auto]])], |
| 221 | [use_timerfd=$enableval], |
| 222 | [use_timerfd=auto]) |
| 223 | if test "x$use_timerfd" != xno; then |
| 224 | AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=yes], [timerfd_h=no]) |
| 225 | if test "x$timerfd_h" = xyes; then |
| 226 | AC_CHECK_DECLS([TFD_NONBLOCK, TFD_CLOEXEC], [timerfd_h_ok=yes], [timerfd_h_ok=no], [[#include <sys/timerfd.h>]]) |
| 227 | if test "x$timerfd_h_ok" = xyes; then |
| 228 | AC_CHECK_FUNC([timerfd_create], [timerfd_ok=yes], [timerfd_ok=no]) |
| 229 | if test "x$timerfd_ok" = xyes; then |
| 230 | AC_DEFINE([HAVE_TIMERFD], [1], [Define if the system has timerfd functionality]) |
| 231 | elif test "x$use_timerfd" = xyes; then |
| 232 | AC_MSG_ERROR([timerfd_create() function not found; glibc 2.9+ required]) |
| 233 | fi |
| 234 | elif test "x$use_timerfd" = xyes; then |
| 235 | AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required]) |
| 236 | fi |
| 237 | elif test "x$use_timerfd" = xyes; then |
| 238 | AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required]) |
| 239 | fi |
| 240 | fi |
| 241 | AC_MSG_CHECKING([whether to use timerfd for timing]) |
| 242 | if test "x$use_timerfd" = xno; then |
| 243 | AC_MSG_RESULT([no (disabled by user)]) |
| 244 | elif test "x$timerfd_h" = xno; then |
| 245 | AC_MSG_RESULT([no (header not usable)]) |
| 246 | elif test "x$timerfd_h_ok" = xno; then |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 247 | AC_MSG_RESULT([no (header not available)]) |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 248 | elif test "x$timerfd_ok" = xno; then |
| 249 | AC_MSG_RESULT([no (functions not available)]) |
| 250 | else |
| 251 | AC_MSG_RESULT([yes]) |
Daniel Drake | 4783008 | 2009-10-28 20:33:49 +0545 | [diff] [blame] | 252 | fi |
| 253 | fi |
| 254 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 255 | dnl Message logging |
| 256 | AC_ARG_ENABLE([log], |
| 257 | [AS_HELP_STRING([--disable-log], [disable all logging])], |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 258 | [log_enabled=$enableval], |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 259 | [log_enabled=yes]) |
Chris Dickens | 9417868 | 2017-01-12 13:50:35 -0800 | [diff] [blame] | 260 | if test "x$log_enabled" != xno; then |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 261 | AC_DEFINE([ENABLE_LOGGING], [1], [Message logging]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 262 | fi |
| 263 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 264 | AC_ARG_ENABLE([debug-log], |
| 265 | [AS_HELP_STRING([--enable-debug-log], [start with debug message logging enabled [default=no]])], |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 266 | [debug_log_enabled=$enableval], |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 267 | [debug_log_enabled=no]) |
Chris Dickens | 9417868 | 2017-01-12 13:50:35 -0800 | [diff] [blame] | 268 | if test "x$debug_log_enabled" != xno; then |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 269 | AC_DEFINE([ENABLE_DEBUG_LOGGING], [1], [Start with debug message logging enabled]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 270 | fi |
| 271 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 272 | AC_ARG_ENABLE([system-log], |
| 273 | [AS_HELP_STRING([--enable-system-log], [output logging messages to system wide log, if supported by the OS [default=no]])], |
Toby Gray | 9222a54 | 2013-07-09 16:05:39 +0100 | [diff] [blame] | 274 | [system_log_enabled=$enableval], |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 275 | [system_log_enabled=no]) |
Chris Dickens | 9417868 | 2017-01-12 13:50:35 -0800 | [diff] [blame] | 276 | if test "x$system_log_enabled" != xno; then |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 277 | AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], [1], [Enable output to system log]) |
| 278 | if test "x$backend" != xwindows && test "x$is_backend_android" != xyes; then |
| 279 | dnl Check if syslog is available in standard C library |
| 280 | AC_CHECK_HEADER([syslog.h], [syslog_h=yes], [syslog_h=no]) |
| 281 | if test "x$syslog_h" = xyes; then |
| 282 | AC_CHECK_FUNCS([syslog]) |
| 283 | fi |
Chris Dickens | 9417868 | 2017-01-12 13:50:35 -0800 | [diff] [blame] | 284 | fi |
Toby Gray | 9222a54 | 2013-07-09 16:05:39 +0100 | [diff] [blame] | 285 | fi |
| 286 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 287 | dnl Examples build |
| 288 | AC_ARG_ENABLE([examples-build], |
| 289 | [AS_HELP_STRING([--enable-examples-build], [build example applications [default=no]])], |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 290 | [build_examples=$enableval], |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 291 | [build_examples=no]) |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 292 | AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != xno]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 293 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 294 | dnl Tests build |
| 295 | AC_ARG_ENABLE([tests-build], |
| 296 | [AS_HELP_STRING([--enable-tests-build], [build test applications [default=no]])], |
Toby Gray | 21cf6e4 | 2012-11-21 14:00:31 +0000 | [diff] [blame] | 297 | [build_tests=$enableval], |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 298 | [build_tests=no]) |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 299 | AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != xno]) |
Chris Dickens | 9417868 | 2017-01-12 13:50:35 -0800 | [diff] [blame] | 300 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 301 | dnl sigaction needed for some example programs |
| 302 | if test "x$build_examples" != xno; then |
| 303 | AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no]) |
| 304 | fi |
| 305 | AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = xyes]) |
Chris Dickens | 9417868 | 2017-01-12 13:50:35 -0800 | [diff] [blame] | 306 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 307 | dnl check for -fvisibility=hidden compiler support (GCC >= 3.4) |
| 308 | saved_CFLAGS="${CFLAGS}" |
| 309 | dnl -Werror required for cygwin |
| 310 | CFLAGS="${CFLAGS} -Werror -fvisibility=hidden" |
Peter Stuge | 44b85da | 2010-11-21 23:10:35 +0100 | [diff] [blame] | 311 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 312 | [VISIBILITY_CFLAGS="-fvisibility=hidden" |
Chris Dickens | cb77a25 | 2017-02-20 00:18:33 -0800 | [diff] [blame] | 313 | AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility])], |
| 314 | [VISIBILITY_CFLAGS="" |
| 315 | AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility])], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 316 | ]) |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 317 | CFLAGS="${saved_CFLAGS}" |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 318 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 319 | dnl check for -Wno-pointer-sign compiler support (GCC >= 4) |
| 320 | saved_CFLAGS="${CFLAGS}" |
| 321 | CFLAGS="${CFLAGS} -Wno-pointer-sign" |
Peter Stuge | 44b85da | 2010-11-21 23:10:35 +0100 | [diff] [blame] | 322 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 323 | nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="") |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 324 | CFLAGS="${saved_CFLAGS}" |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 325 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 326 | dnl check for -std=gnu99 compiler support |
| 327 | saved_CFLAGS="${CFLAGS}" |
Akshay Jaggi | dc97425 | 2014-09-24 22:46:17 +0100 | [diff] [blame] | 328 | CFLAGS="-std=gnu99" |
| 329 | AC_MSG_CHECKING([whether CC supports -std=gnu99]) |
| 330 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 331 | [AC_MSG_RESULT([yes]) |
| 332 | AM_CFLAGS="${AM_CFLAGS} -std=gnu99"], |
| 333 | [AC_MSG_RESULT([no])] |
Akshay Jaggi | dc97425 | 2014-09-24 22:46:17 +0100 | [diff] [blame] | 334 | ) |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 335 | CFLAGS="${saved_CFLAGS}" |
Akshay Jaggi | dc97425 | 2014-09-24 22:46:17 +0100 | [diff] [blame] | 336 | |
Chris Dickens | d5bb64b | 2020-01-22 17:39:14 -0800 | [diff] [blame^] | 337 | 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] | 338 | |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 339 | AC_SUBST(AM_CFLAGS) |
Peter Stuge | 717f476 | 2010-11-15 19:58:51 +0100 | [diff] [blame] | 340 | AC_SUBST(LTLDFLAGS) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 341 | |
Peter Stuge | ef39d15 | 2011-02-25 02:33:29 +0100 | [diff] [blame] | 342 | AC_CONFIG_FILES([libusb-1.0.pc]) |
| 343 | AC_CONFIG_FILES([Makefile]) |
| 344 | AC_CONFIG_FILES([libusb/Makefile]) |
Peter Stuge | ef39d15 | 2011-02-25 02:33:29 +0100 | [diff] [blame] | 345 | AC_CONFIG_FILES([examples/Makefile]) |
Toby Gray | 21cf6e4 | 2012-11-21 14:00:31 +0000 | [diff] [blame] | 346 | AC_CONFIG_FILES([tests/Makefile]) |
Peter Stuge | ef39d15 | 2011-02-25 02:33:29 +0100 | [diff] [blame] | 347 | AC_CONFIG_FILES([doc/Makefile]) |
| 348 | AC_CONFIG_FILES([doc/doxygen.cfg]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 349 | AC_OUTPUT |