+AC_FUNC_REALLOC
+AC_FUNC_STRERROR_R
+AC_CHECK_FUNCS([ \
+ atexit \
+ dirfd \
+ dup2 \
+ ftruncate \
+ gethostbyname \
+ gethostname \
+ gettimeofday \
+ localtime_r \
+ memchr \
+ memset \
+ mkdir \
+ mkdtemp \
+ munmap \
+ rmdir \
+ setenv \
+ socket \
+ strchr \
+ strdup \
+ strerror \
+ strndup \
+ strnlen \
+ strrchr \
+ strtoul \
+ strtoull \
+ tzset \
+ uname \
+])
+
+# Check for MinGW32.
+MINGW32=no
+case $host in
+ *-*-mingw*)
+ MINGW32=yes;;
+esac
+
+AM_CONDITIONAL([BABELTRACE_BUILD_WITH_MINGW], [test "x$MINGW32" = "xyes"])
+
+# Check for libuuid
+AC_CHECK_LIB([uuid], [uuid_generate],
+[
+ AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBUUID], 1, [Has libuuid support.])
+ have_libuuid=yes
+],
+[
+ # libuuid not found, check for uuid_create in libc.
+ AC_CHECK_LIB([c], [uuid_create],
+ [
+ AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBC_UUID], 1, [Has libc uuid support.])
+ have_libc_uuid=yes
+ ],
+ [
+ # for MinGW32 we have our own internal implemenation of uuid using Windows functions.
+ if test "x$MINGW32" = xno; then
+ AC_MSG_ERROR([Cannot find libuuid uuid_generate nor libc uuid_create. Use [LDFLAGS]=-Ldir to specify their location.])
+ fi
+ ])
+]
+)
+AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBUUID], [test "x$have_libuuid" = "xyes"])
+AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBC_UUID], [test "x$have_libc_uuid" = "xyes"])
+
+# Check for fmemopen
+AC_CHECK_LIB([c], [fmemopen],
+[
+ AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_FMEMOPEN], 1, [Has fmemopen support.])
+]
+)
+
+# Check for open_memstream
+AC_CHECK_LIB([c], [open_memstream],
+[
+ AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_OPEN_MEMSTREAM], 1, [Has open_memstream support.])
+]
+)
+
+# Check for posix_fallocate
+AC_CHECK_LIB([c], [posix_fallocate],
+[
+ AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_POSIX_FALLOCATE], 1, [Has posix_fallocate support.])
+]
+)
+
+# Check for faccessat
+AC_CHECK_LIB([c], [faccessat],
+[
+ AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_FACCESSAT], 1, [Has faccessat support.])
+]
+)
+
+AC_CHECK_LIB([popt], [poptGetContext], [],
+ [AC_MSG_ERROR([Cannot find popt.])]
+)
+
+# For Python
+# SWIG version needed or newer:
+swig_version=2.0.0
+
+AC_ARG_ENABLE([python-bindings],
+ [AC_HELP_STRING([--enable-python-bindings],
+ [generate Python bindings])],
+ [enable_python=yes], [enable_python=no])
+
+AM_CONDITIONAL([USE_PYTHON], [test "x${enable_python:-yes}" = xyes])
+
+if test "x${enable_python:-yes}" = xyes; then
+ AX_PKG_SWIG($swig_version, [], [ AC_MSG_ERROR([SWIG $swig_version or newer is needed]) ])
+ AM_PATH_PYTHON
+
+ AM_PATH_PYTHON_MODULES([PYTHON])
+ # pythondir is the path where extra modules are to be installed
+ pythondir=$PYTHON_PREFIX/$PYTHON_MODULES_PATH
+ # pyexecdir is the path that contains shared objects used by the extra modules
+ pyexecdir=$PYTHON_EXEC_PREFIX/$PYTHON_MODULES_PATH
+ AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing python-config])
+ AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])
+ AS_IF([test -z "$PYTHON_INCLUDE"], [
+ AS_IF([test -z "$PYTHON_CONFIG"], [
+ AC_PATH_PROGS([PYTHON_CONFIG],
+ [python$PYTHON_VERSION-config python-config],
+ [no],
+ [`dirname $PYTHON`])
+ AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON. Do you have python-dev installed?])])
+ ])
+ AC_MSG_CHECKING([python include flags])
+ PYTHON_INCLUDE=`$PYTHON_CONFIG --includes`
+ AC_MSG_RESULT([$PYTHON_INCLUDE])
+ ])
+
+else
+ AC_MSG_NOTICE([You may configure with --enable-python-bindings ]dnl
+[if you want Python bindings.])
+
+fi
+
+# Optional debuginfo feature (enabled by default)
+AC_ARG_ENABLE([debuginfo], [AC_HELP_STRING([--disable-debuginfo], [disable the debuginfo feature])], [], [enable_debuginfo=yes])
+
+AM_CONDITIONAL([ENABLE_DEBUGINFO], [test "x$enable_debuginfo" = xyes])
+AS_IF([test "x$enable_debuginfo" = xyes], [
+ AC_CHECK_LIB([elf], [elf_version], [], [])
+ AC_CHECK_LIB([dw], [dwarf_begin], [], [])
+ AS_IF([test "x$ac_cv_lib_elf_elf_version" = xno || test "x$ac_cv_lib_dw_dwarf_begin" = xno],
+ [AC_MSG_ERROR(Missing library from elfutils required for debuginfo. You can disable this feature with --disable-debuginfo.)]
+ )
+ AC_DEFINE([ENABLE_DEBUGINFO], [1], [Define to 1 if you enable the 'debuginfo' feature])
+], [])