OLD | NEW |
(Empty) | |
| 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]))]) |
| 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]))]) |
| 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 |
| 11 dnl in AC_INIT(). |
| 12 |
| 13 LU_DEFINE_VERSION_ATOM([LIBUSB_MAJOR]) |
| 14 LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR]) |
| 15 LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO]) |
| 16 LU_DEFINE_VERSION_RC_ATOM([LIBUSB_RC]) |
| 17 |
| 18 AC_INIT([libusb], LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC, [libusb
-devel@lists.sourceforge.net], [libusb], [http://www.libusb.org/]) |
| 19 |
| 20 # 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.htm
l |
| 23 # http://sourceware.org/autobook/autobook/autobook_91.html |
| 24 lt_current="1" |
| 25 lt_revision="0" |
| 26 lt_age="1" |
| 27 LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}" |
| 28 |
| 29 AM_INIT_AUTOMAKE |
| 30 AM_MAINTAINER_MODE |
| 31 |
| 32 AC_CONFIG_SRCDIR([libusb/core.c]) |
| 33 AC_CONFIG_MACRO_DIR([m4]) |
| 34 AM_CONFIG_HEADER([config.h]) |
| 35 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) |
| 36 |
| 37 AC_PREREQ([2.50]) |
| 38 AC_PROG_CC |
| 39 AC_PROG_LIBTOOL |
| 40 AC_C_INLINE |
| 41 AM_PROG_CC_C_O |
| 42 AC_DEFINE([_GNU_SOURCE], 1, [Use GNU extensions]) |
| 43 |
| 44 LTLDFLAGS="${LTLDFLAGS} -no-undefined" |
| 45 |
| 46 AC_MSG_CHECKING([operating system]) |
| 47 case $host in |
| 48 *-linux*) |
| 49 AC_DEFINE(OS_LINUX, 1, [Linux backend]) |
| 50 AC_SUBST(OS_LINUX) |
| 51 AC_MSG_RESULT([Linux]) |
| 52 backend="linux" |
| 53 AC_CHECK_LIB(rt, clock_gettime, PC_LIBS_PRIVATE="-lrt") |
| 54 threads="posix" |
| 55 THREAD_CFLAGS="-pthread" |
| 56 PC_LIBS_PRIVATE="${PC_LIBS_PRIVATE} -pthread" |
| 57 AC_CHECK_HEADERS([poll.h]) |
| 58 AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument]) |
| 59 ;; |
| 60 *-darwin*) |
| 61 AC_DEFINE(OS_DARWIN, 1, [Darwin backend]) |
| 62 AC_SUBST(OS_DARWIN) |
| 63 AC_MSG_RESULT([Darwin/Mac OS X]) |
| 64 backend="darwin" |
| 65 threads="posix" |
| 66 LIBS="${LIBS} -lobjc" |
| 67 PC_LIBS_PRIVATE="-Wl,-framework,IOKit -Wl,-framework,CoreFoundation" |
| 68 LTLDFLAGS="${LTLDFLAGS} -Wl,-prebind" |
| 69 AC_CHECK_HEADERS([poll.h]) |
| 70 AC_CHECK_TYPE([nfds_t], |
| 71 [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argu
ment])], |
| 72 [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll(
) argument])], |
| 73 [#include <poll.h>]) |
| 74 ;; |
| 75 *-mingw*) |
| 76 AC_MSG_RESULT([Windows]) |
| 77 backend="windows" |
| 78 ;; |
| 79 *-cygwin*) |
| 80 AC_MSG_RESULT([Cygwin (using Windows backend)]) |
| 81 backend="windows" |
| 82 threads="posix" |
| 83 ;; |
| 84 *) |
| 85 AC_MSG_ERROR([unsupported operating system]) |
| 86 esac |
| 87 if test "$backend" = windows; then |
| 88 AC_DEFINE(OS_WINDOWS, 1, [Windows backend]) |
| 89 AC_SUBST(OS_WINDOWS) |
| 90 PC_LIBS_PRIVATE="" |
| 91 LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias" |
| 92 AC_CHECK_TOOL(RC, windres, no) |
| 93 AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argumen
t]) |
| 94 fi |
| 95 AC_SUBST(THREAD_CFLAGS) |
| 96 AC_SUBST(PC_LIBS_PRIVATE) |
| 97 LIBS="${LIBS} ${PC_LIBS_PRIVATE}" |
| 98 |
| 99 AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux) |
| 100 AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin) |
| 101 AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows) |
| 102 AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix) |
| 103 if test "$threads" = posix; then |
| 104 AC_DEFINE(THREADS_POSIX, 1, [Use POSIX Threads]) |
| 105 fi |
| 106 |
| 107 # timerfd |
| 108 AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0]) |
| 109 AC_ARG_ENABLE([timerfd], |
| 110 [AS_HELP_STRING([--enable-timerfd], |
| 111 [use timerfd for timing (default auto)])], |
| 112 [use_timerfd=$enableval], [use_timerfd='auto']) |
| 113 |
| 114 if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then |
| 115 AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required]) |
| 116 fi |
| 117 |
| 118 AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/
timerfd.h>]) |
| 119 if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then |
| 120 AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required]) |
| 121 fi |
| 122 |
| 123 AC_MSG_CHECKING([whether to use timerfd for timing]) |
| 124 if test "x$use_timerfd" = "xno"; then |
| 125 AC_MSG_RESULT([no (disabled by user)]) |
| 126 else |
| 127 if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then |
| 128 AC_MSG_RESULT([yes]) |
| 129 AC_DEFINE(USBI_TIMERFD_AVAILABLE, 1, [timerfd headers available]
) |
| 130 else |
| 131 AC_MSG_RESULT([no (header not available)]) |
| 132 fi |
| 133 fi |
| 134 |
| 135 AC_CHECK_TYPES(struct timespec) |
| 136 |
| 137 # Message logging |
| 138 AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])], |
| 139 [log_enabled=$enableval], |
| 140 [log_enabled='yes']) |
| 141 if test "x$log_enabled" != "xno"; then |
| 142 AC_DEFINE([ENABLE_LOGGING], 1, [Message logging]) |
| 143 fi |
| 144 |
| 145 AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log], |
| 146 [enable debug logging (default n)])], |
| 147 [debug_log_enabled=$enableval], |
| 148 [debug_log_enabled='no']) |
| 149 if test "x$debug_log_enabled" != "xno"; then |
| 150 AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging]) |
| 151 fi |
| 152 |
| 153 # Examples build |
| 154 AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build], |
| 155 [build example applications (default n)])], |
| 156 [build_examples=$enableval], |
| 157 [build_examples='no']) |
| 158 AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"]) |
| 159 |
| 160 # check for -fvisibility=hidden compiler support (GCC >= 3.4) |
| 161 saved_cflags="$CFLAGS" |
| 162 # -Werror required for cygwin |
| 163 CFLAGS="$CFLAGS -Werror -fvisibility=hidden" |
| 164 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
| 165 [VISIBILITY_CFLAGS="-fvisibility=hidden" |
| 166 AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))
], [Default visibility]) ], |
| 167 [ VISIBILITY_CFLAGS="" |
| 168 AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility]) ], |
| 169 ]) |
| 170 CFLAGS="$saved_cflags" |
| 171 |
| 172 # check for -Wno-pointer-sign compiler support (GCC >= 4) |
| 173 saved_cflags="$CFLAGS" |
| 174 CFLAGS="$CFLAGS -Wno-pointer-sign" |
| 175 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
| 176 nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="") |
| 177 CFLAGS="$saved_cflags" |
| 178 |
| 179 # sigaction not available on MinGW |
| 180 AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no]) |
| 181 AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = "xyes"]) |
| 182 |
| 183 # headers not available on all platforms but required on others |
| 184 AC_CHECK_HEADERS([sys/time.h]) |
| 185 |
| 186 AM_CFLAGS="-std=gnu99 -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implici
t-function-declaration $nopointersign_cflags -Wshadow" |
| 187 |
| 188 AC_SUBST(VISIBILITY_CFLAGS) |
| 189 AC_SUBST(AM_CFLAGS) |
| 190 AC_SUBST(LTLDFLAGS) |
| 191 |
| 192 AC_CONFIG_FILES([libusb-1.0.pc]) |
| 193 AC_CONFIG_FILES([Makefile]) |
| 194 AC_CONFIG_FILES([libusb/Makefile]) |
| 195 AC_CONFIG_FILES([examples/Makefile]) |
| 196 AC_CONFIG_FILES([doc/Makefile]) |
| 197 AC_CONFIG_FILES([doc/doxygen.cfg]) |
| 198 AC_OUTPUT |
OLD | NEW |