From 812864181408398af98b217f384205a6f2f9cb68 Mon Sep 17 00:00:00 2001 From: Craig Small Date: Sat, 21 May 2022 11:06:57 +1000 Subject: build-sys: Use ncursesw by default The existing build system would only require wide ncurses for a wide watch and even if the library was there would not link anything else to it. The first issue which #123 made me think of, is if ncursesw was there and ncurses is not, why not use ncursesw? A more major issue is if programs such as slabtop are linked to ncurses, then certain languages will display their text wrong, as found in #237. The days of assuming ASCII only is ok are over the build system now does the following: 1. If ncursesw is available use this for all relevant programs 2. If ncursesw is not but ncurses is, use this instead 3. If you enable 8bit watch and either disable ncurses or we cannot find ncursesw error at configure time. In related news, I hate M4sh. References: procps-ng/procps#123 procps-ng/procps#237 Signed-off-by: Craig Small --- configure.ac | 57 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 22 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index a510b8a..8c6c338 100644 --- a/configure.ac +++ b/configure.ac @@ -212,34 +212,47 @@ AC_SUBST([HARDEN_LDFLAGS]) # Optional packages - AC_ARG_WITH AC_ARG_WITH([ncurses], AS_HELP_STRING([--without-ncurses], [build only applications not needing ncurses]), - [], [with_ncurses=yes] + [AS_IF([test "x$enable_watch8bit" = "xyes"], + [AC_MSG_ERROR([Cannot have both --enable-watch8bit and --without-ncurses])] + )], + [with_ncurses=yes] ) if test "x$with_ncurses" = xno; then AM_CONDITIONAL(WITH_NCURSES, false) else - PKG_CHECK_MODULES([NCURSES], [ncurses], [], [ - AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no]) - AC_CHECK_HEADERS(curses.h ncurses.h term.h, [], [have_ncurses=no], AC_INCLUDES_DEFAULT) - if test "x$have_ncurses" = xno; then - AC_MSG_ERROR([ncurses support missing/incomplete (for partial build use --without-ncurses)]) - fi - NCURSES_LIBS="-lncurses" - ]) AM_CONDITIONAL(WITH_NCURSES, true) - if test "$enable_watch8bit" = yes; then - PKG_CHECK_MODULES([NCURSESW], [ncursesw], [WATCH_NCURSES_LIBS="$NCURSESW_LIBS"], [ - AC_CHECK_LIB([ncursesw], [addwstr], [WATCH_NCURSES_LIBS=-lncursesw], [ - AC_CHECK_LIB([ncurses], [addwstr], [WATCH_NCURSES_LIBS=-lncurses], [ - AC_MSG_ERROR([Cannot find ncurses wide library ncursesw with --enable-watch8bit]) - ]) - ]) - ]) - else - WATCH_NCURSES_LIBS="$NCURSES_LIBS" - fi + PKG_CHECK_MODULES([NCURSES], [ncursesw], + [AC_DEFINE([HAVE_NCURSES], [1], [Use NCURSESW])], + [ + AS_IF([test "x$enable_watch8bit" = "xyes"], + [AC_MSG_ERROR([Cannot find ncurses wide library ncursesw with --enable-watch8bit])]) + PKG_CHECK_MODULES([NCURSES], [ncurses], + [AC_DEFINE([HAVE_NCURSES], [1], [Use NCURSES])], + [AC_MSG_ERROR([ncurses support missing/incomplete (for partial build use --without-ncurses)])] + ) + ] + ) fi -AC_SUBST([NCURSES_LIBS]) -AC_SUBST([WATCH_NCURSES_LIBS]) +# PKG_CHECK_MODULES([NCURSES], [ncurses], [], [ +# AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no]) +# AC_CHECK_HEADERS(curses.h ncurses.h term.h, [], [have_ncurses=no], AC_INCLUDES_DEFAULT) +# if test "x$have_ncurses" = xno; then +# AC_MSG_ERROR([ncurses support missing/incomplete (for partial build use --without-ncurses)]) +# fi +# NCURSES_LIBS="-lncurses" +# ]) +# AM_CONDITIONAL(WITH_NCURSES, true) +# if test "$enable_watch8bit" = yes; then +# PKG_CHECK_MODULES([NCURSESW], [ncursesw], [WATCH_NCURSES_LIBS="$NCURSESW_LIBS"], [ +# AC_CHECK_LIB([ncursesw], [addwstr], [WATCH_NCURSES_LIBS=-lncursesw], [ +# AC_CHECK_LIB([ncurses], [addwstr], [WATCH_NCURSES_LIBS=-lncurses], [ +# AC_MSG_ERROR([Cannot find ncurses wide library ncursesw with --enable-watch8bit]) +# ]) +# ]) +# ]) +# else +# WATCH_NCURSES_LIBS="$NCURSES_LIBS" +# fi AC_ARG_WITH([systemd], [AS_HELP_STRING([--with-systemd], [enable systemd support])], -- cgit v1.2.1