blob: a9eddbad39832c5fc68f3c356fdeda19f751cea9 [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
hjelmn@cs.unm.edu1eff2202014-01-08 23:50:34 +000018AC_INIT([libusb],[LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC],[libusb-devel@lists.sourceforge.net],[libusb],[http://libusb.info])
Daniel Draked7c25452010-10-04 20:03:58 +010019
Chris Dickensd5bb64b2020-01-22 17:39:14 -080020dnl Library versioning
21dnl These numbers should be tweaked on every release. Read carefully:
22dnl http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
23dnl http://sourceware.org/autobook/autobook/autobook_91.html
Nathan Hjelmfde20bb2018-12-05 10:36:50 -070024lt_current=2
Chris Dickenscb77a252017-02-20 00:18:33 -080025lt_revision=0
Ludovic Rousseau767eafb2019-08-08 00:13:17 +020026lt_age=2
Peter Stuge717f4762010-11-15 19:58:51 +010027LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}"
Pete Batard9a4249f2010-07-10 17:51:13 -060028
Daniel Drake852bba42007-11-28 13:48:45 +000029AM_INIT_AUTOMAKE
Peter Stuge6e52ea02010-11-21 23:37:27 +010030
Daniel Drakee9364d72008-01-04 00:40:49 +000031AC_CONFIG_SRCDIR([libusb/core.c])
Daniel Drake8be25602009-06-13 17:19:07 +010032AC_CONFIG_MACRO_DIR([m4])
Ludovic Rousseauc9d41fe2012-06-01 11:30:00 +020033AC_CONFIG_HEADERS([config.h])
Daniel Drake9b120c22009-11-07 10:03:07 +000034m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
Daniel Drake852bba42007-11-28 13:48:45 +000035
Nathan Hjelm2040ab12016-03-10 12:57:50 -070036AC_PREREQ([2.69])
Daniel Drake852bba42007-11-28 13:48:45 +000037AC_PROG_CC
Chris Dickens3dc781c2015-12-03 12:59:20 -080038AC_PROG_CXX
Ludovic Rousseauc9d41fe2012-06-01 11:30:00 +020039LT_INIT
Peter Stugefa9b6822011-09-22 21:17:37 +020040LT_LANG([Windows Resource])
Daniel Drake852bba42007-11-28 13:48:45 +000041AC_C_INLINE
42AM_PROG_CC_C_O
Chris Dickensd5bb64b2020-01-22 17:39:14 -080043AC_DEFINE([_GNU_SOURCE], [1], [Use GNU extensions])
Daniel Drake852bba42007-11-28 13:48:45 +000044
Peter Stuge717f4762010-11-15 19:58:51 +010045LTLDFLAGS="${LTLDFLAGS} -no-undefined"
46
Daniel Drakec0c94322008-03-13 12:36:56 +000047AC_MSG_CHECKING([operating system])
Kuangye Guo7e3de5d2013-10-21 18:36:15 -070048case $host in
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030049*-darwin*)
Peter Stuge0bd4a4d2011-02-26 04:08:38 +010050 AC_MSG_RESULT([Darwin/Mac OS X])
Chris Dickenscb77a252017-02-20 00:18:33 -080051 backend=darwin
Chris Dickensd5bb64b2020-01-22 17:39:14 -080052 poll=posix
Chris Dickenscb77a252017-02-20 00:18:33 -080053 threads=posix
Pete Batard9a4249f2010-07-10 17:51:13 -060054 ;;
Akshay Jaggidc974252014-09-24 22:46:17 +010055*-haiku*)
56 AC_MSG_RESULT([Haiku])
Chris Dickenscb77a252017-02-20 00:18:33 -080057 backend=haiku
Chris Dickensd5bb64b2020-01-22 17:39:14 -080058 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 Dickenscb77a252017-02-20 00:18:33 -080087 threads=posix
Akshay Jaggidc974252014-09-24 22:46:17 +010088 ;;
Lei Cheneefd3222016-02-19 11:58:39 +080089*-solaris*)
90 AC_MSG_RESULT([SunOS])
Chris Dickenscb77a252017-02-20 00:18:33 -080091 backend=sunos
Chris Dickensd5bb64b2020-01-22 17:39:14 -080092 poll=posix
Chris Dickenscb77a252017-02-20 00:18:33 -080093 threads=posix
Lei Cheneefd3222016-02-19 11:58:39 +080094 ;;
Chris Dickensd5bb64b2020-01-22 17:39:14 -080095*-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 Drakec0c94322008-03-13 12:36:56 +0000109*)
Pino Toscano53572d72019-12-27 18:41:28 +0100110 AC_MSG_RESULT([Null])
111 backend="null"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800112 poll=posix
Pino Toscano53572d72019-12-27 18:41:28 +0100113 threads="posix"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800114 ;;
Daniel Drakec0c94322008-03-13 12:36:56 +0000115esac
Pete Batard968df122012-04-19 18:01:04 +0100116
117case $backend in
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800118darwin)
119 AC_DEFINE([OS_DARWIN], [1], [Darwin backend])
120 LIBS="-lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation"
121 LTLDFLAGS="${LTLDFLAGS} -Wl,-prebind"
122 ;;
123haiku)
124 AC_DEFINE([OS_HAIKU], [1], [Haiku backend])
125 LIBS="-lbe"
126 ;;
Pete Batard968df122012-04-19 18:01:04 +0100127linux)
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800128 AC_DEFINE([OS_LINUX], [1], [Linux backend])
Baruch Siach552a4a42018-06-05 14:22:21 +0300129 AC_SEARCH_LIBS([clock_gettime], [rt], [], [], [-pthread])
Nathan Hjelm68532912012-11-29 16:14:03 -0700130 AC_ARG_ENABLE([udev],
Toby Gray9222a542013-07-09 16:05:39 +0100131 [AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended) [default=yes]])],
Chris Dickenscb77a252017-02-20 00:18:33 -0800132 [], [enable_udev=yes])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800133 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 Dickens068b5942017-01-12 11:01:59 -0800142 if test "x$is_backend_android" != xyes; then
143 THREAD_CFLAGS="-pthread"
144 LIBS="${LIBS} -pthread"
145 fi
Alexander Stein6e0028c2020-02-05 21:41:07 +0100146 AC_CHECK_FUNCS([pthread_setname_np])
Lei Cheneefd3222016-02-19 11:58:39 +0800147 ;;
Hans de Goedeeb4e7be2013-08-21 16:18:39 +0200148netbsd)
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800149 AC_DEFINE([OS_NETBSD], [1], [NetBSD backend])
Hans de Goedeeb4e7be2013-08-21 16:18:39 +0200150 THREAD_CFLAGS="-pthread"
151 LIBS="-pthread"
Akshay Jaggidc974252014-09-24 22:46:17 +0100152 ;;
Pino Toscano53572d72019-12-27 18:41:28 +0100153null)
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800154 AC_DEFINE([OS_NULL], [1], [Null backend])
Pino Toscano53572d72019-12-27 18:41:28 +0100155 THREAD_CFLAGS="-pthread"
156 LIBS="-pthread"
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800157 ;;
158openbsd)
159 AC_DEFINE([OS_OPENBSD], [1], [OpenBSD backend])
160 THREAD_CFLAGS="-pthread"
161 LIBS="-pthread"
162 ;;
163sunos)
164 AC_DEFINE([OS_SUNOS], [1], [SunOS backend])
165 THREAD_CFLAGS="-pthread"
166 LIBS="-pthread -ldevinfo"
167 ;;
168windows)
169 AC_DEFINE([OS_WINDOWS], [1], [Windows backend])
170 AC_CHECK_TYPES([struct timespec], [], [], [[#include <time.h>]])
171 LIBS=""
172 LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
173 AC_DEFINE([_WIN32_WINNT], [_WIN32_WINNT_VISTA], [Oldest Windows version supported (Vista)])
174 ;;
175*)
176 AC_MSG_ERROR([Unknown backend])
Pino Toscano53572d72019-12-27 18:41:28 +0100177 ;;
Pete Batard968df122012-04-19 18:01:04 +0100178esac
179
Peter Stuge94b0ccc2012-10-23 00:15:23 +0000180AC_SUBST(LIBS)
Daniel Drakec0c94322008-03-13 12:36:56 +0000181
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800182AM_CONDITIONAL([OS_DARWIN], [test "x$backend" = xdarwin])
183AM_CONDITIONAL([OS_HAIKU], [test "x$backend" = xhaiku])
184AM_CONDITIONAL([OS_LINUX], [test "x$backend" = xlinux])
185AM_CONDITIONAL([OS_NETBSD], [test "x$backend" = xnetbsd])
186AM_CONDITIONAL([OS_NULL], [test "x$backend" = xnull])
187AM_CONDITIONAL([OS_OPENBSD], [test "x$backend" = xopenbsd])
188AM_CONDITIONAL([OS_SUNOS], [test "x$backend" = xsunos])
189AM_CONDITIONAL([OS_WINDOWS], [test "x$backend" = xwindows])
Chris Dickensa96937a2020-01-26 14:29:48 -0800190AM_CONDITIONAL([POLL_POSIX], [test "x$poll" = xposix])
191AM_CONDITIONAL([POLL_WINDOWS], [test "x$poll" = xwindows])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800192AM_CONDITIONAL([THREADS_POSIX], [test "x$threads" = xposix])
193AM_CONDITIONAL([THREADS_WINDOWS], [test "x$threads" = xwindows])
194AM_CONDITIONAL([CREATE_IMPORT_LIB], [test "x$create_import_lib" = xyes])
195AM_CONDITIONAL([USE_UDEV], [test "x$enable_udev" = xyes])
Daniel Drakec0c94322008-03-13 12:36:56 +0000196
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800197if test "x$poll" = xposix; then
198 AC_DEFINE([POLL_POSIX], [1], [Use POSIX poll() implementation])
199 AC_CHECK_TYPES([nfds_t], [], [], [[#include <poll.h>]])
200 AC_CHECK_FUNCS([pipe2])
201elif test "x$poll" = xwindows; then
202 AC_DEFINE([POLL_WINDOWS], [1], [Use Windows poll() implementation])
Daniel Drake47830082009-10-28 20:33:49 +0545203else
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800204 AC_MSG_ERROR([Unknown poll implementation])
205fi
206
207if test "x$threads" = xposix; then
208 AC_DEFINE([THREADS_POSIX], [1], [Use POSIX Threads])
209elif test "x$threads" = xwindows; then
210 AC_DEFINE([THREADS_WINDOWS], [1], [Use Windows Threads])
211else
212 AC_MSG_ERROR([Unknown threads implementation])
213fi
214
215dnl headers not available on all platforms but required on others
216AC_CHECK_HEADERS([sys/time.h])
217
Chris Dickens26b16eb2020-01-26 22:43:28 -0800218dnl the clock_gettime() function needs certain clock IDs defined
219AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [have_clockgettime=no])
220if test "x$have_clock_gettime" = xyes; then
221 AC_CHECK_DECL([CLOCK_REALTIME], [], [AC_MSG_ERROR([C library headers missing definition for CLOCK_REALTIME])], [[#include <time.h>]])
222 AC_CHECK_DECL([CLOCK_MONOTONIC], [], [AC_MSG_ERROR([C library headers missing definition for CLOCK_MONOTONIC])], [[#include <time.h>]])
223elif test "x$backend" != xdarwin && test "x$backend" != xwindows; then
224 AC_MSG_ERROR([clock_gettime() is required on this platform])
225fi
226
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800227dnl timerfd support
228if test "x$backend" = xlinux || test "x$backend" = xsunos; then
229 AC_ARG_ENABLE([timerfd],
230 [AS_HELP_STRING([--enable-timerfd], [use timerfd for timing [default=auto]])],
231 [use_timerfd=$enableval],
232 [use_timerfd=auto])
233 if test "x$use_timerfd" != xno; then
234 AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=yes], [timerfd_h=no])
235 if test "x$timerfd_h" = xyes; then
236 AC_CHECK_DECLS([TFD_NONBLOCK, TFD_CLOEXEC], [timerfd_h_ok=yes], [timerfd_h_ok=no], [[#include <sys/timerfd.h>]])
237 if test "x$timerfd_h_ok" = xyes; then
238 AC_CHECK_FUNC([timerfd_create], [timerfd_ok=yes], [timerfd_ok=no])
239 if test "x$timerfd_ok" = xyes; then
240 AC_DEFINE([HAVE_TIMERFD], [1], [Define if the system has timerfd functionality])
241 elif test "x$use_timerfd" = xyes; then
242 AC_MSG_ERROR([timerfd_create() function not found; glibc 2.9+ required])
243 fi
244 elif test "x$use_timerfd" = xyes; then
245 AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
246 fi
247 elif test "x$use_timerfd" = xyes; then
248 AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
249 fi
250 fi
251 AC_MSG_CHECKING([whether to use timerfd for timing])
252 if test "x$use_timerfd" = xno; then
253 AC_MSG_RESULT([no (disabled by user)])
254 elif test "x$timerfd_h" = xno; then
255 AC_MSG_RESULT([no (header not usable)])
256 elif test "x$timerfd_h_ok" = xno; then
Daniel Drake47830082009-10-28 20:33:49 +0545257 AC_MSG_RESULT([no (header not available)])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800258 elif test "x$timerfd_ok" = xno; then
259 AC_MSG_RESULT([no (functions not available)])
260 else
261 AC_MSG_RESULT([yes])
Daniel Drake47830082009-10-28 20:33:49 +0545262 fi
263fi
264
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800265dnl Message logging
266AC_ARG_ENABLE([log],
267 [AS_HELP_STRING([--disable-log], [disable all logging])],
Daniel Drake852bba42007-11-28 13:48:45 +0000268 [log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800269 [log_enabled=yes])
Chris Dickens94178682017-01-12 13:50:35 -0800270if test "x$log_enabled" != xno; then
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800271 AC_DEFINE([ENABLE_LOGGING], [1], [Message logging])
Daniel Drake852bba42007-11-28 13:48:45 +0000272fi
273
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800274AC_ARG_ENABLE([debug-log],
275 [AS_HELP_STRING([--enable-debug-log], [start with debug message logging enabled [default=no]])],
Daniel Drake852bba42007-11-28 13:48:45 +0000276 [debug_log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800277 [debug_log_enabled=no])
Chris Dickens94178682017-01-12 13:50:35 -0800278if test "x$debug_log_enabled" != xno; then
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800279 AC_DEFINE([ENABLE_DEBUG_LOGGING], [1], [Start with debug message logging enabled])
Daniel Drake852bba42007-11-28 13:48:45 +0000280fi
281
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800282AC_ARG_ENABLE([system-log],
283 [AS_HELP_STRING([--enable-system-log], [output logging messages to system wide log, if supported by the OS [default=no]])],
Toby Gray9222a542013-07-09 16:05:39 +0100284 [system_log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800285 [system_log_enabled=no])
Chris Dickens94178682017-01-12 13:50:35 -0800286if test "x$system_log_enabled" != xno; then
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800287 AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], [1], [Enable output to system log])
288 if test "x$backend" != xwindows && test "x$is_backend_android" != xyes; then
289 dnl Check if syslog is available in standard C library
290 AC_CHECK_HEADER([syslog.h], [syslog_h=yes], [syslog_h=no])
291 if test "x$syslog_h" = xyes; then
292 AC_CHECK_FUNCS([syslog])
293 fi
Chris Dickens94178682017-01-12 13:50:35 -0800294 fi
Toby Gray9222a542013-07-09 16:05:39 +0100295fi
296
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800297dnl Examples build
298AC_ARG_ENABLE([examples-build],
299 [AS_HELP_STRING([--enable-examples-build], [build example applications [default=no]])],
Daniel Drake852bba42007-11-28 13:48:45 +0000300 [build_examples=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800301 [build_examples=no])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800302AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != xno])
Daniel Drake852bba42007-11-28 13:48:45 +0000303
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800304dnl Tests build
305AC_ARG_ENABLE([tests-build],
306 [AS_HELP_STRING([--enable-tests-build], [build test applications [default=no]])],
Toby Gray21cf6e42012-11-21 14:00:31 +0000307 [build_tests=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800308 [build_tests=no])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800309AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != xno])
Chris Dickens94178682017-01-12 13:50:35 -0800310
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800311dnl sigaction needed for some example programs
312if test "x$build_examples" != xno; then
313 AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no])
314fi
315AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = xyes])
Chris Dickens94178682017-01-12 13:50:35 -0800316
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800317dnl check for -fvisibility=hidden compiler support (GCC >= 3.4)
318saved_CFLAGS="${CFLAGS}"
319dnl -Werror required for cygwin
320CFLAGS="${CFLAGS} -Werror -fvisibility=hidden"
Peter Stuge44b85da2010-11-21 23:10:35 +0100321AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
Alex Vatchenkob5017952009-05-28 15:58:50 -0400322 [VISIBILITY_CFLAGS="-fvisibility=hidden"
Chris Dickenscb77a252017-02-20 00:18:33 -0800323 AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility])],
324 [VISIBILITY_CFLAGS=""
325 AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility])],
Alex Vatchenkob5017952009-05-28 15:58:50 -0400326 ])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800327CFLAGS="${saved_CFLAGS}"
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -0300328
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800329dnl check for -Wno-pointer-sign compiler support (GCC >= 4)
330saved_CFLAGS="${CFLAGS}"
331CFLAGS="${CFLAGS} -Wno-pointer-sign"
Peter Stuge44b85da2010-11-21 23:10:35 +0100332AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
Alex Vatchenkob5017952009-05-28 15:58:50 -0400333 nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800334CFLAGS="${saved_CFLAGS}"
Alex Vatchenkob5017952009-05-28 15:58:50 -0400335
Chris Dickensa5f6a432020-01-24 11:51:55 -0800336dnl check for -std=gnu11 compiler support
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800337saved_CFLAGS="${CFLAGS}"
Chris Dickensa5f6a432020-01-24 11:51:55 -0800338CFLAGS="-std=gnu11"
339AC_MSG_CHECKING([whether CC supports -std=gnu11])
Akshay Jaggidc974252014-09-24 22:46:17 +0100340AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800341 [AC_MSG_RESULT([yes])
Chris Dickensa5f6a432020-01-24 11:51:55 -0800342 AM_CFLAGS="${AM_CFLAGS} -std=gnu11"],
343 [AC_MSG_RESULT([no])])
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800344CFLAGS="${saved_CFLAGS}"
Akshay Jaggidc974252014-09-24 22:46:17 +0100345
Chris Dickensa5f6a432020-01-24 11:51:55 -0800346dnl check for _Thread_local compiler support
347if test "x$backend" != xwindows; then
348 saved_CFLAGS="${CFLAGS}"
349 saved_LDFLAGS="${LDFLAGS}"
350 CFLAGS="${CFLAGS} -fPIC"
351 LDFLAGS="${LDFLAGS} -shared"
352 AC_MSG_CHECKING([whether CC supports _Thread_local])
353 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [static _Thread_local int v])],
354 [AC_MSG_RESULT([yes])
355 AC_DEFINE([HAVE_CC_THREAD_LOCAL], [1], [Define to 1 if the compiler supports _Thread_local.])],
356 [AC_MSG_RESULT([no])])
357 CFLAGS="${saved_CFLAGS}"
358 LDFLAGS="${saved_LDFLAGS}"
359fi
360
Chris Dickensd5bb64b2020-01-22 17:39:14 -0800361AM_CFLAGS="${AM_CFLAGS} -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration ${nopointersign_cflags} -Wshadow ${THREAD_CFLAGS} ${VISIBILITY_CFLAGS}"
Alex Vatchenkob5017952009-05-28 15:58:50 -0400362
Daniel Drake852bba42007-11-28 13:48:45 +0000363AC_SUBST(AM_CFLAGS)
Peter Stuge717f4762010-11-15 19:58:51 +0100364AC_SUBST(LTLDFLAGS)
Daniel Drake852bba42007-11-28 13:48:45 +0000365
Peter Stugeef39d152011-02-25 02:33:29 +0100366AC_CONFIG_FILES([libusb-1.0.pc])
367AC_CONFIG_FILES([Makefile])
368AC_CONFIG_FILES([libusb/Makefile])
Peter Stugeef39d152011-02-25 02:33:29 +0100369AC_CONFIG_FILES([examples/Makefile])
Toby Gray21cf6e42012-11-21 14:00:31 +0000370AC_CONFIG_FILES([tests/Makefile])
Peter Stugeef39d152011-02-25 02:33:29 +0100371AC_CONFIG_FILES([doc/Makefile])
372AC_CONFIG_FILES([doc/doxygen.cfg])
Daniel Drake852bba42007-11-28 13:48:45 +0000373AC_OUTPUT