Daniel Drake | 8be2560 | 2009-06-13 17:19:07 +0100 | [diff] [blame^] | 1 | AC_INIT([libusb], [1.0.2]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 2 | AM_INIT_AUTOMAKE |
Daniel Drake | e9364d7 | 2008-01-04 00:40:49 +0000 | [diff] [blame] | 3 | AC_CONFIG_SRCDIR([libusb/core.c]) |
Daniel Drake | 8be2560 | 2009-06-13 17:19:07 +0100 | [diff] [blame^] | 4 | AC_CONFIG_MACRO_DIR([m4]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 5 | AM_CONFIG_HEADER([config.h]) |
| 6 | |
| 7 | AC_PREREQ([2.50]) |
| 8 | AC_PROG_CC |
| 9 | AC_PROG_LIBTOOL |
| 10 | AC_C_INLINE |
| 11 | AM_PROG_CC_C_O |
Daniel Drake | 637a8d7 | 2008-01-30 13:19:10 +0000 | [diff] [blame] | 12 | AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 13 | |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 14 | AC_MSG_CHECKING([operating system]) |
| 15 | case $host in |
| 16 | *-linux*) |
| 17 | AC_DEFINE(OS_LINUX, [], [Linux backend]) |
| 18 | AC_SUBST(OS_LINUX) |
| 19 | AC_MSG_RESULT([Linux]) |
| 20 | backend="linux" |
Nathan Hjelm | ccf6d3d | 2009-02-16 21:13:52 -0300 | [diff] [blame] | 21 | AC_CHECK_LIB(rt, clock_gettime) |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 22 | AM_LDFLAGS="" |
| 23 | ;; |
| 24 | *-darwin*) |
| 25 | AC_DEFINE(OS_DARWIN, [], [Darwin backend]) |
| 26 | AC_SUBST(OS_DARWIN) |
| 27 | AC_MSG_RESULT([Darwin/MacOS X]) |
| 28 | backend="darwin" |
| 29 | AM_LDFLAGS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -no-undefined" |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 30 | ;; |
| 31 | *) |
| 32 | AC_MSG_ERROR([unsupported operating system]) |
| 33 | esac |
| 34 | |
| 35 | AM_CONDITIONAL([OS_LINUX], [test "x$backend" == "xlinux"]) |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 36 | AM_CONDITIONAL([OS_DARWIN], [test "x$backend" == "xdarwin"]) |
Daniel Drake | c0c9432 | 2008-03-13 12:36:56 +0000 | [diff] [blame] | 37 | |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 38 | # Library versioning |
| 39 | lt_major="0" |
| 40 | lt_revision="0" |
| 41 | lt_age="0" |
| 42 | AC_SUBST(lt_major) |
| 43 | AC_SUBST(lt_revision) |
| 44 | AC_SUBST(lt_age) |
| 45 | |
| 46 | # Message logging |
| 47 | AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])], |
| 48 | [log_enabled=$enableval], |
| 49 | [log_enabled='yes']) |
| 50 | if test "x$log_enabled" != "xno"; then |
| 51 | AC_DEFINE([ENABLE_LOGGING], 1, [Message logging]) |
| 52 | fi |
| 53 | |
| 54 | AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log], |
| 55 | [enable debug logging (default n)])], |
| 56 | [debug_log_enabled=$enableval], |
| 57 | [debug_log_enabled='no']) |
| 58 | if test "x$debug_log_enabled" != "xno"; then |
| 59 | AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging]) |
| 60 | fi |
| 61 | |
| 62 | # Examples build |
| 63 | AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build], |
| 64 | [build example applications (default n)])], |
| 65 | [build_examples=$enableval], |
| 66 | [build_examples='no']) |
| 67 | AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"]) |
| 68 | |
Daniel Drake | 37b7f9a | 2008-01-26 14:03:43 +0000 | [diff] [blame] | 69 | # Restore gnu89 inline semantics on gcc 4.3 and newer |
| 70 | saved_cflags="$CFLAGS" |
| 71 | CFLAGS="$CFLAGS -fgnu89-inline" |
| 72 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="") |
| 73 | CFLAGS="$saved_cflags" |
| 74 | |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 75 | # check for -fvisibility=hidden compiler support (GCC >= 3.4) |
| 76 | saved_cflags="$CFLAGS" |
| 77 | CFLAGS="$CFLAGS -fvisibility=hidden" |
| 78 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), |
| 79 | [VISIBILITY_CFLAGS="-fvisibility=hidden" |
| 80 | AC_DEFINE([API_EXPORTED], [__attribute__((visibility("default")))], [Default visibility]) ], |
| 81 | [ VISIBILITY_CFLAGS="" |
| 82 | AC_DEFINE([API_EXPORTED], [], [Default visibility]) ], |
| 83 | ]) |
| 84 | CFLAGS="$saved_cflags" |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 85 | |
Alex Vatchenko | b501795 | 2009-05-28 15:58:50 -0400 | [diff] [blame] | 86 | # check for -Wno-pointer-sign compiler support (GCC >= 4) |
| 87 | saved_cflags="$CFLAGS" |
| 88 | CFLAGS="$CFLAGS -Wno-pointer-sign" |
| 89 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), |
| 90 | nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="") |
| 91 | CFLAGS="$saved_cflags" |
| 92 | |
| 93 | AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow" |
| 94 | |
| 95 | AC_SUBST(VISIBILITY_CFLAGS) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 96 | AC_SUBST(AM_CFLAGS) |
Nathan Hjelm | b49f6bf | 2009-02-16 21:39:29 -0300 | [diff] [blame] | 97 | AC_SUBST(AM_LDFLAGS) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 98 | |
Aurelien Jarno | d25b566 | 2008-09-04 13:50:49 +0200 | [diff] [blame] | 99 | AC_CONFIG_FILES([libusb-1.0.pc] [Makefile] [libusb/Makefile] [examples/Makefile] [doc/Makefile] [doc/doxygen.cfg]) |
Daniel Drake | 852bba4 | 2007-11-28 13:48:45 +0000 | [diff] [blame] | 100 | AC_OUTPUT |
| 101 | |