blob: 0bd2cd8d2be202d6c3ad9c2bcb15a9114988fa25 [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
Daniel Draked192c5b2010-10-04 18:45:18 +010020# 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
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
Peter Stuge19d58822010-11-21 23:09:02 +010043AC_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])
Pete Batard968df122012-04-19 18:01:04 +010048
Kuangye Guo7e3de5d2013-10-21 18:36:15 -070049dnl on linux-android platform, some functions are in different places
50case $host in
51*-linux-android*)
52 AC_MSG_RESULT([This is a Linux-Android system])
Chris Dickenscb77a252017-02-20 00:18:33 -080053 is_backend_android=yes
Kuangye Guo7e3de5d2013-10-21 18:36:15 -070054 ;;
55*)
Chris Dickenscb77a252017-02-20 00:18:33 -080056 is_backend_android=no
Kuangye Guo7e3de5d2013-10-21 18:36:15 -070057esac
58
Daniel Drakec0c94322008-03-13 12:36:56 +000059case $host in
Gustavo Zacarias5f366712013-09-03 10:24:04 -030060*-linux* | *-uclinux*)
Daniel Drakec0c94322008-03-13 12:36:56 +000061 AC_MSG_RESULT([Linux])
Chris Dickenscb77a252017-02-20 00:18:33 -080062 backend=linux
63 threads=posix
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030064 ;;
65*-darwin*)
Peter Stuge0bd4a4d2011-02-26 04:08:38 +010066 AC_MSG_RESULT([Darwin/Mac OS X])
Chris Dickenscb77a252017-02-20 00:18:33 -080067 backend=darwin
68 threads=posix
Peter Stuge6e52ea02010-11-21 23:37:27 +010069 ;;
Martin Pieuchotc5682882012-01-30 09:59:30 +010070*-openbsd*)
Martin Pieuchotc5682882012-01-30 09:59:30 +010071 AC_MSG_RESULT([OpenBSD])
Chris Dickenscb77a252017-02-20 00:18:33 -080072 backend=openbsd
73 threads=posix
Pete Batard968df122012-04-19 18:01:04 +010074 ;;
75*-netbsd*)
Hans de Goedeeb4e7be2013-08-21 16:18:39 +020076 AC_MSG_RESULT([NetBSD])
Chris Dickenscb77a252017-02-20 00:18:33 -080077 backend=netbsd
78 threads=posix
Martin Pieuchotc5682882012-01-30 09:59:30 +010079 ;;
Evan Hunter8e3d41e2016-01-08 13:53:42 +000080*-mingw* | *msys*)
Pete Batard9a4249f2010-07-10 17:51:13 -060081 AC_MSG_RESULT([Windows])
Chris Dickenscb77a252017-02-20 00:18:33 -080082 backend=windows
83 threads=windows
84 create_import_lib=yes
Pete Batardff3259b2012-06-07 11:55:30 +010085 AM_CFLAGS="${AM_CFLAGS} -fno-omit-frame-pointer"
Pete Batard9a4249f2010-07-10 17:51:13 -060086 ;;
87*-cygwin*)
Peter Stuge0bd4a4d2011-02-26 04:08:38 +010088 AC_MSG_RESULT([Cygwin (using Windows backend)])
Chris Dickenscb77a252017-02-20 00:18:33 -080089 backend=windows
90 threads=posix
Pete Batard9a4249f2010-07-10 17:51:13 -060091 ;;
Akshay Jaggidc974252014-09-24 22:46:17 +010092*-haiku*)
93 AC_MSG_RESULT([Haiku])
Chris Dickenscb77a252017-02-20 00:18:33 -080094 backend=haiku
95 threads=posix
Akshay Jaggidc974252014-09-24 22:46:17 +010096 ;;
Lei Cheneefd3222016-02-19 11:58:39 +080097*-solaris*)
98 AC_MSG_RESULT([SunOS])
Chris Dickenscb77a252017-02-20 00:18:33 -080099 backend=sunos
100 threads=posix
Lei Cheneefd3222016-02-19 11:58:39 +0800101 ;;
Daniel Drakec0c94322008-03-13 12:36:56 +0000102*)
Pino Toscano53572d72019-12-27 18:41:28 +0100103 AC_MSG_RESULT([Null])
104 backend="null"
105 threads="posix"
Daniel Drakec0c94322008-03-13 12:36:56 +0000106esac
Pete Batard968df122012-04-19 18:01:04 +0100107
108case $backend in
109linux)
110 AC_DEFINE(OS_LINUX, 1, [Linux backend])
111 AC_SUBST(OS_LINUX)
Baruch Siach552a4a42018-06-05 14:22:21 +0300112 AC_SEARCH_LIBS([clock_gettime], [rt], [], [], [-pthread])
Nathan Hjelm68532912012-11-29 16:14:03 -0700113 AC_ARG_ENABLE([udev],
Toby Gray9222a542013-07-09 16:05:39 +0100114 [AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended) [default=yes]])],
Chris Dickenscb77a252017-02-20 00:18:33 -0800115 [], [enable_udev=yes])
116 if test "x$enable_udev" = xyes ; then
Nathan Hjelm68532912012-11-29 16:14:03 -0700117 # system has udev. use it or fail!
Chris Dickenscb77a252017-02-20 00:18:33 -0800118 AC_CHECK_HEADERS([libudev.h], [], [AC_MSG_ERROR([udev support requested but libudev header not installed])])
119 AC_CHECK_LIB([udev], [udev_new], [], [AC_MSG_ERROR([udev support requested but libudev not installed])])
Nathan Hjelm68532912012-11-29 16:14:03 -0700120 AC_DEFINE(USE_UDEV, 1, [Use udev for device enumeration/hotplug])
121 else
Chris Dickens3f4df892016-01-28 14:15:29 -0800122 AC_CHECK_HEADERS([asm/types.h], [], [])
Chris Dickenscb77a252017-02-20 00:18:33 -0800123 AC_CHECK_HEADERS([sys/socket.h linux/netlink.h], [], [AC_MSG_ERROR([Linux netlink headers not found])], [
Nathan Hjelm83021ab2013-07-27 12:35:51 -0600124#ifdef HAVE_ASM_TYPES_H
125#include <asm/types.h>
126#endif
Nathan Hjelm83021ab2013-07-27 12:35:51 -0600127#include <sys/socket.h>
Nathan Hjelm83021ab2013-07-27 12:35:51 -0600128])
Nathan Hjelm68532912012-11-29 16:14:03 -0700129 fi
130 AC_SUBST(USE_UDEV)
Kuangye Guo7e3de5d2013-10-21 18:36:15 -0700131
Chris Dickens068b5942017-01-12 11:01:59 -0800132 if test "x$is_backend_android" != xyes; then
133 THREAD_CFLAGS="-pthread"
134 LIBS="${LIBS} -pthread"
135 fi
Kuangye Guo7e3de5d2013-10-21 18:36:15 -0700136
Pete Batard968df122012-04-19 18:01:04 +0100137 AC_CHECK_HEADERS([poll.h])
138 AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
139 ;;
140darwin)
141 AC_DEFINE(OS_DARWIN, 1, [Darwin backend])
142 AC_SUBST(OS_DARWIN)
Peter Stuge94b0ccc2012-10-23 00:15:23 +0000143 LIBS="-lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation"
Pete Batard968df122012-04-19 18:01:04 +0100144 LTLDFLAGS="${LTLDFLAGS} -Wl,-prebind"
145 AC_CHECK_HEADERS([poll.h])
146 AC_CHECK_TYPE([nfds_t],
147 [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])],
148 [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])],
149 [#include <poll.h>])
150 ;;
Hans de Goedeeb4e7be2013-08-21 16:18:39 +0200151openbsd)
152 AC_DEFINE(OS_OPENBSD, 1, [OpenBSD backend])
Pete Batard968df122012-04-19 18:01:04 +0100153 AC_SUBST(OS_OPENBSD)
154 THREAD_CFLAGS="-pthread"
Peter Stuge94b0ccc2012-10-23 00:15:23 +0000155 LIBS="-pthread"
Pete Batard968df122012-04-19 18:01:04 +0100156 AC_CHECK_HEADERS([poll.h])
157 AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
158 ;;
Lei Cheneefd3222016-02-19 11:58:39 +0800159sunos)
160 AC_DEFINE(OS_SUNOS, 1, [SunOS backend])
161 AC_SUBST(OS_SUNOS)
162 THREAD_CFLAGS="-pthread"
163 LIBS="-pthread -ldevinfo"
164 AC_CHECK_HEADERS([poll.h])
165 AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
166 ;;
Hans de Goedeeb4e7be2013-08-21 16:18:39 +0200167netbsd)
168 AC_DEFINE(OS_NETBSD, 1, [NetBSD backend])
169 AC_SUBST(OS_NETBSD)
170 THREAD_CFLAGS="-pthread"
171 LIBS="-pthread"
172 AC_CHECK_HEADERS([poll.h])
173 AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
174 ;;
Pete Batard968df122012-04-19 18:01:04 +0100175windows)
Peter Stuge1a2d21f2011-02-26 04:21:05 +0100176 AC_DEFINE(OS_WINDOWS, 1, [Windows backend])
177 AC_SUBST(OS_WINDOWS)
Peter Stuge94b0ccc2012-10-23 00:15:23 +0000178 LIBS=""
Peter Stuge1a2d21f2011-02-26 04:21:05 +0100179 LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
Peter Stuge1a2d21f2011-02-26 04:21:05 +0100180 AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])
Chris Dickens96e0af72020-01-21 16:13:07 -0800181 AC_DEFINE([_WIN32_WINNT], [_WIN32_WINNT_VISTA], [Oldest Windows version supported (Vista)])
Pete Batard968df122012-04-19 18:01:04 +0100182 ;;
Akshay Jaggidc974252014-09-24 22:46:17 +0100183haiku)
184 AC_DEFINE(OS_HAIKU, 1, [Haiku backend])
185 AC_SUBST(OS_HAIKU)
186 LIBS="${LIBS} -lbe"
187 AC_CHECK_HEADERS([poll.h])
188 AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
189 ;;
Pino Toscano53572d72019-12-27 18:41:28 +0100190null)
191 AC_DEFINE(OS_NULL, 1, [Null backend])
192 AC_SUBST(OS_NULL)
193 THREAD_CFLAGS="-pthread"
194 LIBS="-pthread"
195 AC_CHECK_HEADERS([poll.h])
196 AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
197 ;;
Pete Batard968df122012-04-19 18:01:04 +0100198esac
199
Peter Stuge94b0ccc2012-10-23 00:15:23 +0000200AC_SUBST(LIBS)
Daniel Drakec0c94322008-03-13 12:36:56 +0000201
Peter Stugec24649d2010-10-30 22:28:59 +0200202AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux)
203AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin)
Hans de Goedeeb4e7be2013-08-21 16:18:39 +0200204AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xopenbsd)
Lei Cheneefd3222016-02-19 11:58:39 +0800205AM_CONDITIONAL(OS_SUNOS, test "x$backend" = xsunos)
Hans de Goedeeb4e7be2013-08-21 16:18:39 +0200206AM_CONDITIONAL(OS_NETBSD, test "x$backend" = xnetbsd)
Peter Stugec24649d2010-10-30 22:28:59 +0200207AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows)
Akshay Jaggidc974252014-09-24 22:46:17 +0100208AM_CONDITIONAL(OS_HAIKU, test "x$backend" = xhaiku)
Pino Toscano53572d72019-12-27 18:41:28 +0100209AM_CONDITIONAL(OS_NULL, test "x$backend" = xnull)
Peter Stugec24649d2010-10-30 22:28:59 +0200210AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix)
Chris Dickens94178682017-01-12 13:50:35 -0800211AM_CONDITIONAL(CREATE_IMPORT_LIB, test "x$create_import_lib" = xyes)
Nathan Hjelm68532912012-11-29 16:14:03 -0700212AM_CONDITIONAL(USE_UDEV, test "x$enable_udev" = xyes)
Chris Dickenscb77a252017-02-20 00:18:33 -0800213if test "x$threads" = xposix; then
Peter Stugec24649d2010-10-30 22:28:59 +0200214 AC_DEFINE(THREADS_POSIX, 1, [Use POSIX Threads])
215fi
Daniel Drakec0c94322008-03-13 12:36:56 +0000216
Daniel Drake47830082009-10-28 20:33:49 +0545217# timerfd
218AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
219AC_ARG_ENABLE([timerfd],
220 [AS_HELP_STRING([--enable-timerfd],
Toby Gray9222a542013-07-09 16:05:39 +0100221 [use timerfd for timing [default=auto]])],
Chris Dickenscb77a252017-02-20 00:18:33 -0800222 [use_timerfd=$enableval], [use_timerfd=auto])
Daniel Drake47830082009-10-28 20:33:49 +0545223
Chris Dickens94178682017-01-12 13:50:35 -0800224if test "x$use_timerfd" = xyes -a "x$timerfd_h" = x0; then
Daniel Drake0bd7ef52009-11-21 16:57:25 +0000225 AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
226fi
227
Chris Dickensaa73b2e2017-02-20 00:55:15 -0800228AC_CHECK_DECLS([TFD_NONBLOCK, TFD_CLOEXEC], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>])
Chris Dickens94178682017-01-12 13:50:35 -0800229if test "x$use_timerfd" = xyes -a "x$tfd_hdr_ok" = xno; then
Daniel Drake0bd7ef52009-11-21 16:57:25 +0000230 AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
Daniel Drake47830082009-10-28 20:33:49 +0545231fi
232
233AC_MSG_CHECKING([whether to use timerfd for timing])
Chris Dickens94178682017-01-12 13:50:35 -0800234if test "x$use_timerfd" = xno; then
Daniel Drake47830082009-10-28 20:33:49 +0545235 AC_MSG_RESULT([no (disabled by user)])
236else
Chris Dickens94178682017-01-12 13:50:35 -0800237 if test "x$timerfd_h" = x1 -a "x$tfd_hdr_ok" = xyes; then
Daniel Drake47830082009-10-28 20:33:49 +0545238 AC_MSG_RESULT([yes])
Peter Stuge19d58822010-11-21 23:09:02 +0100239 AC_DEFINE(USBI_TIMERFD_AVAILABLE, 1, [timerfd headers available])
Daniel Drake47830082009-10-28 20:33:49 +0545240 else
241 AC_MSG_RESULT([no (header not available)])
242 fi
243fi
244
Chris Dickensaa73b2e2017-02-20 00:55:15 -0800245AC_CHECK_FUNCS([pipe2])
Chris Dickenscb77a252017-02-20 00:18:33 -0800246AC_CHECK_TYPES([struct timespec])
Pete Batard9a4249f2010-07-10 17:51:13 -0600247
Daniel Drake852bba42007-11-28 13:48:45 +0000248# Message logging
249AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
250 [log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800251 [log_enabled=yes])
Chris Dickens94178682017-01-12 13:50:35 -0800252if test "x$log_enabled" != xno; then
Daniel Drake852bba42007-11-28 13:48:45 +0000253 AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
254fi
255
256AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
Toby Gray9222a542013-07-09 16:05:39 +0100257 [start with debug message logging enabled [default=no]])],
Daniel Drake852bba42007-11-28 13:48:45 +0000258 [debug_log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800259 [debug_log_enabled=no])
Chris Dickens94178682017-01-12 13:50:35 -0800260if test "x$debug_log_enabled" != xno; then
Pete Batardcf6e68a2012-05-31 18:31:34 +0100261 AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Start with debug message logging enabled])
Daniel Drake852bba42007-11-28 13:48:45 +0000262fi
263
Toby Gray9222a542013-07-09 16:05:39 +0100264AC_ARG_ENABLE([system-log], [AS_HELP_STRING([--enable-system-log],
265 [output logging messages to system wide log, if supported by the OS [default=no]])],
266 [system_log_enabled=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800267 [system_log_enabled=no])
Chris Dickens94178682017-01-12 13:50:35 -0800268if test "x$system_log_enabled" != xno; then
Toby Gray9222a542013-07-09 16:05:39 +0100269 AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], 1, [Enable output to system log])
Toby Gray9222a542013-07-09 16:05:39 +0100270
Chris Dickens94178682017-01-12 13:50:35 -0800271 # Check if syslog is available in standard C library
272 AC_CHECK_HEADERS(syslog.h)
273 AC_CHECK_FUNC([syslog], [have_syslog=yes], [have_syslog=no])
274 if test "x$have_syslog" != xno; then
275 AC_DEFINE([HAVE_SYSLOG_FUNC], 1, [syslog() function available])
276 fi
Toby Gray9222a542013-07-09 16:05:39 +0100277fi
278
Daniel Drake852bba42007-11-28 13:48:45 +0000279# Examples build
280AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
Toby Gray9222a542013-07-09 16:05:39 +0100281 [build example applications [default=no]])],
Daniel Drake852bba42007-11-28 13:48:45 +0000282 [build_examples=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800283 [build_examples=no])
Chris Dickens94178682017-01-12 13:50:35 -0800284AM_CONDITIONAL(BUILD_EXAMPLES, test "x$build_examples" != xno)
Daniel Drake852bba42007-11-28 13:48:45 +0000285
Toby Gray21cf6e42012-11-21 14:00:31 +0000286# Tests build
287AC_ARG_ENABLE([tests-build], [AS_HELP_STRING([--enable-tests-build],
Toby Gray9222a542013-07-09 16:05:39 +0100288 [build test applications [default=no]])],
Toby Gray21cf6e42012-11-21 14:00:31 +0000289 [build_tests=$enableval],
Chris Dickenscb77a252017-02-20 00:18:33 -0800290 [build_tests=no])
Chris Dickens94178682017-01-12 13:50:35 -0800291AM_CONDITIONAL(BUILD_TESTS, test "x$build_tests" != xno)
292
293# headers not available on all platforms but required on others
294AC_CHECK_HEADERS([sys/time.h])
295
296# sigaction not available on MinGW
297AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no])
298AM_CONDITIONAL(HAVE_SIGACTION, test "x$have_sigaction" = xyes)
Toby Gray21cf6e42012-11-21 14:00:31 +0000299
Alex Vatchenkob5017952009-05-28 15:58:50 -0400300# check for -fvisibility=hidden compiler support (GCC >= 3.4)
301saved_cflags="$CFLAGS"
Pete Batard9a4249f2010-07-10 17:51:13 -0600302# -Werror required for cygwin
303CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
Peter Stuge44b85da2010-11-21 23:10:35 +0100304AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
Alex Vatchenkob5017952009-05-28 15:58:50 -0400305 [VISIBILITY_CFLAGS="-fvisibility=hidden"
Chris Dickenscb77a252017-02-20 00:18:33 -0800306 AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility])],
307 [VISIBILITY_CFLAGS=""
308 AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility])],
Alex Vatchenkob5017952009-05-28 15:58:50 -0400309 ])
310CFLAGS="$saved_cflags"
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -0300311
Alex Vatchenkob5017952009-05-28 15:58:50 -0400312# check for -Wno-pointer-sign compiler support (GCC >= 4)
313saved_cflags="$CFLAGS"
314CFLAGS="$CFLAGS -Wno-pointer-sign"
Peter Stuge44b85da2010-11-21 23:10:35 +0100315AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
Alex Vatchenkob5017952009-05-28 15:58:50 -0400316 nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
317CFLAGS="$saved_cflags"
318
Akshay Jaggidc974252014-09-24 22:46:17 +0100319# check for -std=gnu99 compiler support
320saved_cflags="$CFLAGS"
321CFLAGS="-std=gnu99"
322AC_MSG_CHECKING([whether CC supports -std=gnu99])
323AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
324 [AC_MSG_RESULT([yes])]
325 [AM_CFLAGS="${AM_CFLAGS} -std=gnu99"],
326 [AC_MSG_RESULT([no])]
327)
328CFLAGS="$saved_cflags"
329
330AM_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 -0400331
Daniel Drake852bba42007-11-28 13:48:45 +0000332AC_SUBST(AM_CFLAGS)
Peter Stuge717f4762010-11-15 19:58:51 +0100333AC_SUBST(LTLDFLAGS)
Daniel Drake852bba42007-11-28 13:48:45 +0000334
Peter Stugeef39d152011-02-25 02:33:29 +0100335AC_CONFIG_FILES([libusb-1.0.pc])
336AC_CONFIG_FILES([Makefile])
337AC_CONFIG_FILES([libusb/Makefile])
Peter Stugeef39d152011-02-25 02:33:29 +0100338AC_CONFIG_FILES([examples/Makefile])
Toby Gray21cf6e42012-11-21 14:00:31 +0000339AC_CONFIG_FILES([tests/Makefile])
Peter Stugeef39d152011-02-25 02:33:29 +0100340AC_CONFIG_FILES([doc/Makefile])
341AC_CONFIG_FILES([doc/doxygen.cfg])
Daniel Drake852bba42007-11-28 13:48:45 +0000342AC_OUTPUT