blob: 57327c05e6e73642fb2a4a0c3223257dd692e690 [file] [log] [blame]
Daniel Drake8be25602009-06-13 17:19:07 +01001AC_INIT([libusb], [1.0.2])
Daniel Drake852bba42007-11-28 13:48:45 +00002AM_INIT_AUTOMAKE
Daniel Drakee9364d72008-01-04 00:40:49 +00003AC_CONFIG_SRCDIR([libusb/core.c])
Daniel Drake8be25602009-06-13 17:19:07 +01004AC_CONFIG_MACRO_DIR([m4])
Daniel Drake852bba42007-11-28 13:48:45 +00005AM_CONFIG_HEADER([config.h])
6
7AC_PREREQ([2.50])
8AC_PROG_CC
9AC_PROG_LIBTOOL
10AC_C_INLINE
11AM_PROG_CC_C_O
Daniel Drake637a8d72008-01-30 13:19:10 +000012AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions])
Daniel Drake852bba42007-11-28 13:48:45 +000013
Daniel Drakec0c94322008-03-13 12:36:56 +000014AC_MSG_CHECKING([operating system])
15case $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 Hjelmccf6d3d2009-02-16 21:13:52 -030021 AC_CHECK_LIB(rt, clock_gettime)
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030022 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 Drakec0c94322008-03-13 12:36:56 +000030 ;;
31*)
32 AC_MSG_ERROR([unsupported operating system])
33esac
34
35AM_CONDITIONAL([OS_LINUX], [test "x$backend" == "xlinux"])
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030036AM_CONDITIONAL([OS_DARWIN], [test "x$backend" == "xdarwin"])
Daniel Drakec0c94322008-03-13 12:36:56 +000037
Daniel Drake852bba42007-11-28 13:48:45 +000038# Library versioning
39lt_major="0"
40lt_revision="0"
41lt_age="0"
42AC_SUBST(lt_major)
43AC_SUBST(lt_revision)
44AC_SUBST(lt_age)
45
46# Message logging
47AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
48 [log_enabled=$enableval],
49 [log_enabled='yes'])
50if test "x$log_enabled" != "xno"; then
51 AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
52fi
53
54AC_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'])
58if test "x$debug_log_enabled" != "xno"; then
59 AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging])
60fi
61
62# Examples build
63AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
64 [build example applications (default n)])],
65 [build_examples=$enableval],
66 [build_examples='no'])
67AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
68
Daniel Drake37b7f9a2008-01-26 14:03:43 +000069# Restore gnu89 inline semantics on gcc 4.3 and newer
70saved_cflags="$CFLAGS"
71CFLAGS="$CFLAGS -fgnu89-inline"
72AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="")
73CFLAGS="$saved_cflags"
74
Alex Vatchenkob5017952009-05-28 15:58:50 -040075# check for -fvisibility=hidden compiler support (GCC >= 3.4)
76saved_cflags="$CFLAGS"
77CFLAGS="$CFLAGS -fvisibility=hidden"
78AC_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 ])
84CFLAGS="$saved_cflags"
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030085
Alex Vatchenkob5017952009-05-28 15:58:50 -040086# check for -Wno-pointer-sign compiler support (GCC >= 4)
87saved_cflags="$CFLAGS"
88CFLAGS="$CFLAGS -Wno-pointer-sign"
89AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
90 nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
91CFLAGS="$saved_cflags"
92
93AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow"
94
95AC_SUBST(VISIBILITY_CFLAGS)
Daniel Drake852bba42007-11-28 13:48:45 +000096AC_SUBST(AM_CFLAGS)
Nathan Hjelmb49f6bf2009-02-16 21:39:29 -030097AC_SUBST(AM_LDFLAGS)
Daniel Drake852bba42007-11-28 13:48:45 +000098
Aurelien Jarnod25b5662008-09-04 13:50:49 +020099AC_CONFIG_FILES([libusb-1.0.pc] [Makefile] [libusb/Makefile] [examples/Makefile] [doc/Makefile] [doc/doxygen.cfg])
Daniel Drake852bba42007-11-28 13:48:45 +0000100AC_OUTPUT
101