blob: 32f4244a83cf98ee3ee1034d5e0f67ef459dc306 [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 Dickens9a1bc8c2020-03-30 12:28:11 -070041dnl check for -std=gnu11 compiler support (optional)
42dnl note that we don't just check whether the compiler accepts '-std=x11'
43dnl but also that it supports the _Thread_local keyword because some compilers
44dnl (e.g. gcc 4.8) accept the command line option but do not implement TLS
45saved_CFLAGS="${CFLAGS}"
46CFLAGS="-std=gnu11"
47AC_MSG_CHECKING([whether CC supports -std=gnu11])
48AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
49 [AC_MSG_RESULT([yes])
50 cc_supports_gnu11=yes],
51 [AC_MSG_RESULT([no])
52 cc_supports_gnu11=])
53CFLAGS="${saved_CFLAGS}"
Daniel Drake852bba42007-11-28 13:48:45 +000054
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070055if test "x$cc_supports_gnu11" = xyes; then
56 AM_CFLAGS="-std=gnu11"
57else
58 dnl fallback check for -std=c11 compiler support (required)
59 saved_CFLAGS="${CFLAGS}"
60 CFLAGS="-std=c11"
61 AC_MSG_CHECKING([whether CC supports -std=c11])
62 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
63 [AC_MSG_RESULT([yes])],
64 [AC_MSG_RESULT([no])
65 AC_MSG_ERROR([compiler with C11 support is required to build libusb])])
66 CFLAGS="${saved_CFLAGS}"
67 AM_CFLAGS="-std=c11"
68fi
Peter Stuge717f4762010-11-15 19:58:51 +010069
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070070AC_DEFINE([_GNU_SOURCE], [1], [Enable GNU extensions.])
71AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__ ((visibility ("default")))], [Define to the attribute for default visibility.])
72
73create_import_lib=
74is_android_linux=
Daniel Drakec0c94322008-03-13 12:36:56 +000075AC_MSG_CHECKING([operating system])
Kuangye Guo7e3de5d2013-10-21 18:36:15 -070076case $host in
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030077*-darwin*)
Peter Stuge0bd4a4d2011-02-26 04:08:38 +010078 AC_MSG_RESULT([Darwin/Mac OS X])
Chris Dickenscb77a252017-02-20 00:18:33 -080079 backend=darwin
Chris Dickensd5bb64b2020-01-22 17:39:14 -080080 poll=posix
Chris Dickenscb77a252017-02-20 00:18:33 -080081 threads=posix
Pete Batard9a4249f2010-07-10 17:51:13 -060082 ;;
Akshay Jaggidc974252014-09-24 22:46:17 +010083*-haiku*)
84 AC_MSG_RESULT([Haiku])
Chris Dickenscb77a252017-02-20 00:18:33 -080085 backend=haiku
Chris Dickensd5bb64b2020-01-22 17:39:14 -080086 poll=posix
87 threads=posix
88 ;;
89*-linux* | *-uclinux*)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070090 dnl on Android Linux, some functions are in different places
Chris Dickensd5bb64b2020-01-22 17:39:14 -080091 case $host in
92 *-linux-android*)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -070093 AC_MSG_RESULT([Android Linux])
94 is_android_linux=yes
Chris Dickensd5bb64b2020-01-22 17:39:14 -080095 ;;
96 *)
97 AC_MSG_RESULT([Linux])
Chris Dickensd5bb64b2020-01-22 17:39:14 -080098 ;;
99 esac
100 backend=linux
101 poll=posix
102 threads=posix
103 ;;
104*-netbsd*)
105 AC_MSG_RESULT([NetBSD])
106 backend=netbsd
107 poll=posix
108 threads=posix
109 ;;
110*-openbsd*)
111 AC_MSG_RESULT([OpenBSD])
112 backend=openbsd
113 poll=posix
Chris Dickenscb77a252017-02-20 00:18:33 -0800114 threads=posix
Akshay Jaggidc974252014-09-24 22:46:17 +0100115 ;;
Lei Cheneefd3222016-02-19 11:58:39 +0800116*-solaris*)
117 AC_MSG_RESULT([SunOS])
Chris Dickenscb77a252017-02-20 00:18:33 -0800118 backend=sunos
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800119 poll=posix
Chris Dickenscb77a252017-02-20 00:18:33 -0800120 threads=posix
Lei Cheneefd3222016-02-19 11:58:39 +0800121 ;;
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800122*-cygwin*)
123 AC_MSG_RESULT([Windows (using Cygwin)])
124 backend=windows
125 poll=windows
126 threads=posix
127 ;;
128*-mingw* | *msys*)
129 AC_MSG_RESULT([Windows])
130 backend=windows
131 poll=windows
132 threads=windows
Chris Dickens4a5540a2020-03-25 00:09:26 -0700133 test "x$enable_shared" = xyes && create_import_lib=yes
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800134 AM_CFLAGS="${AM_CFLAGS} -fno-omit-frame-pointer"
135 ;;
Daniel Drakec0c94322008-03-13 12:36:56 +0000136*)
Pino Toscano53572d72019-12-27 18:41:28 +0100137 AC_MSG_RESULT([Null])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700138 AC_MSG_WARN([The host being compiled for is not supported.])
139 AC_MSG_WARN([The library may compile but will not function in any useful manner.])
Pino Toscano53572d72019-12-27 18:41:28 +0100140 backend="null"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800141 poll=posix
Pino Toscano53572d72019-12-27 18:41:28 +0100142 threads="posix"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800143 ;;
Daniel Drakec0c94322008-03-13 12:36:56 +0000144esac
Pete Batard968df122012-04-19 18:01:04 +0100145
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700146if test "x$poll" = xposix; then
147 AC_DEFINE([POLL_POSIX], [1], [Define to 1 if using the POSIX poll() implementation.])
148 AC_CHECK_TYPES([nfds_t], [], [], [[#include <poll.h>]])
149 AC_CHECK_FUNCS([pipe2])
150elif test "x$poll" = xwindows; then
151 AC_DEFINE([POLL_WINDOWS], [1], [Define to 1 if using the Windows poll() implementation.])
152else
153 AC_MSG_ERROR([Unknown poll implementation])
154fi
155
156if test "x$threads" = xposix; then
157 AC_DEFINE([THREADS_POSIX], [1], [Define to 1 if using POSIX threads.])
158 AC_SUBST(THREAD_CFLAGS, [-pthread])
159 dnl Android Linux and Darwin provide pthread functions directly in libc
160 dnl glibc also provides some pthread functions directly, so search for a thread-specific function
161 AC_SEARCH_LIBS([pthread_key_create], [pthread], [AC_SUBST(THREAD_LIBS, [-lpthread])], [], [])
162elif test "x$threads" = xwindows; then
163 AC_DEFINE([THREADS_WINDOWS], [1], [Define to 1 if using Windows threads.])
164else
165 AC_MSG_ERROR([Unknown threads implementation])
166fi
167
Pete Batard968df122012-04-19 18:01:04 +0100168case $backend in
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800169darwin)
Chris Dickens30b56ba2020-03-27 00:03:41 -0700170 AC_CHECK_FUNCS([pthread_threadid_np])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700171 LIBS="${LIBS} -lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800172 ;;
173haiku)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700174 LIBS="${LIBS} -lbe"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800175 ;;
Pete Batard968df122012-04-19 18:01:04 +0100176linux)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700177 AC_SEARCH_LIBS([clock_gettime], [rt], [], [], [])
178 AC_CHECK_FUNCS([pthread_setname_np])
Nathan Hjelm68532912012-11-29 16:14:03 -0700179 AC_ARG_ENABLE([udev],
Toby Gray9222a542013-07-09 16:05:39 +0100180 [AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended) [default=yes]])],
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700181 [use_udev=$enableval], [use_udev=yes])
182 if test "x$use_udev" = xyes; then
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800183 dnl system has udev. use it or fail!
184 AC_CHECK_HEADER([libudev.h], [], [AC_MSG_ERROR([udev support requested but libudev header not installed])])
185 AC_CHECK_LIB([udev], [udev_new], [], [AC_MSG_ERROR([udev support requested but libudev not installed])])
186 else
187 AC_CHECK_HEADERS([asm/types.h])
188 AC_CHECK_HEADER([linux/netlink.h], [], [AC_MSG_ERROR([Linux netlink header not found])])
189 AC_CHECK_HEADER([sys/socket.h], [], [AC_MSG_ERROR([Linux socket header not found])])
190 fi
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800191 ;;
192sunos)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700193 LIBS="${LIBS} -ldevinfo"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800194 ;;
195windows)
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800196 AC_CHECK_TYPES([struct timespec], [], [], [[#include <time.h>]])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700197 AC_DEFINE([_WIN32_WINNT], [_WIN32_WINNT_VISTA], [Define to the oldest supported Windows version.])
198 LT_LDFLAGS="${LT_LDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800199 ;;
200*)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700201 dnl no special handling required
Pino Toscano53572d72019-12-27 18:41:28 +0100202 ;;
Pete Batard968df122012-04-19 18:01:04 +0100203esac
204
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800205dnl headers not available on all platforms but required on others
206AC_CHECK_HEADERS([sys/time.h])
207
Chris Dickens26b16eb2020-01-26 22:43:28 -0800208dnl the clock_gettime() function needs certain clock IDs defined
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700209AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [have_clock_gettime=])
Chris Dickens26b16eb2020-01-26 22:43:28 -0800210if test "x$have_clock_gettime" = xyes; then
211 AC_CHECK_DECL([CLOCK_REALTIME], [], [AC_MSG_ERROR([C library headers missing definition for CLOCK_REALTIME])], [[#include <time.h>]])
212 AC_CHECK_DECL([CLOCK_MONOTONIC], [], [AC_MSG_ERROR([C library headers missing definition for CLOCK_MONOTONIC])], [[#include <time.h>]])
213elif test "x$backend" != xdarwin && test "x$backend" != xwindows; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700214 AC_MSG_ERROR([clock_gettime() is required on this platform])
Chris Dickens26b16eb2020-01-26 22:43:28 -0800215fi
216
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800217dnl timerfd support
218if 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
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700224 AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=yes], [timerfd_h=])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800225 if test "x$timerfd_h" = xyes; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700226 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 -0800227 if test "x$timerfd_h_ok" = xyes; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700228 AC_CHECK_FUNC([timerfd_create], [timerfd_ok=yes], [timerfd_ok=])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800229 if test "x$timerfd_ok" = xyes; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700230 AC_DEFINE([HAVE_TIMERFD], [1], [Define to 1 if the system has timerfd functionality.])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800231 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)])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700244 elif test "x$timerfd_h" != xyes; then
Daniel Drake47830082009-10-28 20:33:49 +0545245 AC_MSG_RESULT([no (header not available)])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700246 elif test "x$timerfd_h_ok" != xyes; then
247 AC_MSG_RESULT([no (header not usable)])
248 elif test "x$timerfd_ok" != xyes; then
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800249 AC_MSG_RESULT([no (functions not available)])
250 else
251 AC_MSG_RESULT([yes])
Daniel Drake47830082009-10-28 20:33:49 +0545252 fi
253fi
254
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800255dnl Message logging
256AC_ARG_ENABLE([log],
257 [AS_HELP_STRING([--disable-log], [disable all logging])],
Daniel Drake852bba42007-11-28 13:48:45 +0000258 [log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800259 [log_enabled=yes])
Chris Dickens94178682017-01-12 13:50:35 -0800260if test "x$log_enabled" != xno; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700261 AC_DEFINE([ENABLE_LOGGING], [1], [Define to 1 to enable message logging.])
Daniel Drake852bba42007-11-28 13:48:45 +0000262fi
263
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800264AC_ARG_ENABLE([debug-log],
265 [AS_HELP_STRING([--enable-debug-log], [start with debug message logging enabled [default=no]])],
Daniel Drake852bba42007-11-28 13:48:45 +0000266 [debug_log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800267 [debug_log_enabled=no])
Chris Dickens94178682017-01-12 13:50:35 -0800268if test "x$debug_log_enabled" != xno; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700269 AC_DEFINE([ENABLE_DEBUG_LOGGING], [1], [Define to 1 to start with debug message logging enabled.])
Daniel Drake852bba42007-11-28 13:48:45 +0000270fi
271
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800272AC_ARG_ENABLE([system-log],
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700273 [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 +0100274 [system_log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800275 [system_log_enabled=no])
Chris Dickens94178682017-01-12 13:50:35 -0800276if test "x$system_log_enabled" != xno; then
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700277 AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], [1], [Define to 1 to output logging messages to the systemwide log.])
278 if test "x$backend" != xwindows && test "x$is_android_linux" != xyes; then
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800279 dnl Check if syslog is available in standard C library
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700280 AC_CHECK_HEADER([syslog.h], [syslog_h=yes], [syslog_h=])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800281 if test "x$syslog_h" = xyes; then
282 AC_CHECK_FUNCS([syslog])
283 fi
Chris Dickens94178682017-01-12 13:50:35 -0800284 fi
Toby Gray9222a542013-07-09 16:05:39 +0100285fi
286
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800287dnl Examples build
288AC_ARG_ENABLE([examples-build],
289 [AS_HELP_STRING([--enable-examples-build], [build example applications [default=no]])],
Daniel Drake852bba42007-11-28 13:48:45 +0000290 [build_examples=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800291 [build_examples=no])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700292if test "x$build_examples" != xno; then
293 dnl sigaction needed for some example programs
294 AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=])
295fi
Daniel Drake852bba42007-11-28 13:48:45 +0000296
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800297dnl Tests build
298AC_ARG_ENABLE([tests-build],
299 [AS_HELP_STRING([--enable-tests-build], [build test applications [default=no]])],
Toby Gray21cf6e42012-11-21 14:00:31 +0000300 [build_tests=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800301 [build_tests=no])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700302
303AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != xno])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800304AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != xno])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700305AM_CONDITIONAL([CREATE_IMPORT_LIB], [test "x$create_import_lib" = xyes])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800306AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = xyes])
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700307AM_CONDITIONAL([OS_DARWIN], [test "x$backend" = xdarwin])
308AM_CONDITIONAL([OS_HAIKU], [test "x$backend" = xhaiku])
309AM_CONDITIONAL([OS_LINUX], [test "x$backend" = xlinux])
310AM_CONDITIONAL([OS_NETBSD], [test "x$backend" = xnetbsd])
311AM_CONDITIONAL([OS_NULL], [test "x$backend" = xnull])
312AM_CONDITIONAL([OS_OPENBSD], [test "x$backend" = xopenbsd])
313AM_CONDITIONAL([OS_SUNOS], [test "x$backend" = xsunos])
314AM_CONDITIONAL([OS_WINDOWS], [test "x$backend" = xwindows])
315AM_CONDITIONAL([POLL_POSIX], [test "x$poll" = xposix])
316AM_CONDITIONAL([POLL_WINDOWS], [test "x$poll" = xwindows])
317AM_CONDITIONAL([THREADS_POSIX], [test "x$threads" = xposix])
318AM_CONDITIONAL([THREADS_WINDOWS], [test "x$threads" = xwindows])
319AM_CONDITIONAL([USE_UDEV], [test "x$use_udev" = xyes])
Chris Dickens94178682017-01-12 13:50:35 -0800320
Chris Dickens95bbfb62020-03-30 12:38:47 -0700321EXTRA_CFLAGS=
322
323dnl The -Wcast-function-type warning causes a flurry of warnings when compiling
324dnl Windows with GCC 8 or later because of dynamically loaded functions
325if test "x$backend" = xwindows; then
326 saved_CFLAGS="${CFLAGS}"
327 CFLAGS="-Werror -Wcast-function-type"
328 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
329 [EXTRA_CFLAGS="-Wno-cast-function-type"],
330 [])
331 CFLAGS="${saved_CFLAGS}"
332fi
333
334AM_CFLAGS="${AM_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 ${EXTRA_CFLAGS}"
Daniel Drake852bba42007-11-28 13:48:45 +0000335AC_SUBST(AM_CFLAGS)
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700336
Chris Dickens95bbfb62020-03-30 12:38:47 -0700337AM_CXXFLAGS="${AM_CFLAGS} -Wmissing-declarations"
Chris Dickens9a1bc8c2020-03-30 12:28:11 -0700338AC_SUBST(AM_CXXFLAGS)
339
340AC_SUBST(LT_LDFLAGS)
Daniel Drake852bba42007-11-28 13:48:45 +0000341
Chris Dickens4a5540a2020-03-25 00:09:26 -0700342dnl set name of html output directory for doxygen
343AC_SUBST(DOXYGEN_HTMLDIR, [api-1.0])
344
Peter Stugeef39d152011-02-25 02:33:29 +0100345AC_CONFIG_FILES([libusb-1.0.pc])
346AC_CONFIG_FILES([Makefile])
347AC_CONFIG_FILES([libusb/Makefile])
Peter Stugeef39d152011-02-25 02:33:29 +0100348AC_CONFIG_FILES([examples/Makefile])
Toby Gray21cf6e42012-11-21 14:00:31 +0000349AC_CONFIG_FILES([tests/Makefile])
Peter Stugeef39d152011-02-25 02:33:29 +0100350AC_CONFIG_FILES([doc/Makefile])
351AC_CONFIG_FILES([doc/doxygen.cfg])
Daniel Drake852bba42007-11-28 13:48:45 +0000352AC_OUTPUT