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 <csmall@dropbear.xyz>
This commit is contained in:
Craig Small 2022-05-21 11:06:57 +10:00
parent f080820931
commit 8128641814
2 changed files with 36 additions and 23 deletions

View File

@ -178,7 +178,7 @@ slabtop_SOURCES = slabtop.c lib/strutils.c lib/fileutils.c
slabtop_LDADD = $(LDADD) @NCURSES_LIBS@
endif
watch_SOURCES = watch.c lib/strutils.c lib/fileutils.c
watch_LDADD = @WATCH_NCURSES_LIBS@ $(CYGWINFLAGS)
watch_LDADD = @NCURSES_LIBS@ $(CYGWINFLAGS)
top_top_SOURCES = \
top/top.h \
top/top.c \

View File

@ -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])],