1 From 862326451184bb0fe9c2b2b110fcfc986f9b1734 Mon Sep 17 00:00:00 2001
2 From: Karel Zak <kzak@redhat.com>
3 Date: Tue, 13 Dec 2016 12:41:18 +0100
4 Subject: [PATCH] build-sys: cleanup UL_NCURSES_CHECK
6 * use SUFFIX for upper-case suffix
7 * use AC_CHECK_TOOL() to search for ncurses-config (thanks to Mike Frysinger)
8 * separate checks by AS_IF()
10 Signed-off-by: Karel Zak <kzak@redhat.com>
12 m4/ul.m4 | 54 +++++++++++++++++++++++++++++++++---------------------
13 1 file changed, 33 insertions(+), 21 deletions(-)
15 diff --git a/m4/ul.m4 b/m4/ul.m4
16 index 44c721e..f8a0dd7 100644
19 @@ -438,36 +438,48 @@ dnl The expected <name> is ncurses or ncursesw.
21 AC_DEFUN([UL_NCURSES_CHECK], [
22 m4_define([suffix], $1)
23 - m4_define([suffixup], m4_toupper($1))
24 + m4_define([SUFFIX], m4_toupper($1))
27 - PKG_CHECK_MODULES(suffixup, [$1], [
28 + # pkg-config (not supported by ncurses upstream by default)
30 + PKG_CHECK_MODULES(SUFFIX, [$1], [
32 - NCURSES_LIBS=${suffixup[]_LIBS}
33 - NCURSES_CFLAGS=${suffixup[]_CFLAGS}
34 + NCURSES_LIBS=${SUFFIX[]_LIBS}
35 + NCURSES_CFLAGS=${SUFFIX[]_CFLAGS}
38 - # ncurses-config should be everywhere, pkg-config is not supported by default
39 - # by ncurses upstream
42 AS_IF([test "x$have_[]suffix" = xno], [
43 - AC_MSG_CHECKING([$1 config])
44 - if AC_RUN_LOG([suffix[]6-config --version >/dev/null]); then
45 + AC_CHECK_TOOL(SUFFIX[]6_CONFIG, suffix[]6-config)
46 + if AC_RUN_LOG([$SUFFIX[]6_CONFIG --version >/dev/null]); then
48 - NCURSES_LIBS=`suffix[]6-config --libs`
49 - NCURSES_CFLAGS=`suffix[]6-config --cflags`
50 - AC_MSG_RESULT([(v6) yes])
51 - elif AC_RUN_LOG([suffix[]5-config --version >/dev/null]); then
52 + NCURSES_LIBS=`$SUFFIX[]6_CONFIG --libs`
53 + NCURSES_CFLAGS=`$SUFFIX[]6_CONFIG --cflags`
61 + AS_IF([test "x$have_[]suffix" = xno], [
62 + AC_CHECK_TOOL(SUFFIX[]5_CONFIG, suffix[]5-config)
63 + if AC_RUN_LOG([$SUFFIX[]5_CONFIG --version >/dev/null]); then
65 - NCURSES_LIBS=`suffix[]5-config --libs`
66 - NCURSES_CFLAGS=`suffix[]5-config --cflags`
67 - AC_MSG_RESULT([(v5) yes])
68 + NCURSES_LIBS=`$SUFFIX[]5_CONFIG --libs`
69 + NCURSES_CFLAGS=`$SUFFIX[]5_CONFIG --cflags`
72 - AS_IF([test "x$have_[]suffix" = xno], [
73 - AC_CHECK_LIB([$1], [initscr], [have_[]suffix=yes], [have_[]suffix=no])
74 - AS_IF([test "x$have_[]suffix" = xyes], [NCURSES_LIBS="-l[]suffix"])
80 + # classic autoconf way
82 + AS_IF([test "x$have_[]suffix" = xno], [
83 + AS_IF([test "x$have_[]suffix" = xno], [
84 + AC_CHECK_LIB([$1], [initscr], [have_[]suffix=yes], [have_[]suffix=no])
85 + AS_IF([test "x$have_[]suffix" = xyes], [NCURSES_LIBS="-l[]suffix"])