|
kusano |
7d535a |
dnl These m4 macros are whitespace sensitive and break if moved around much.
|
|
kusano |
7d535a |
m4_define([LU_VERSION_H], m4_include([libusb/version.h]))
|
|
kusano |
7d535a |
m4_define([LU_DEFINE_VERSION_ATOM],
|
|
kusano |
7d535a |
[m4_define([$1], m4_bregexp(LU_VERSION_H,
|
|
kusano |
7d535a |
[^#define\s*$1\s*\([0-9]*\).*], [\1]))])
|
|
kusano |
7d535a |
m4_define([LU_DEFINE_VERSION_RC_ATOM],
|
|
kusano |
7d535a |
[m4_define([$1], m4_bregexp(LU_VERSION_H,
|
|
kusano |
7d535a |
[^#define\s*$1\s*"\(-rc[0-9]*\)".*], [\1]))])
|
|
kusano |
7d535a |
dnl The m4_bregexp() returns (only) the numbers following the #define named
|
|
kusano |
7d535a |
dnl in the first macro parameter. m4_define() then defines the name for use
|
|
kusano |
7d535a |
dnl in AC_INIT().
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
LU_DEFINE_VERSION_ATOM([LIBUSB_MAJOR])
|
|
kusano |
7d535a |
LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR])
|
|
kusano |
7d535a |
LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO])
|
|
kusano |
7d535a |
LU_DEFINE_VERSION_RC_ATOM([LIBUSB_RC])
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AC_INIT([libusb], LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC, [libusb-devel@lists.sourceforge.net], [libusb], [http://www.libusb.org/])
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# Library versioning
|
|
kusano |
7d535a |
# These numbers should be tweaked on every release. Read carefully:
|
|
kusano |
7d535a |
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
|
kusano |
7d535a |
# http://sourceware.org/autobook/autobook/autobook_91.html
|
|
kusano |
7d535a |
lt_current="1"
|
|
kusano |
7d535a |
lt_revision="0"
|
|
kusano |
7d535a |
lt_age="1"
|
|
kusano |
7d535a |
LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AM_INIT_AUTOMAKE
|
|
kusano |
7d535a |
AM_MAINTAINER_MODE
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AC_CONFIG_SRCDIR([libusb/core.c])
|
|
kusano |
7d535a |
AC_CONFIG_MACRO_DIR([m4])
|
|
kusano |
7d535a |
AM_CONFIG_HEADER([config.h])
|
|
kusano |
7d535a |
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AC_PREREQ([2.50])
|
|
kusano |
7d535a |
AC_PROG_CC
|
|
kusano |
7d535a |
AC_PROG_LIBTOOL
|
|
kusano |
7d535a |
LT_LANG([Windows Resource])
|
|
kusano |
7d535a |
AC_C_INLINE
|
|
kusano |
7d535a |
AM_PROG_CC_C_O
|
|
kusano |
7d535a |
AC_DEFINE([_GNU_SOURCE], 1, [Use GNU extensions])
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
LTLDFLAGS="${LTLDFLAGS} -no-undefined"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AC_MSG_CHECKING([operating system])
|
|
kusano |
7d535a |
case $host in
|
|
kusano |
7d535a |
*-linux*)
|
|
kusano |
7d535a |
AC_MSG_RESULT([Linux])
|
|
kusano |
7d535a |
backend="linux"
|
|
kusano |
7d535a |
;;
|
|
kusano |
7d535a |
*-darwin*)
|
|
kusano |
7d535a |
AC_MSG_RESULT([Darwin/Mac OS X])
|
|
kusano |
7d535a |
backend="darwin"
|
|
kusano |
7d535a |
;;
|
|
kusano |
7d535a |
*-openbsd*)
|
|
kusano |
7d535a |
AC_MSG_RESULT([OpenBSD])
|
|
kusano |
7d535a |
backend="openbsd"
|
|
kusano |
7d535a |
;;
|
|
kusano |
7d535a |
*-netbsd*)
|
|
kusano |
7d535a |
AC_MSG_RESULT([NetBSD (using OpenBSD backend)])
|
|
kusano |
7d535a |
backend="openbsd"
|
|
kusano |
7d535a |
;;
|
|
kusano |
7d535a |
*-mingw*)
|
|
kusano |
7d535a |
AC_MSG_RESULT([Windows])
|
|
kusano |
7d535a |
backend="windows"
|
|
kusano |
7d535a |
;;
|
|
kusano |
7d535a |
*-cygwin*)
|
|
kusano |
7d535a |
AC_MSG_RESULT([Cygwin (using Windows backend)])
|
|
kusano |
7d535a |
backend="windows"
|
|
kusano |
7d535a |
threads="posix"
|
|
kusano |
7d535a |
;;
|
|
kusano |
7d535a |
*)
|
|
kusano |
7d535a |
AC_MSG_ERROR([unsupported operating system])
|
|
kusano |
7d535a |
esac
|
|
kusano |
7d535a |
case $backend in
|
|
kusano |
7d535a |
linux)
|
|
kusano |
7d535a |
AC_DEFINE(OS_LINUX, 1, [Linux backend])
|
|
kusano |
7d535a |
AC_SUBST(OS_LINUX)
|
|
kusano |
7d535a |
AC_CHECK_LIB(rt, clock_gettime, PC_LIBS_PRIVATE="-lrt")
|
|
kusano |
7d535a |
threads="posix"
|
|
kusano |
7d535a |
THREAD_CFLAGS="-pthread"
|
|
kusano |
7d535a |
PC_LIBS_PRIVATE="${PC_LIBS_PRIVATE} -pthread"
|
|
kusano |
7d535a |
AC_CHECK_HEADERS([poll.h])
|
|
kusano |
7d535a |
AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
|
|
kusano |
7d535a |
;;
|
|
kusano |
7d535a |
darwin)
|
|
kusano |
7d535a |
AC_DEFINE(OS_DARWIN, 1, [Darwin backend])
|
|
kusano |
7d535a |
AC_SUBST(OS_DARWIN)
|
|
kusano |
7d535a |
threads="posix"
|
|
kusano |
7d535a |
PC_LIBS_PRIVATE="-lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation"
|
|
kusano |
7d535a |
LTLDFLAGS="${LTLDFLAGS} -Wl,-prebind"
|
|
kusano |
7d535a |
AC_CHECK_HEADERS([poll.h])
|
|
kusano |
7d535a |
AC_CHECK_TYPE([nfds_t],
|
|
kusano |
7d535a |
[AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])],
|
|
kusano |
7d535a |
[AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])],
|
|
kusano |
7d535a |
[#include <poll.h>])</poll.h>
|
|
kusano |
7d535a |
;;
|
|
kusano |
7d535a |
openbsd)
|
|
kusano |
7d535a |
AC_DEFINE(OS_OPENBSD, 1, [OpenBSD backend])
|
|
kusano |
7d535a |
AC_SUBST(OS_OPENBSD)
|
|
kusano |
7d535a |
threads="posix"
|
|
kusano |
7d535a |
THREAD_CFLAGS="-pthread"
|
|
kusano |
7d535a |
PC_LIBS_PRIVATE="-pthread"
|
|
kusano |
7d535a |
AC_CHECK_HEADERS([poll.h])
|
|
kusano |
7d535a |
AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
|
|
kusano |
7d535a |
;;
|
|
kusano |
7d535a |
windows)
|
|
kusano |
7d535a |
AC_DEFINE(OS_WINDOWS, 1, [Windows backend])
|
|
kusano |
7d535a |
AC_SUBST(OS_WINDOWS)
|
|
kusano |
7d535a |
PC_LIBS_PRIVATE=""
|
|
kusano |
7d535a |
LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
|
|
kusano |
7d535a |
AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])
|
|
kusano |
7d535a |
;;
|
|
kusano |
7d535a |
esac
|
|
kusano |
7d535a |
AC_SUBST(THREAD_CFLAGS)
|
|
kusano |
7d535a |
AC_SUBST(PC_LIBS_PRIVATE)
|
|
kusano |
7d535a |
LIBS="${LIBS} ${PC_LIBS_PRIVATE}"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux)
|
|
kusano |
7d535a |
AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin)
|
|
kusano |
7d535a |
AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xopenbsd)
|
|
kusano |
7d535a |
AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows)
|
|
kusano |
7d535a |
AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix)
|
|
kusano |
7d535a |
if test "$threads" = posix; then
|
|
kusano |
7d535a |
AC_DEFINE(THREADS_POSIX, 1, [Use POSIX Threads])
|
|
kusano |
7d535a |
fi
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# timerfd
|
|
kusano |
7d535a |
AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
|
|
kusano |
7d535a |
AC_ARG_ENABLE([timerfd],
|
|
kusano |
7d535a |
[AS_HELP_STRING([--enable-timerfd],
|
|
kusano |
7d535a |
[use timerfd for timing (default auto)])],
|
|
kusano |
7d535a |
[use_timerfd=$enableval], [use_timerfd='auto'])
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then
|
|
kusano |
7d535a |
AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
|
|
kusano |
7d535a |
fi
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AC_CHECK_DECL([TFD_NONBLOCK], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys timerfd.h="">])</sys>
|
|
kusano |
7d535a |
if test "x$use_timerfd" = "xyes" -a "x$tfd_hdr_ok" = "xno"; then
|
|
kusano |
7d535a |
AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
|
|
kusano |
7d535a |
fi
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AC_MSG_CHECKING([whether to use timerfd for timing])
|
|
kusano |
7d535a |
if test "x$use_timerfd" = "xno"; then
|
|
kusano |
7d535a |
AC_MSG_RESULT([no (disabled by user)])
|
|
kusano |
7d535a |
else
|
|
kusano |
7d535a |
if test "x$timerfd_h" = "x1" -a "x$tfd_hdr_ok" = "xyes"; then
|
|
kusano |
7d535a |
AC_MSG_RESULT([yes])
|
|
kusano |
7d535a |
AC_DEFINE(USBI_TIMERFD_AVAILABLE, 1, [timerfd headers available])
|
|
kusano |
7d535a |
else
|
|
kusano |
7d535a |
AC_MSG_RESULT([no (header not available)])
|
|
kusano |
7d535a |
fi
|
|
kusano |
7d535a |
fi
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AC_CHECK_TYPES(struct timespec)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# Message logging
|
|
kusano |
7d535a |
AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
|
|
kusano |
7d535a |
[log_enabled=$enableval],
|
|
kusano |
7d535a |
[log_enabled='yes'])
|
|
kusano |
7d535a |
if test "x$log_enabled" != "xno"; then
|
|
kusano |
7d535a |
AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
|
|
kusano |
7d535a |
fi
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
|
|
kusano |
7d535a |
[enable debug logging (default n)])],
|
|
kusano |
7d535a |
[debug_log_enabled=$enableval],
|
|
kusano |
7d535a |
[debug_log_enabled='no'])
|
|
kusano |
7d535a |
if test "x$debug_log_enabled" != "xno"; then
|
|
kusano |
7d535a |
AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging])
|
|
kusano |
7d535a |
fi
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# Examples build
|
|
kusano |
7d535a |
AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
|
|
kusano |
7d535a |
[build example applications (default n)])],
|
|
kusano |
7d535a |
[build_examples=$enableval],
|
|
kusano |
7d535a |
[build_examples='no'])
|
|
kusano |
7d535a |
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# check for -fvisibility=hidden compiler support (GCC >= 3.4)
|
|
kusano |
7d535a |
saved_cflags="$CFLAGS"
|
|
kusano |
7d535a |
# -Werror required for cygwin
|
|
kusano |
7d535a |
CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
|
|
kusano |
7d535a |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
|
|
kusano |
7d535a |
[VISIBILITY_CFLAGS="-fvisibility=hidden"
|
|
kusano |
7d535a |
AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility]) ],
|
|
kusano |
7d535a |
[ VISIBILITY_CFLAGS=""
|
|
kusano |
7d535a |
AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility]) ],
|
|
kusano |
7d535a |
])
|
|
kusano |
7d535a |
CFLAGS="$saved_cflags"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# check for -Wno-pointer-sign compiler support (GCC >= 4)
|
|
kusano |
7d535a |
saved_cflags="$CFLAGS"
|
|
kusano |
7d535a |
CFLAGS="$CFLAGS -Wno-pointer-sign"
|
|
kusano |
7d535a |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
|
|
kusano |
7d535a |
nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
|
|
kusano |
7d535a |
CFLAGS="$saved_cflags"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# sigaction not available on MinGW
|
|
kusano |
7d535a |
AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no])
|
|
kusano |
7d535a |
AM_CONDITIONAL([HAVE_SIGACTION], [test "x$have_sigaction" = "xyes"])
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# headers not available on all platforms but required on others
|
|
kusano |
7d535a |
AC_CHECK_HEADERS([sys/time.h])
|
|
kusano |
7d535a |
AC_CHECK_FUNCS(gettimeofday)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AM_CFLAGS="-std=gnu99 -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AC_SUBST(VISIBILITY_CFLAGS)
|
|
kusano |
7d535a |
AC_SUBST(AM_CFLAGS)
|
|
kusano |
7d535a |
AC_SUBST(LTLDFLAGS)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
AC_CONFIG_FILES([libusb-1.0.pc])
|
|
kusano |
7d535a |
AC_CONFIG_FILES([Makefile])
|
|
kusano |
7d535a |
AC_CONFIG_FILES([libusb/Makefile])
|
|
kusano |
7d535a |
AC_CONFIG_FILES([examples/Makefile])
|
|
kusano |
7d535a |
AC_CONFIG_FILES([doc/Makefile])
|
|
kusano |
7d535a |
AC_CONFIG_FILES([doc/doxygen.cfg])
|
|
kusano |
7d535a |
AC_OUTPUT
|