blob: d2d5b6f7cbbadfb347c95d7846ae443748d06ebc [file] [log] [blame]
Peter Stuge85a14f42011-05-09 08:12:24 +02001dnl These m4 macros are whitespace sensitive and break if moved around much.
2m4_define([LU_VERSION_H], m4_include([libusb/version.h]))
3m4_define([LU_DEFINE_VERSION_ATOM],
4 [m4_define([$1], m4_bregexp(LU_VERSION_H,
5 [^#define\s*$1\s*\([0-9]*\).*], [\1]))])
Peter Stugecbc2d7b2011-09-15 16:48:35 +02006m4_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 Stuge85a14f42011-05-09 08:12:24 +02009dnl The m4_bregexp() returns (only) the numbers following the #define named
10dnl in the first macro parameter. m4_define() then defines the name for use
Ludovic Rousseauc9d41fe2012-06-01 11:30:00 +020011dnl in AC_INIT.
Pete Batard9a4249f2010-07-10 17:51:13 -060012
Peter Stuge85a14f42011-05-09 08:12:24 +020013LU_DEFINE_VERSION_ATOM([LIBUSB_MAJOR])
14LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR])
15LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO])
Peter Stugecbc2d7b2011-09-15 16:48:35 +020016LU_DEFINE_VERSION_RC_ATOM([LIBUSB_RC])
Daniel Draked7c25452010-10-04 20:03:58 +010017
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070018AC_PREREQ([2.69])
Chris Dickens4a5540a2020-03-25 00:09:26 -070019AC_INIT([libusb-1.0], [LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC], [libusb-devel@lists.sourceforge.net], [libusb-1.0], [http://libusb.info])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070020AC_CONFIG_HEADERS([config.h])
21AC_CONFIG_SRCDIR([libusb/core.c])
22AC_CONFIG_MACRO_DIR([m4])
23AC_PROG_CC
24AC_PROG_CXX
25AC_C_INLINE
26AM_INIT_AUTOMAKE
27LT_INIT
28LT_LANG([Windows Resource])
Daniel Draked7c25452010-10-04 20:03:58 +010029
Chris Dickensd5bb64b2020-01-22 17:39:14 -080030dnl Library versioning
31dnl These numbers should be tweaked on every release. Read carefully:
32dnl http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
33dnl http://sourceware.org/autobook/autobook/autobook_91.html
Nathan Hjelmfde20bb2018-12-05 10:36:50 -070034lt_current=2
Chris Dickenscb77a252017-02-20 00:18:33 -080035lt_revision=0
Ludovic Rousseau767eafb2019-08-08 00:13:17 +020036lt_age=2
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070037LT_LDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age} -no-undefined"
Pete Batard9a4249f2010-07-10 17:51:13 -060038
Daniel Drake9b120c22009-11-07 10:03:07 +000039m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
Daniel Drake852bba42007-11-28 13:48:45 +000040
Chris Dickens7c0cea72020-04-09 11:30:19 -070041EXTRA_CFLAGS=
42
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070043dnl check for -std=gnu11 compiler support (optional)
Chris Dickens7c0cea72020-04-09 11:30:19 -070044dnl note that we don't just check if the compiler accepts '-std=x11'
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070045dnl but also that it supports the _Thread_local keyword because some compilers
46dnl (e.g. gcc 4.8) accept the command line option but do not implement TLS
47saved_CFLAGS="${CFLAGS}"
48CFLAGS="-std=gnu11"
Chris Dickens7c0cea72020-04-09 11:30:19 -070049AC_MSG_CHECKING([if $CC supports -std=gnu11])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070050AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
51 [AC_MSG_RESULT([yes])
Chris Dickens7c0cea72020-04-09 11:30:19 -070052 c_dialect=gnu],
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070053 [AC_MSG_RESULT([no])
Chris Dickens7c0cea72020-04-09 11:30:19 -070054 c_dialect=])
55if test "x$c_dialect" != xgnu; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070056 dnl fallback check for -std=c11 compiler support (required)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070057 CFLAGS="-std=c11"
Chris Dickens7c0cea72020-04-09 11:30:19 -070058 AC_MSG_CHECKING([if $CC supports -std=c11])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070059 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
60 [AC_MSG_RESULT([yes])],
61 [AC_MSG_RESULT([no])
62 AC_MSG_ERROR([compiler with C11 support is required to build libusb])])
Chris Dickens7c0cea72020-04-09 11:30:19 -070063 c_dialect=c
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070064fi
Chris Dickens7c0cea72020-04-09 11:30:19 -070065CFLAGS="${saved_CFLAGS}"
Peter Stuge717f4762010-11-15 19:58:51 +010066
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070067AC_DEFINE([_GNU_SOURCE], [1], [Enable GNU extensions.])
68AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__ ((visibility ("default")))], [Define to the attribute for default visibility.])
69
70create_import_lib=
71is_android_linux=
Daniel Drakec0c94322008-03-13 12:36:56 +000072AC_MSG_CHECKING([operating system])
Kuangye Guo7e3de5d2013-10-21 18:36:15 -070073case $host in
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030074*-darwin*)
Peter Stuge0bd4a4d2011-02-26 04:08:38 +010075 AC_MSG_RESULT([Darwin/Mac OS X])
Chris Dickenscb77a252017-02-20 00:18:33 -080076 backend=darwin
Chris Dickensd5bb64b2020-01-22 17:39:14 -080077 poll=posix
Chris Dickenscb77a252017-02-20 00:18:33 -080078 threads=posix
Pete Batard9a4249f2010-07-10 17:51:13 -060079 ;;
Akshay Jaggidc974252014-09-24 22:46:17 +010080*-haiku*)
81 AC_MSG_RESULT([Haiku])
Chris Dickenscb77a252017-02-20 00:18:33 -080082 backend=haiku
Chris Dickensd5bb64b2020-01-22 17:39:14 -080083 poll=posix
84 threads=posix
85 ;;
86*-linux* | *-uclinux*)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070087 dnl on Android Linux, some functions are in different places
Chris Dickensd5bb64b2020-01-22 17:39:14 -080088 case $host in
89 *-linux-android*)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070090 AC_MSG_RESULT([Android Linux])
91 is_android_linux=yes
Chris Dickensd5bb64b2020-01-22 17:39:14 -080092 ;;
93 *)
94 AC_MSG_RESULT([Linux])
Chris Dickensd5bb64b2020-01-22 17:39:14 -080095 ;;
96 esac
97 backend=linux
98 poll=posix
99 threads=posix
100 ;;
101*-netbsd*)
102 AC_MSG_RESULT([NetBSD])
103 backend=netbsd
104 poll=posix
105 threads=posix
106 ;;
107*-openbsd*)
108 AC_MSG_RESULT([OpenBSD])
109 backend=openbsd
110 poll=posix
Chris Dickenscb77a252017-02-20 00:18:33 -0800111 threads=posix
Akshay Jaggidc974252014-09-24 22:46:17 +0100112 ;;
Lei Cheneefd3222016-02-19 11:58:39 +0800113*-solaris*)
114 AC_MSG_RESULT([SunOS])
Chris Dickenscb77a252017-02-20 00:18:33 -0800115 backend=sunos
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800116 poll=posix
Chris Dickenscb77a252017-02-20 00:18:33 -0800117 threads=posix
Lei Cheneefd3222016-02-19 11:58:39 +0800118 ;;
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800119*-cygwin*)
120 AC_MSG_RESULT([Windows (using Cygwin)])
121 backend=windows
122 poll=windows
123 threads=posix
124 ;;
125*-mingw* | *msys*)
126 AC_MSG_RESULT([Windows])
127 backend=windows
128 poll=windows
129 threads=windows
Chris Dickens4a5540a2020-03-25 00:09:26 -0700130 test "x$enable_shared" = xyes && create_import_lib=yes
Chris Dickens7c0cea72020-04-09 11:30:19 -0700131 EXTRA_CFLAGS="-fno-omit-frame-pointer"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800132 ;;
Daniel Drakec0c94322008-03-13 12:36:56 +0000133*)
Pino Toscano53572d72019-12-27 18:41:28 +0100134 AC_MSG_RESULT([Null])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700135 AC_MSG_WARN([The host being compiled for is not supported.])
136 AC_MSG_WARN([The library may compile but will not function in any useful manner.])
Pino Toscano53572d72019-12-27 18:41:28 +0100137 backend="null"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800138 poll=posix
Pino Toscano53572d72019-12-27 18:41:28 +0100139 threads="posix"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800140 ;;
Daniel Drakec0c94322008-03-13 12:36:56 +0000141esac
Pete Batard968df122012-04-19 18:01:04 +0100142
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700143if test "x$poll" = xposix; then
144 AC_DEFINE([POLL_POSIX], [1], [Define to 1 if using the POSIX poll() implementation.])
145 AC_CHECK_TYPES([nfds_t], [], [], [[#include <poll.h>]])
146 AC_CHECK_FUNCS([pipe2])
147elif test "x$poll" = xwindows; then
148 AC_DEFINE([POLL_WINDOWS], [1], [Define to 1 if using the Windows poll() implementation.])
149else
150 AC_MSG_ERROR([Unknown poll implementation])
151fi
152
153if test "x$threads" = xposix; then
154 AC_DEFINE([THREADS_POSIX], [1], [Define to 1 if using POSIX threads.])
155 AC_SUBST(THREAD_CFLAGS, [-pthread])
156 dnl Android Linux and Darwin provide pthread functions directly in libc
157 dnl glibc also provides some pthread functions directly, so search for a thread-specific function
158 AC_SEARCH_LIBS([pthread_key_create], [pthread], [AC_SUBST(THREAD_LIBS, [-lpthread])], [], [])
159elif test "x$threads" = xwindows; then
160 AC_DEFINE([THREADS_WINDOWS], [1], [Define to 1 if using Windows threads.])
161else
162 AC_MSG_ERROR([Unknown threads implementation])
163fi
164
Pete Batard968df122012-04-19 18:01:04 +0100165case $backend in
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800166darwin)
Chris Dickens30b56ba2020-03-27 00:03:41 -0700167 AC_CHECK_FUNCS([pthread_threadid_np])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700168 LIBS="${LIBS} -lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800169 ;;
170haiku)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700171 LIBS="${LIBS} -lbe"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800172 ;;
Pete Batard968df122012-04-19 18:01:04 +0100173linux)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700174 AC_SEARCH_LIBS([clock_gettime], [rt], [], [], [])
175 AC_CHECK_FUNCS([pthread_setname_np])
Nathan Hjelm68532912012-11-29 16:14:03 -0700176 AC_ARG_ENABLE([udev],
Toby Gray9222a542013-07-09 16:05:39 +0100177 [AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended) [default=yes]])],
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700178 [use_udev=$enableval], [use_udev=yes])
179 if test "x$use_udev" = xyes; then
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800180 dnl system has udev. use it or fail!
181 AC_CHECK_HEADER([libudev.h], [], [AC_MSG_ERROR([udev support requested but libudev header not installed])])
182 AC_CHECK_LIB([udev], [udev_new], [], [AC_MSG_ERROR([udev support requested but libudev not installed])])
183 else
184 AC_CHECK_HEADERS([asm/types.h])
185 AC_CHECK_HEADER([linux/netlink.h], [], [AC_MSG_ERROR([Linux netlink header not found])])
186 AC_CHECK_HEADER([sys/socket.h], [], [AC_MSG_ERROR([Linux socket header not found])])
187 fi
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800188 ;;
189sunos)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700190 LIBS="${LIBS} -ldevinfo"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800191 ;;
192windows)
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800193 AC_CHECK_TYPES([struct timespec], [], [], [[#include <time.h>]])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700194 AC_DEFINE([_WIN32_WINNT], [_WIN32_WINNT_VISTA], [Define to the oldest supported Windows version.])
195 LT_LDFLAGS="${LT_LDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800196 ;;
197*)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700198 dnl no special handling required
Pino Toscano53572d72019-12-27 18:41:28 +0100199 ;;
Pete Batard968df122012-04-19 18:01:04 +0100200esac
201
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800202dnl headers not available on all platforms but required on others
203AC_CHECK_HEADERS([sys/time.h])
204
Chris Dickens26b16eb2020-01-26 22:43:28 -0800205dnl the clock_gettime() function needs certain clock IDs defined
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700206AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [have_clock_gettime=])
Chris Dickens26b16eb2020-01-26 22:43:28 -0800207if test "x$have_clock_gettime" = xyes; then
208 AC_CHECK_DECL([CLOCK_REALTIME], [], [AC_MSG_ERROR([C library headers missing definition for CLOCK_REALTIME])], [[#include <time.h>]])
209 AC_CHECK_DECL([CLOCK_MONOTONIC], [], [AC_MSG_ERROR([C library headers missing definition for CLOCK_MONOTONIC])], [[#include <time.h>]])
210elif test "x$backend" != xdarwin && test "x$backend" != xwindows; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700211 AC_MSG_ERROR([clock_gettime() is required on this platform])
Chris Dickens26b16eb2020-01-26 22:43:28 -0800212fi
213
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800214dnl timerfd support
215if test "x$backend" = xlinux || test "x$backend" = xsunos; then
216 AC_ARG_ENABLE([timerfd],
217 [AS_HELP_STRING([--enable-timerfd], [use timerfd for timing [default=auto]])],
218 [use_timerfd=$enableval],
219 [use_timerfd=auto])
220 if test "x$use_timerfd" != xno; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700221 AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=yes], [timerfd_h=])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800222 if test "x$timerfd_h" = xyes; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700223 AC_CHECK_DECLS([TFD_NONBLOCK, TFD_CLOEXEC], [timerfd_h_ok=yes], [timerfd_h_ok=], [[#include <sys/timerfd.h>]])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800224 if test "x$timerfd_h_ok" = xyes; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700225 AC_CHECK_FUNC([timerfd_create], [timerfd_ok=yes], [timerfd_ok=])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800226 if test "x$timerfd_ok" = xyes; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700227 AC_DEFINE([HAVE_TIMERFD], [1], [Define to 1 if the system has timerfd functionality.])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800228 elif test "x$use_timerfd" = xyes; then
229 AC_MSG_ERROR([timerfd_create() function not found; glibc 2.9+ required])
230 fi
231 elif test "x$use_timerfd" = xyes; then
232 AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
233 fi
234 elif test "x$use_timerfd" = xyes; then
235 AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
236 fi
237 fi
238 AC_MSG_CHECKING([whether to use timerfd for timing])
239 if test "x$use_timerfd" = xno; then
240 AC_MSG_RESULT([no (disabled by user)])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700241 elif test "x$timerfd_h" != xyes; then
Daniel Drake47830082009-10-28 20:33:49 +0545242 AC_MSG_RESULT([no (header not available)])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700243 elif test "x$timerfd_h_ok" != xyes; then
244 AC_MSG_RESULT([no (header not usable)])
245 elif test "x$timerfd_ok" != xyes; then
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800246 AC_MSG_RESULT([no (functions not available)])
247 else
248 AC_MSG_RESULT([yes])
Daniel Drake47830082009-10-28 20:33:49 +0545249 fi
250fi
251
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800252dnl Message logging
253AC_ARG_ENABLE([log],
254 [AS_HELP_STRING([--disable-log], [disable all logging])],
Daniel Drake852bba42007-11-28 13:48:45 +0000255 [log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800256 [log_enabled=yes])
Chris Dickens94178682017-01-12 13:50:35 -0800257if test "x$log_enabled" != xno; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700258 AC_DEFINE([ENABLE_LOGGING], [1], [Define to 1 to enable message logging.])
Daniel Drake852bba42007-11-28 13:48:45 +0000259fi
260
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800261AC_ARG_ENABLE([debug-log],
262 [AS_HELP_STRING([--enable-debug-log], [start with debug message logging enabled [default=no]])],
Daniel Drake852bba42007-11-28 13:48:45 +0000263 [debug_log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800264 [debug_log_enabled=no])
Chris Dickens94178682017-01-12 13:50:35 -0800265if test "x$debug_log_enabled" != xno; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700266 AC_DEFINE([ENABLE_DEBUG_LOGGING], [1], [Define to 1 to start with debug message logging enabled.])
Daniel Drake852bba42007-11-28 13:48:45 +0000267fi
268
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800269AC_ARG_ENABLE([system-log],
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700270 [AS_HELP_STRING([--enable-system-log], [output logging messages to the systemwide log, if supported by the OS [default=no]])],
Toby Gray9222a542013-07-09 16:05:39 +0100271 [system_log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800272 [system_log_enabled=no])
Chris Dickens94178682017-01-12 13:50:35 -0800273if test "x$system_log_enabled" != xno; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700274 AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], [1], [Define to 1 to output logging messages to the systemwide log.])
275 if test "x$backend" != xwindows && test "x$is_android_linux" != xyes; then
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800276 dnl Check if syslog is available in standard C library
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700277 AC_CHECK_HEADER([syslog.h], [syslog_h=yes], [syslog_h=])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800278 if test "x$syslog_h" = xyes; then
279 AC_CHECK_FUNCS([syslog])
280 fi
Chris Dickens94178682017-01-12 13:50:35 -0800281 fi
Toby Gray9222a542013-07-09 16:05:39 +0100282fi
283
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800284dnl Examples build
285AC_ARG_ENABLE([examples-build],
286 [AS_HELP_STRING([--enable-examples-build], [build example applications [default=no]])],
Daniel Drake852bba42007-11-28 13:48:45 +0000287 [build_examples=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800288 [build_examples=no])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700289if test "x$build_examples" != xno; then
290 dnl sigaction needed for some example programs
291 AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=])
292fi
Daniel Drake852bba42007-11-28 13:48:45 +0000293
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800294dnl Tests build
295AC_ARG_ENABLE([tests-build],
296 [AS_HELP_STRING([--enable-tests-build], [build test applications [default=no]])],
Toby Gray21cf6e42012-11-21 14:00:31 +0000297 [build_tests=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800298 [build_tests=no])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700299
300AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != xno])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800301AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != xno])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700302AM_CONDITIONAL([CREATE_IMPORT_LIB], [test "x$create_import_lib" = xyes])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800303AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = xyes])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700304AM_CONDITIONAL([OS_DARWIN], [test "x$backend" = xdarwin])
305AM_CONDITIONAL([OS_HAIKU], [test "x$backend" = xhaiku])
306AM_CONDITIONAL([OS_LINUX], [test "x$backend" = xlinux])
307AM_CONDITIONAL([OS_NETBSD], [test "x$backend" = xnetbsd])
308AM_CONDITIONAL([OS_NULL], [test "x$backend" = xnull])
309AM_CONDITIONAL([OS_OPENBSD], [test "x$backend" = xopenbsd])
310AM_CONDITIONAL([OS_SUNOS], [test "x$backend" = xsunos])
311AM_CONDITIONAL([OS_WINDOWS], [test "x$backend" = xwindows])
312AM_CONDITIONAL([POLL_POSIX], [test "x$poll" = xposix])
313AM_CONDITIONAL([POLL_WINDOWS], [test "x$poll" = xwindows])
314AM_CONDITIONAL([THREADS_POSIX], [test "x$threads" = xposix])
315AM_CONDITIONAL([THREADS_WINDOWS], [test "x$threads" = xwindows])
316AM_CONDITIONAL([USE_UDEV], [test "x$use_udev" = xyes])
Chris Dickens94178682017-01-12 13:50:35 -0800317
Chris Dickens95bbfb62020-03-30 12:38:47 -0700318dnl The -Wcast-function-type warning causes a flurry of warnings when compiling
319dnl Windows with GCC 8 or later because of dynamically loaded functions
320if test "x$backend" = xwindows; then
321 saved_CFLAGS="${CFLAGS}"
322 CFLAGS="-Werror -Wcast-function-type"
323 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
Chris Dickens7c0cea72020-04-09 11:30:19 -0700324 [EXTRA_CFLAGS="${EXTRA_CFLAGS} -Wno-cast-function-type"],
Chris Dickens95bbfb62020-03-30 12:38:47 -0700325 [])
326 CFLAGS="${saved_CFLAGS}"
327fi
328
Chris Dickens7c0cea72020-04-09 11:30:19 -0700329SHARED_CFLAGS="-Wall -Wextra -Wshadow -Wunused -Wwrite-strings -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=init-self -Werror=missing-prototypes -Werror=strict-prototypes -Werror=undef -Werror=uninitialized"
330
331AM_CFLAGS="-std=${c_dialect}11 ${EXTRA_CFLAGS} ${SHARED_CFLAGS}"
Daniel Drake852bba42007-11-28 13:48:45 +0000332AC_SUBST(AM_CFLAGS)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700333
Chris Dickens7c0cea72020-04-09 11:30:19 -0700334AM_CXXFLAGS="-std=${c_dialect}++11 ${EXTRA_CFLAGS} ${SHARED_CFLAGS} -Wmissing-declarations"
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700335AC_SUBST(AM_CXXFLAGS)
336
337AC_SUBST(LT_LDFLAGS)
Daniel Drake852bba42007-11-28 13:48:45 +0000338
Chris Dickens4a5540a2020-03-25 00:09:26 -0700339dnl set name of html output directory for doxygen
340AC_SUBST(DOXYGEN_HTMLDIR, [api-1.0])
341
Peter Stugeef39d152011-02-25 02:33:29 +0100342AC_CONFIG_FILES([libusb-1.0.pc])
343AC_CONFIG_FILES([Makefile])
344AC_CONFIG_FILES([libusb/Makefile])
Peter Stugeef39d152011-02-25 02:33:29 +0100345AC_CONFIG_FILES([examples/Makefile])
Toby Gray21cf6e42012-11-21 14:00:31 +0000346AC_CONFIG_FILES([tests/Makefile])
Peter Stugeef39d152011-02-25 02:33:29 +0100347AC_CONFIG_FILES([doc/Makefile])
348AC_CONFIG_FILES([doc/doxygen.cfg])
Daniel Drake852bba42007-11-28 13:48:45 +0000349AC_OUTPUT