[config] Many updates to configuration and feature checks

- Added custom checks for libraries and pkgconfig modules that test library
 presence with additional checks for use of headers and functions with
 given options.  Also support correct additional feature library checks
 using provided flags.
- Added custom enable/disable feature macros to simplify their use.
- Use custom CFLAGS and LIBS variables for Makefiles to simplify maintenance.
- Update many feature checks from platform to function.
- Streamline many function checks.
- Correctly check gnutls, gcrypt and gpg-error libraries.
- Fix chromecast and spotify config and compile on FreeBSD
- Added inotify, signalfd and kqueue, and byte swap checks.
- Many clarifications of error messages.
- Correct json-c checks to properly use supplied CFLAGS.
- Correct many quoting inconsistencies
- Use __DATE__ in place of BUILDDATE
- Use full path for gperf and antlr3
- Remove unnecessary CFLAGS
- Added tests for pthread_setname_np parameters
- Added tests for clock_gettime and timer_settime
- Added tests for time.h
- Test if pthread, dl and rt libs are required/available.
- Updated checks for libunistring
This commit is contained in:
Scott Shambarger
2017-01-06 00:44:18 -08:00
parent 8ead7ea3b8
commit ce4ef0aa23
27 changed files with 460 additions and 573 deletions

View File

@@ -1,77 +0,0 @@
# absolute-header.m4 serial 12
dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Derek Price.
# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
# ---------------------------------------
# Find the absolute name of a header file, testing first if the header exists.
# If the header were sys/inttypes.h, this macro would define
# ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of sys/inttypes.h
# in config.h
# (e.g. `#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"').
# The three "///" are to pacify Sun C 5.8, which otherwise would say
# "warning: #include of /usr/include/... may be non-portable".
# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
# Note: This macro assumes that the header file is not empty after
# preprocessing, i.e. it does not only define preprocessor macros but also
# provides some type/enum definitions or function/variable declarations.
AC_DEFUN([gl_ABSOLUTE_HEADER],
[AC_REQUIRE([AC_CANONICAL_HOST])
AC_LANG_PREPROC_REQUIRE()dnl
m4_foreach_w([gl_HEADER_NAME], [$1],
[AS_VAR_PUSHDEF([gl_absolute_header],
[gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl
AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>],
m4_defn([gl_absolute_header]),
[AS_VAR_PUSHDEF([ac_header_exists],
[ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl
AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl
if test AS_VAR_GET(ac_header_exists) = yes; then
gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME]))
fi
AS_VAR_POPDEF([ac_header_exists])dnl
])dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])),
["AS_VAR_GET(gl_absolute_header)"],
[Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.])
AS_VAR_POPDEF([gl_absolute_header])dnl
])dnl
])# gl_ABSOLUTE_HEADER
# gl_ABSOLUTE_HEADER_ONE(HEADER)
# ------------------------------
# Like gl_ABSOLUTE_HEADER, except that:
# - it assumes that the header exists,
# - it uses the current CPPFLAGS,
# - it does not cache the result,
# - it is silent.
AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
[
AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])])
dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
dnl that contain only a #include of other header files and no
dnl non-comment tokens of their own. This leads to a failure to
dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
dnl and others. The workaround is to force preservation of comments
dnl through option -C. This ensures all necessary #line directives
dnl are present. GCC supports option -C as well.
case "$host_os" in
aix*) gl_absname_cpp="$ac_cpp -C" ;;
*) gl_absname_cpp="$ac_cpp" ;;
esac
dnl eval is necessary to expand gl_absname_cpp.
dnl Ultrix and Pyramid sh refuse to redirect output of eval,
dnl so use subshell.
AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]),
[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
sed -n '\#/$1#{
s#.*"\(.*/$1\)".*#\1#
s#^/[^/]#//&#
p
q
}'`])
])

145
m4/fork_checks.m4 Normal file
View File

@@ -0,0 +1,145 @@
# fork_checks.m4 serial 1
dnl Copyright (c) Scott Shambarger <devel@shambarger.net>
dnl
dnl Copying and distribution of this file, with or without modification, are
dnl permitted in any medium without royalty provided the copyright notice
dnl and this notice are preserved. This file is offered as-is, without any
dnl warranty.
dnl _FORK_VARS_SET(TARGET, VAR)
dnl --------------------------
dnl Convenience function to set CPPFLAGS/LIBS and TARGET_{CPPFLAGS/LIBS}
dnl from VAR_{CFLAGS/LIBS}
m4_define([_FORK_VARS_SET],
[[
LIBS="$][$2_LIBS $LIBS"
CPPFLAGS="$][$2_CFLAGS $CPPFLAGS"
][$1_LIBS="$][$2_LIBS $][$1_LIBS"]
AC_LIB_APPENDTOVAR([$1_CPPFLAGS], [$][$2_CFLAGS])
])
dnl FORK_LIB_REQUIRE(TARGET, DESCRIPTION, ENV, LIBRARY, [FUNCTION], [HEADER],
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl -------------------------------------------------------------------------
dnl Check for software which lacks pkg-config support, failing if not found.
dnl When ENV_CFLAGS and ENV_LIBS are set (ENV is prefix), tries to link
dnl FUNCTION/include HEADER with them, and adds them to TARGET_CPPFLAGS and
dnl TARGET_LIBS. With unset environment, expands like AC_SEARCH_LIBS on
dnl FUNCTION/LIBRARY and checks HEADER with default CPPFLAGS/LIBS, and suggests
dnl providing ENV variables on failure. Expands optional ACTION-IF-FOUND
dnl with working CPPFLAGS/LIBS for additional checks. DESCRIPTION used as
dnl friendly name in error messages to help user identify software.
dnl Restores original CPPFLAGS and LIBS when done. Expands
dnl ACTION-IF-NOT-FOUND if ENV_* not set, and FUNCTION in LIBRARY not
dnl found overriding default error. (NOTE: default must be empty to get error)
AC_DEFUN([FORK_LIB_REQUIRE],
[AS_VAR_PUSHDEF([FORK_MSG], [fork_msg_$3])
AC_ARG_VAR([$3_CFLAGS], [C compiler flags for $2, overriding search])
AC_ARG_VAR([$3_LIBS], [linker flags for $2, overriding search])
[save_$3_LIBS=$LIBS; save_$3_CPPFLAGS=$CPPFLAGS]
AS_IF([[test -n "$][$3_CFLAGS" && test -n "$][$3_LIBS"]],
[AS_VAR_SET([FORK_MSG], [["
Library specific environment variables $3_LIBS and
$3_CFLAGS were used, verify they are correct..."]])
_FORK_VARS_SET([$1], [$3])
m4_ifval([$5], [AC_CHECK_FUNC([[$5]], [],
[AC_MSG_FAILURE([[Unable to link function $5 with $2.$]FORK_MSG])])])],
[AS_VAR_SET([FORK_MSG], [["
Install $2 in the default include path, or alternatively set
library specific environment variables $3_CFLAGS
and $3_LIBS."]])
m4_ifval([$5],
[AC_MSG_CHECKING([[for library containing $5...]])
AC_TRY_LINK_FUNC([[$5]], [AC_MSG_RESULT([[none required]])],
[[LIBS="-l$4 $LIBS"
$1_LIBS="-l$4 $][$1_LIBS"]
AC_TRY_LINK_FUNC([[$5]], [AC_MSG_RESULT([[-l$4]])],
[AC_MSG_RESULT([[no]])
m4_default([$8], [AC_MSG_FAILURE([[Function $5 in lib$4 not found.$]FORK_MSG])])])
])
])
])
m4_ifval([$6], [AC_CHECK_HEADER([[$6]], [],
[AC_MSG_FAILURE([[Unable to find header $6 for $2.$]FORK_MSG])])])
$7
[LIBS=$save_$3_LIBS; CPPFLAGS=$save_$3_CPPFLAGS]
AS_VAR_POPDEF([FORK_MSG])
])
dnl FORK_MODULES_CHECK(TARGET, ENV, MODULES, [FUNCTION], [HEADER],
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl --------------------------------------------------------------
dnl Expands PKG_CHECK_MODULES, but when found also attempt to link
dnl FUNCTION and include HEADER. Appends working package values to
dnl TARGET_CPPFLAGS and TARGET_LIBS. Expands optional ACTION-IF-FOUND with
dnl working CPPFLAGS/LIBS for additional checks. Expands
dnl ACTION-IF-NOT-FOUND only if package not found (not link/include failures)
dnl overriding default error. (NOTE: default must be empty to get error!)
dnl Restores original CPPFLAGS and LIBS when done.
AC_DEFUN([FORK_MODULES_CHECK],
[PKG_CHECK_MODULES([$2], [[$3]],
[[save_$2_LIBS=$LIBS; save_$2_CPPFLAGS=$CPPFLAGS]
_FORK_VARS_SET([$1], [$2])
m4_ifval([$4], [AC_CHECK_FUNC([[$4]], [],
[AC_MSG_ERROR([[Unable to link function $4]])])])
m4_ifval([$5], [AC_CHECK_HEADER([[$5]], [],
[AC_MSG_ERROR([[Unable to find header $5]])])])
$6
[LIBS=$save_$2_LIBS; CPPFLAGS=$save_$2_CPPFLAGS]], [$7])
])
dnl FORK_ARG_WITH_CHECK(TARGET, DESCRIPTION, OPTION, ENV, MODULES, [FUNCTION],
dnl [HEADER], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl --------------------------------------------------------------------------
dnl Create an --with-OPTION with a default of "check" (include MODULES
dnl if they are available). Expands FORK_MODULES_CHECK with remaining
dnl arguments. Defines HAVE_ENV to 1 if package found. DESCRIPTION is used
dnl in option help. Shell variable with_OPTION set to yes before
dnl ACTION-IF-FOUND. Default ACTION-IF-NOT-FOUND will fail
dnl if --with-OPTION given, and MODULES not found, or sets shell var
dnl with_OPTION to no (setting NOT-FOUND overrides this behavior to allow
dnl alternate checks).
AC_DEFUN([FORK_ARG_WITH_CHECK],
[AC_ARG_WITH([[$3]], [AS_HELP_STRING([--with-$3],
[with $2 (default=check)])], [],
[[with_$3=check]])
AS_IF([[test "x$with_$3" != "xno"]],
[FORK_MODULES_CHECK([$1], [$4], [$5], [$6], [$7],
[[with_$3=yes]
AC_DEFINE([HAVE_$4], 1,
[Define to 1 to build with $2])
$8],
[m4_default([$9], [AS_IF([[test "x$with_$3" != "xcheck"]],
[AC_MSG_FAILURE([[--with-$3 was given, but test for $5 failed]])])
[with_$3=no]])])dnl keep default empty!
])
])
dnl FORK_ARG_ENABLE(DESCRIPTION, OPTION, DEFINE, [ACTION-IF-ENABLE])
dnl ----------------------------------------------------------------
dnl Create an --enable-OPTION, setting shell variable enable_OPTION
dnl to no by default. If feature is enabled, defines DEFINE to 1
dnl and expand ACTION-IF_ENABLE. DESCRIPTION is used in option help.
AC_DEFUN([FORK_ARG_ENABLE],
[AC_ARG_ENABLE([[$2]], [AS_HELP_STRING([--enable-$2],
[enable $1 (default=no)])])
AS_IF([[test "x$enable_$2" = "xyes"]],
[AC_DEFINE([$3], 1, [Define to 1 to enable $1])
$4],
[[enable_$2=no]])
])
dnl FORK_ARG_DISABLE(DESCRIPTION, OPTION, DEFINE, [ACTION-IF-ENABLE])
dnl ----------------------------------------------------------------
dnl Create an --disable-OPTION, setting shell variable enable_OPTION
dnl to yes by default. If feature is enabled, defines DEFINE to 1
dnl and expand ACTION-IF_ENABLE. DESCRIPTION is used in option help.
AC_DEFUN([FORK_ARG_DISABLE],
[AC_ARG_ENABLE([[$2]], [AS_HELP_STRING([--disable-$2],
[disable $1 (default=no)])])
AS_IF([[test "x$enable_$2" = "x" || test "x$enable_$2" = "xyes"]],
[AC_DEFINE([$3], 1, [Define to 1 to enable $1])
[enable_$2=yes]
$4],
[[enable_$2=no]])
])

View File

@@ -1,150 +0,0 @@
# libunistring.m4 serial 11
dnl Copyright (C) 2009-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl gl_LIBUNISTRING
dnl Searches for an installed libunistring.
dnl If found, it sets and AC_SUBSTs HAVE_LIBUNISTRING=yes and the LIBUNISTRING
dnl and LTLIBUNISTRING variables, sets the LIBUNISTRING_VERSION variable, and
dnl augments the CPPFLAGS variable, and #defines HAVE_LIBUNISTRING to 1.
dnl Otherwise, it sets and AC_SUBSTs HAVE_LIBUNISTRING=no and LIBUNISTRING and
dnl LTLIBUNISTRING to empty.
dnl Define gl_LIBUNISTRING using AC_DEFUN_ONCE for Autoconf >= 2.64, in order
dnl to avoid warnings like
dnl "warning: AC_REQUIRE: `gl_LIBUNISTRING' was expanded before it was required".
dnl This is tricky because of the way 'aclocal' is implemented:
dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
dnl Otherwise aclocal's initial scan pass would miss the macro definition.
dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
dnl warnings.
m4_define([gl_libunistring_AC_DEFUN],
m4_version_prereq([2.64],
[[AC_DEFUN_ONCE(
[$1], [$2])]],
[m4_ifdef([gl_00GNULIB],
[[AC_DEFUN_ONCE(
[$1], [$2])]],
[[AC_DEFUN(
[$1], [$2])]])]))
gl_libunistring_AC_DEFUN([gl_LIBUNISTRING],
[
AC_BEFORE([$0], [gl_LIBUNISTRING_MODULE])
AC_BEFORE([$0], [gl_LIBUNISTRING_LIBHEADER])
AC_BEFORE([$0], [gl_LIBUNISTRING_LIB_PREPARE])
m4_ifdef([gl_LIBUNISTRING_OPTIONAL],
[
AC_MSG_CHECKING([whether included libunistring is requested])
AC_ARG_WITH([included-libunistring],
[ --with-included-libunistring use the libunistring parts included here],
[gl_libunistring_force_included=$withval],
[gl_libunistring_force_included=no])
AC_MSG_RESULT([$gl_libunistring_force_included])
gl_libunistring_use_included="$gl_libunistring_force_included"
if test "$gl_libunistring_use_included" = yes; then
dnl Assume that libunistring is not installed until some other macro
dnl explicitly invokes gl_LIBUNISTRING_CORE.
if test -z "$HAVE_LIBUNISTRING"; then
HAVE_LIBUNISTRING=no
fi
LIBUNISTRING=
LTLIBUNISTRING=
else
gl_LIBUNISTRING_CORE
if test $HAVE_LIBUNISTRING = no; then
gl_libunistring_use_included=yes
LIBUNISTRING=
LTLIBUNISTRING=
fi
fi
],
[gl_LIBUNISTRING_CORE])
])
AC_DEFUN([gl_LIBUNISTRING_CORE],
[
AC_REQUIRE([AM_ICONV])
if test -n "$LIBICONV"; then
dnl First, try to link without -liconv. libunistring often depends on
dnl libiconv, but we don't know (and often don't need to know) where
dnl libiconv is installed.
AC_LIB_HAVE_LINKFLAGS([unistring], [],
[#include <uniconv.h>], [u8_strconv_from_locale((char*)0);],
[no, trying again together with libiconv])
if test "$ac_cv_libunistring" != yes; then
dnl Second try, with -liconv.
dnl We have to erase the cached result of the first AC_LIB_HAVE_LINKFLAGS
dnl invocation, otherwise the second one will not be run.
unset ac_cv_libunistring
glus_save_LIBS="$LIBS"
LIBS="$LIBS $LIBICONV"
AC_LIB_HAVE_LINKFLAGS([unistring], [],
[#include <uniconv.h>], [u8_strconv_from_locale((char*)0);],
[no, consider installing GNU libunistring])
if test -n "$LIBUNISTRING"; then
LIBUNISTRING="$LIBUNISTRING $LIBICONV"
LTLIBUNISTRING="$LTLIBUNISTRING $LTLIBICONV"
fi
LIBS="$glus_save_LIBS"
fi
else
AC_LIB_HAVE_LINKFLAGS([unistring], [],
[#include <uniconv.h>], [u8_strconv_from_locale((char*)0);],
[no, consider installing GNU libunistring])
fi
if test $HAVE_LIBUNISTRING = yes; then
dnl Determine the installed version.
AC_CACHE_CHECK([for libunistring version], [gl_cv_libunistring_version],
[AC_COMPUTE_INT([gl_libunistring_hexversion],
[_LIBUNISTRING_VERSION],
[#include <unistring/version.h>])
dnl Versions <= 0.9.3 had a hexversion of 0x0009.
dnl Use other tests to distinguish them.
if test $gl_libunistring_hexversion = 9; then
dnl Version 0.9.2 introduced the header <unistring/cdefs.h>.
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <unistring/cdefs.h>]], [[]])],
[gl_cv_libunistring_version092=true],
[gl_cv_libunistring_version092=false])
if $gl_cv_libunistring_version092; then
dnl Version 0.9.3 changed a comment in <unistr.h>.
gl_ABSOLUTE_HEADER_ONE([unistr.h])
if test -n "$gl_cv_absolute_unistr_h" \
&& grep 'Copy no more than N units of SRC to DEST. Return a pointer' $gl_cv_absolute_unistr_h > /dev/null; then
dnl Detected version 0.9.3.
gl_libunistring_hexversion=2307
else
dnl Detected version 0.9.2.
gl_libunistring_hexversion=2306
fi
else
dnl Version 0.9.1 introduced the type casing_suffix_context_t.
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <unicase.h>
casing_suffix_context_t ct;]],
[[]])],
[gl_cv_libunistring_version091=true],
[gl_cv_libunistring_version091=false])
if $gl_cv_libunistring_version091; then
dnl Detected version 0.9.1.
gl_libunistring_hexversion=2305
else
dnl Detected version 0.9.
gl_libunistring_hexversion=2304
fi
fi
fi
dnl Transform into the usual major.minor.subminor notation.
gl_libunistring_major=`expr $gl_libunistring_hexversion / 65536`
gl_libunistring_minor=`expr $gl_libunistring_hexversion / 256 % 256`
gl_libunistring_subminor=`expr $gl_libunistring_hexversion % 256`
gl_cv_libunistring_version="$gl_libunistring_major.$gl_libunistring_minor.$gl_libunistring_subminor"
])
LIBUNISTRING_VERSION="$gl_cv_libunistring_version"
fi
])