From 2bd0b84f18c935e9d66be545049686ab7646cb9a Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 3 Jun 2016 13:37:15 +0200 Subject: build-sys: add UL_REQUIRES_COMPILE macro Signed-off-by: Karel Zak --- m4/ul.m4 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'm4') diff --git a/m4/ul.m4 b/m4/ul.m4 index dd932e31f..6c439511d 100644 --- a/m4/ul.m4 +++ b/m4/ul.m4 @@ -248,6 +248,43 @@ AC_DEFUN([UL_REQUIRES_HAVE], [ fi ]) +dnl UL_REQUIRES_HAVE(NAME, PROGRAM_PROLOGUE, PROGRAM_BODY, DESC, [VARSUFFIX=$1]) +dnl +dnl Modifies $build_ variable according to $enable_ and +dnl ability compile AC_LANG_PROGRAM(, ). +dnl +dnl The is description used for warning/error dnl message (e.g. "foo support"). +dnl +dnl The default for $build_ and $enable_ could be overwrited by option $5. + +AC_DEFUN([UL_REQUIRES_COMPILE], [ + m4_define([suffix], m4_default([$5],$1)) + + if test "x$[build_]suffix" != xno; then + + AC_MSG_CHECKING([$4]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$2], [$3])], + [AC_MSG_RESULT([yes]) + [ul_haveprogram_]suffix=yes], + [AC_MSG_RESULT([no]) + [ul_haveprogram_]suffix=no]) + + case $[enable_]suffix:$[ul_haveprogram_]suffix in #( + no:*) + [build_]suffix=no ;; + yes:yes) + [build_]suffix=yes ;; + yes:*) + AC_MSG_ERROR([$1 selected, but required $4 not available]);; + check:yes) + [build_]suffix=yes ;; + check:*) + AC_MSG_WARN([$4 not found; not building $1]) + [build_]suffix=no ;; + esac + fi +]) + dnl dnl UL_CONFLICTS_BUILD(NAME, ANOTHER, ANOTHERDESC, [VARSUFFIX=$1]) dnl -- cgit v1.2.3-55-g7522