Use deviced instead of USB Security Daemon
[platform/upstream/libusb.git] / configure.ac
index ec07937..c822e5b 100644 (file)
@@ -15,7 +15,7 @@ LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR])
 LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO])
 LU_DEFINE_VERSION_RC_ATOM([LIBUSB_RC])
 
-AC_INIT([libusbx],[LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC],[libusbx-devel@lists.sourceforge.net],[libusbx],[http://libusbx.org])
+AC_INIT([libusb],[LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC],[libusb-devel@lists.sourceforge.net],[libusb],[http://libusb.info])
 
 # Library versioning
 # These numbers should be tweaked on every release. Read carefully:
@@ -27,15 +27,15 @@ lt_age="1"
 LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}"
 
 AM_INIT_AUTOMAKE
-AM_MAINTAINER_MODE
 
 AC_CONFIG_SRCDIR([libusb/core.c])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([config.h])
 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
 
-AC_PREREQ([2.50])
+AC_PREREQ([2.69])
 AC_PROG_CC
+AC_PROG_CXX
 LT_INIT
 LT_LANG([Windows Resource])
 AC_C_INLINE
@@ -46,8 +46,18 @@ LTLDFLAGS="${LTLDFLAGS} -no-undefined"
 
 AC_MSG_CHECKING([operating system])
 
+dnl on linux-android platform, some functions are in different places
 case $host in
-*-linux*)
+*-linux-android*)
+       AC_MSG_RESULT([This is a Linux-Android system])
+       is_backend_android="yes"
+       ;;
+*)
+       is_backend_android="no"
+esac
+
+case $host in
+*-linux* | *-uclinux*)
        AC_MSG_RESULT([Linux])
        backend="linux"
        threads="posix"
@@ -59,15 +69,15 @@ case $host in
        ;;
 *-openbsd*)
        AC_MSG_RESULT([OpenBSD])
-       backend="bsd"
+       backend="openbsd"
        threads="posix"
        ;;
 *-netbsd*)
-       AC_MSG_RESULT([NetBSD (using OpenBSD backend)])
-       backend="bsd"
+       AC_MSG_RESULT([NetBSD])
+       backend="netbsd"
        threads="posix"
        ;;
-*-mingw*)
+*-mingw* | *msys*)
        AC_MSG_RESULT([Windows])
        backend="windows"
        threads="windows"
@@ -79,17 +89,64 @@ case $host in
        backend="windows"
        threads="posix"
        ;;
+*-haiku*)
+       AC_MSG_RESULT([Haiku])
+       backend="haiku"
+       threads="posix"
+       ;;
+*-solaris*)
+       AC_MSG_RESULT([SunOS])
+       backend="sunos"
+       threads="posix"
+       ;;
 *)
-       AC_MSG_ERROR([unsupported operating system])
+       AC_MSG_ERROR([unsupported operating system $host])
 esac
 
 case $backend in
 linux)
        AC_DEFINE(OS_LINUX, 1, [Linux backend])
        AC_SUBST(OS_LINUX)
+       AC_ARG_ENABLE([deviced],
+               [AC_HELP_STRING([--enable-deviced], [Use deviced to obtain dev node fds [default=no]])],
+               [], [enable_deviced="no"])
+       if test "x$enable_deviced" = "xyes"; then
+          PKG_CHECK_MODULES([DEVICED], [deviced])
+          AC_DEFINE(USE_DEVICED, 1, [Use deviced to obtain dev node fds])
+       fi
+
+       AC_SUBST(USE_DEVICED)
+
        AC_SEARCH_LIBS(clock_gettime, rt, [], [], -pthread)
+       AC_ARG_ENABLE([udev],
+               [AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended) [default=yes]])],
+               [], [enable_udev="yes"])
+               if test "x$enable_udev" = "xyes" ; then
+                       # system has udev. use it or fail!
+                       AC_CHECK_HEADERS([libudev.h],[],[AC_ERROR(["udev support requested but libudev not installed"])])
+                       AC_CHECK_LIB([udev], [udev_new], [], [AC_ERROR(["udev support requested but libudev not installed"])])
+                       AC_DEFINE(USE_UDEV, 1, [Use udev for device enumeration/hotplug])
+               else
+                       AC_CHECK_HEADERS([asm/types.h], [], [])
+                       AC_CHECK_HEADERS([sys/socket.h linux/netlink.h], [], [AC_ERROR(["Linux netlink headers not found"])], [
+#ifdef HAVE_ASM_TYPES_H
+#include <asm/types.h>
+#endif
+#include <sys/socket.h>
+])
+               fi
+               AC_SUBST(USE_UDEV)
+
+case $is_backend_android in
+yes)
+       dnl there are gettimeofday function but configure doesn't seem to be able to find it.
+       AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [Define if you have gettimeofday])
+       ;;
+*)
        THREAD_CFLAGS="-pthread"
        LIBS="${LIBS} -pthread"
+esac
+
        AC_CHECK_HEADERS([poll.h])
        AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
        ;;
@@ -104,20 +161,52 @@ darwin)
                [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])],
                [#include <poll.h>])
        ;;
-bsd)
-       AC_DEFINE(OS_OPENBSD, 1, [OpenBSD/NetBSD backend])
+openbsd)
+       AC_DEFINE(OS_OPENBSD, 1, [OpenBSD backend])
        AC_SUBST(OS_OPENBSD)
        THREAD_CFLAGS="-pthread"
        LIBS="-pthread"
        AC_CHECK_HEADERS([poll.h])
        AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
        ;;
+sunos)
+       AC_DEFINE(OS_SUNOS, 1, [SunOS backend])
+       AC_SUBST(OS_SUNOS)
+       THREAD_CFLAGS="-pthread"
+       LIBS="-pthread -ldevinfo"
+       AC_CHECK_HEADERS([poll.h])
+       AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
+       ;;
+netbsd)
+       AC_DEFINE(OS_NETBSD, 1, [NetBSD backend])
+       AC_SUBST(OS_NETBSD)
+       THREAD_CFLAGS="-pthread"
+       LIBS="-pthread"
+       AC_CHECK_HEADERS([poll.h])
+       AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
+       ;;
 windows)
        AC_DEFINE(OS_WINDOWS, 1, [Windows backend])
        AC_SUBST(OS_WINDOWS)
        LIBS=""
        LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
        AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])
+       AC_DEFINE([WINVER], 0x0501, [Oldest Windows version supported])
+
+       AC_ARG_ENABLE([usbdk],
+               [AC_HELP_STRING([--enable-usbdk], [use UsbDk Windows backend [default=no]])],
+               [], [enable_usbdk="no"])
+               if test "x$enable_usbdk" = "xyes" ; then
+                   AC_DEFINE(USE_USBDK, 1, [Use UsbDk Windows backend])
+               fi
+               AC_SUBST(USE_USBDK)
+       ;;
+haiku)
+       AC_DEFINE(OS_HAIKU, 1, [Haiku backend])
+       AC_SUBST(OS_HAIKU)
+       LIBS="${LIBS} -lbe"
+       AC_CHECK_HEADERS([poll.h])
+       AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
        ;;
 esac
 
@@ -125,10 +214,16 @@ AC_SUBST(LIBS)
 
 AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux)
 AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin)
-AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xbsd)
+AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xopenbsd)
+AM_CONDITIONAL(OS_SUNOS, test "x$backend" = xsunos)
+AM_CONDITIONAL(OS_NETBSD, test "x$backend" = xnetbsd)
 AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows)
+AM_CONDITIONAL(OS_HAIKU, test "x$backend" = xhaiku)
 AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix)
-AM_CONDITIONAL(CREATE_IMPORT_LIB, test "x$create_import_lib" = "xyes") 
+AM_CONDITIONAL(CREATE_IMPORT_LIB, test "x$create_import_lib" = "xyes")
+AM_CONDITIONAL(USE_UDEV, test "x$enable_udev" = xyes)
+AM_CONDITIONAL(USE_USBDK, test "x$enable_usbdk" = xyes)
+AM_CONDITIONAL(USE_DEVICED, test "x$enable_deviced" = xyes)
 if test "$threads" = posix; then
        AC_DEFINE(THREADS_POSIX, 1, [Use POSIX Threads])
 fi
@@ -137,7 +232,7 @@ fi
 AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
 AC_ARG_ENABLE([timerfd],
        [AS_HELP_STRING([--enable-timerfd],
-               [use timerfd for timing (default auto)])],
+               [use timerfd for timing [default=auto]])],
        [use_timerfd=$enableval], [use_timerfd='auto'])
 
 if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then
@@ -172,23 +267,38 @@ if test "x$log_enabled" != "xno"; then
 fi
 
 AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
-       [start with debug message logging enabled (default n)])],
+       [start with debug message logging enabled [default=no]])],
        [debug_log_enabled=$enableval],
        [debug_log_enabled='no'])
 if test "x$debug_log_enabled" != "xno"; then
        AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Start with debug message logging enabled])
 fi
 
+AC_ARG_ENABLE([system-log], [AS_HELP_STRING([--enable-system-log],
+       [output logging messages to system wide log, if supported by the OS [default=no]])],
+       [system_log_enabled=$enableval],
+       [system_log_enabled='no'])
+if test "x$system_log_enabled" != "xno"; then
+       AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], 1, [Enable output to system log])
+fi
+
+# Check if syslog is available in standard C library
+AC_CHECK_HEADERS(syslog.h)
+AC_CHECK_FUNC([syslog], [have_syslog=yes], [have_syslog=no])
+if test "x$have_syslog" != "xno"; then
+       AC_DEFINE([HAVE_SYSLOG_FUNC], 1, [syslog() function available])
+fi
+
 # Examples build
 AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
-       [build example applications (default n)])],
+       [build example applications [default=no]])],
        [build_examples=$enableval],
        [build_examples='no'])
 AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
 
 # Tests build
 AC_ARG_ENABLE([tests-build], [AS_HELP_STRING([--enable-tests-build],
-       [build test applications (default n)])],
+       [build test applications [default=no]])],
        [build_tests=$enableval],
        [build_tests='no'])
 AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != "xno"])
@@ -221,7 +331,18 @@ AC_CHECK_HEADERS([sys/time.h])
 AC_CHECK_FUNCS(gettimeofday)
 AC_CHECK_HEADERS([signal.h])
 
-AM_CFLAGS="${AM_CFLAGS} -std=gnu99 -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow ${THREAD_CFLAGS} ${VISIBILITY_CFLAGS}"
+# check for -std=gnu99 compiler support
+saved_cflags="$CFLAGS"
+CFLAGS="-std=gnu99"
+AC_MSG_CHECKING([whether CC supports -std=gnu99])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+    [AC_MSG_RESULT([yes])]
+    [AM_CFLAGS="${AM_CFLAGS} -std=gnu99"],
+    [AC_MSG_RESULT([no])]
+)
+CFLAGS="$saved_cflags"
+
+AM_CFLAGS="${AM_CFLAGS} -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow ${THREAD_CFLAGS} ${VISIBILITY_CFLAGS}"
 
 AC_SUBST(AM_CFLAGS)
 AC_SUBST(LTLDFLAGS)