From 4138c5763121a96d20847f98bce27a12acc85df7 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 22 May 2021 16:39:08 +0200 Subject: [PATCH] Configure: Rewrite the macro for checking Xft2 version The original macro used over-complicated things, like: - useless uses of 'eval', - split AC_CACHE_CHECK construct (AC_MSG_CHECKING + AC_CACHE_VAL + AC_MSG_RESULT) - dubious variable name (CPPFLAGS_old, which is not the "old" value but the "saved" value for a temporary change) - variable CPPFLAGS was changed at wrong hierarchy level - calculate the integer value for XFT_VERSION in m4 instead generating shell commands that had to do it on user side - indentation was missing Signed-off-by: Christophe CURIS --- m4/windowmaker.m4 | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/m4/windowmaker.m4 b/m4/windowmaker.m4 index bdae9c6a..685bf382 100644 --- a/m4/windowmaker.m4 +++ b/m4/windowmaker.m4 @@ -30,33 +30,23 @@ m4_pattern_allow([^WM_OSDEP(_[A-Z]*)?$]) # else it will not be able to find Xft.h # AC_DEFUN([WM_CHECK_XFT_VERSION], -[ -CPPFLAGS_old="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS $XFT_CFLAGS $inc_search_path" -xft_major_version=`echo $1 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` -xft_minor_version=`echo $1 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` -xft_micro_version=`echo $1 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` -AC_MSG_CHECKING([whether libXft is at least version $1]) -AC_CACHE_VAL(ac_cv_lib_xft_version_ok, -[AC_TRY_LINK( -[/* Test version of libXft we have */ +[m4_define([XFT_REQUIRED_VERSION], + m4_eval(m4_bregexp($1, [^\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)], + [\1 * 10000 + \2 * 100 + \3]) ) )dnl + AC_CACHE_CHECK([whether libXft is at least version $1], [ac_cv_lib_xft_version_ok], + [CPPFLAGS_save="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $XFT_CFLAGS $inc_search_path" + AC_TRY_LINK([ #include #include - -#if !defined(XFT_VERSION) || XFT_VERSION < $xft_major_version*10000 + $xft_minor_version*100 + $xft_micro_version +], [ +#if !defined(XFT_VERSION) || XFT_VERSION < ]XFT_REQUIRED_VERSION[ #error libXft on this system is too old. Consider upgrading to at least $1 #endif -], [], -eval "ac_cv_lib_xft_version_ok=yes", -eval "ac_cv_lib_xft_version_ok=no")]) -if eval "test \"`echo '$ac_cv_lib_xft_version_ok'`\" = yes"; then - AC_MSG_RESULT(yes) - ifelse([$2], , :, [$2]) -else - AC_MSG_RESULT(no) - ifelse([$3], , , [$3]) -fi -CPPFLAGS="$CPPFLAGS_old" +], [ac_cv_lib_xft_version_ok=yes], [ac_cv_lib_xft_version_ok=no]) + CPPFLAGS="$CPPFLAGS_save"]) + m4_undefine([XFT_REQUIRED_VERSION])dnl + AS_IF([test "x$ac_cv_lib_xft_version_ok" != "xyes"], [$3], [$2])dnl ])