Yavor Goulishev | bda86ae | 2011-05-23 11:56:53 -0700 | [diff] [blame] | 1 | AC_INIT([libusb], [1.0.8]) |
| 2 | AM_INIT_AUTOMAKE |
| 3 | AC_CONFIG_SRCDIR([libusb/core.c]) |
| 4 | AC_CONFIG_MACRO_DIR([m4]) |
| 5 | AM_CONFIG_HEADER([config.h]) |
| 6 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) |
| 7 | |
| 8 | AC_PREREQ([2.50]) |
| 9 | AC_PROG_CC |
| 10 | AC_PROG_LIBTOOL |
| 11 | AC_C_INLINE |
| 12 | AM_PROG_CC_C_O |
| 13 | AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions]) |
| 14 | |
| 15 | AC_MSG_CHECKING([operating system]) |
| 16 | case $host in |
| 17 | *-linux*) |
| 18 | AC_DEFINE(OS_LINUX, [], [Linux backend]) |
| 19 | AC_SUBST(OS_LINUX) |
| 20 | AC_MSG_RESULT([Linux]) |
| 21 | backend="linux" |
| 22 | AC_CHECK_LIB(rt, clock_gettime) |
| 23 | AM_LDFLAGS="" |
| 24 | ;; |
| 25 | *-darwin*) |
| 26 | AC_DEFINE(OS_DARWIN, [], [Darwin backend]) |
| 27 | AC_SUBST(OS_DARWIN) |
| 28 | AC_DEFINE(USBI_OS_HANDLES_TIMEOUT, [], [Backend handles timeout]) |
| 29 | AC_MSG_RESULT([Darwin/MacOS X]) |
| 30 | backend="darwin" |
| 31 | AM_LDFLAGS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -no-undefined" |
| 32 | ;; |
| 33 | *) |
| 34 | AC_MSG_ERROR([unsupported operating system]) |
| 35 | esac |
| 36 | |
| 37 | AM_CONDITIONAL([OS_LINUX], [test "x$backend" == "xlinux"]) |
| 38 | AM_CONDITIONAL([OS_DARWIN], [test "x$backend" == "xdarwin"]) |
| 39 | |
| 40 | # Library versioning |
| 41 | lt_major="0" |
| 42 | lt_revision="0" |
| 43 | lt_age="0" |
| 44 | AC_SUBST(lt_major) |
| 45 | AC_SUBST(lt_revision) |
| 46 | AC_SUBST(lt_age) |
| 47 | |
| 48 | # timerfd |
| 49 | AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0]) |
| 50 | AC_ARG_ENABLE([timerfd], |
| 51 | [AS_HELP_STRING([--enable-timerfd], |
| 52 | [use timerfd for timing (default auto)])], |
| 53 | [use_timerfd=$enableval], [use_timerfd='auto']) |
| 54 | |
| 55 | if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then |
| 56 | AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required]) |
| 57 | fi |
| 58 | |
| 59 | AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>]) |
| 60 | if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then |
| 61 | AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required]) |
| 62 | fi |
| 63 | |
| 64 | AC_MSG_CHECKING([whether to use timerfd for timing]) |
| 65 | if test "x$use_timerfd" = "xno"; then |
| 66 | AC_MSG_RESULT([no (disabled by user)]) |
| 67 | else |
| 68 | if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then |
| 69 | AC_MSG_RESULT([yes]) |
| 70 | AC_DEFINE(USBI_TIMERFD_AVAILABLE, [], [timerfd headers available]) |
| 71 | else |
| 72 | AC_MSG_RESULT([no (header not available)]) |
| 73 | fi |
| 74 | fi |
| 75 | |
| 76 | # Message logging |
| 77 | AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])], |
| 78 | [log_enabled=$enableval], |
| 79 | [log_enabled='yes']) |
| 80 | if test "x$log_enabled" != "xno"; then |
| 81 | AC_DEFINE([ENABLE_LOGGING], 1, [Message logging]) |
| 82 | fi |
| 83 | |
| 84 | AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log], |
| 85 | [enable debug logging (default n)])], |
| 86 | [debug_log_enabled=$enableval], |
| 87 | [debug_log_enabled='no']) |
| 88 | if test "x$debug_log_enabled" != "xno"; then |
| 89 | AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging]) |
| 90 | fi |
| 91 | |
| 92 | # Examples build |
| 93 | AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build], |
| 94 | [build example applications (default n)])], |
| 95 | [build_examples=$enableval], |
| 96 | [build_examples='no']) |
| 97 | AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"]) |
| 98 | |
| 99 | # Restore gnu89 inline semantics on gcc 4.3 and newer |
| 100 | saved_cflags="$CFLAGS" |
| 101 | CFLAGS="$CFLAGS -fgnu89-inline" |
| 102 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="") |
| 103 | CFLAGS="$saved_cflags" |
| 104 | |
| 105 | # check for -fvisibility=hidden compiler support (GCC >= 3.4) |
| 106 | saved_cflags="$CFLAGS" |
| 107 | CFLAGS="$CFLAGS -fvisibility=hidden" |
| 108 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), |
| 109 | [VISIBILITY_CFLAGS="-fvisibility=hidden" |
| 110 | AC_DEFINE([API_EXPORTED], [__attribute__((visibility("default")))], [Default visibility]) ], |
| 111 | [ VISIBILITY_CFLAGS="" |
| 112 | AC_DEFINE([API_EXPORTED], [], [Default visibility]) ], |
| 113 | ]) |
| 114 | CFLAGS="$saved_cflags" |
| 115 | |
| 116 | # check for -Wno-pointer-sign compiler support (GCC >= 4) |
| 117 | saved_cflags="$CFLAGS" |
| 118 | CFLAGS="$CFLAGS -Wno-pointer-sign" |
| 119 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), |
| 120 | nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="") |
| 121 | CFLAGS="$saved_cflags" |
| 122 | |
| 123 | AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow" |
| 124 | |
| 125 | AC_SUBST(VISIBILITY_CFLAGS) |
| 126 | AC_SUBST(AM_CFLAGS) |
| 127 | AC_SUBST(AM_LDFLAGS) |
| 128 | |
| 129 | AC_CONFIG_FILES([libusb-1.0.pc] [Makefile] [libusb/Makefile] [examples/Makefile] [doc/Makefile] [doc/doxygen.cfg]) |
| 130 | AC_OUTPUT |
| 131 | |