summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2024-08-21 19:56:21 +0800
committerBenBE <BenBE@geshi.org>2024-09-20 22:28:59 +0200
commitd5f24d20d85443561fdab93c87a1a214dcb9e833 (patch)
tree4a6b600ee8b1178ad3fb99dc92033ede85b24795
parent5d1948b8d2dc96a412d2c211a987fe04bbbd692b (diff)
build: Improve "-ltinfo" detection in configure
Since "-lncurses" might require explicit "-ltinfo" flag to link (especially for static libncurses without libtool or pkg-config), "-ltinfo" needs to be checked alongside "-lncurses" and not after it. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
-rw-r--r--configure.ac52
1 files changed, 36 insertions, 16 deletions
diff --git a/configure.ac b/configure.ac
index 4671b4c8..80eb9bf2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -450,20 +450,39 @@ htop_check_curses_capability () {
# At this point we have not checked the name of curses header, so
# use forward declaration for the linking tests below.
- # htop calls refresh(), which might be implemented as a macro.
- # It is more reliable to test linking with doupdate(), which
- # refresh() would call internally.
- AC_MSG_CHECKING([for doupdate in $htop_msg_linker_flags])
+ # htop uses keypad() and "stdscr", but for ncurses implementation,
+ # the symbols are in "-ltinfo" and not "-lncurses".
+ # Check "-ltinfo" symbols first, as libncurses might require
+ # explicit "-ltinfo" to link (for internal dependency).
+ AC_MSG_CHECKING([for keypad in $htop_msg_linker_flags])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-int doupdate(void);
+/* extern WINDOW* stdscr; */
+/* int keypad(WINDOW* win, bool enable); */
+extern void* stdscr;
+int keypad(void* win, int enable);
]], [[
-doupdate();
+keypad(stdscr, 0);
]])],
- [AC_MSG_RESULT(yes)
- htop_curses_capability=nonwide],
+ [AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
htop_curses_status=1])
+ # htop calls refresh(), which might be implemented as a macro.
+ # It is more reliable to test linking with doupdate(), which
+ # refresh() would call internally.
+ if test "$htop_curses_status" -eq 0; then
+ AC_MSG_CHECKING([for doupdate in $htop_msg_linker_flags])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+int doupdate(void);
+ ]], [[
+doupdate();
+ ]])],
+ [AC_MSG_RESULT(yes)
+ htop_curses_capability=nonwide],
+ [AC_MSG_RESULT(no)
+ htop_curses_status=1])
+ fi
+
if test "x$htop_curses_status$enable_unicode" = x0yes; then
AC_MSG_CHECKING([for mvadd_wchnstr in $htop_msg_linker_flags])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@@ -553,6 +572,15 @@ none-*|nonwide-yes)
if htop_check_curses_capability "" "-l$curses_name"; then
break
fi
+ # For ncurses implementation, an extra "-ltinfo" or "-ltinfow"
+ # flag might be needed to link.
+ if test "x$enable_unicode" = xyes &&
+ htop_check_curses_capability "" "-l$curses_name -ltinfow"; then
+ break
+ fi
+ if htop_check_curses_capability "" "-l$curses_name -ltinfo"; then
+ break
+ fi
done
;;
esac
@@ -579,10 +607,6 @@ if test "x$enable_unicode" = xyes; then
[AC_CHECK_HEADERS([ncurses/term.h], [],
[AC_CHECK_HEADERS([term.h], [],
[AC_MSG_ERROR([can not find required term header file])])])])
-
- # check if additional linker flags are needed for keypad(3)
- # (at this point we already link against a working ncurses library with wide character support)
- AC_SEARCH_LIBS([keypad], [tinfow tinfo])
else
AC_CHECK_HEADERS([curses.h], [],
[AC_CHECK_HEADERS([ncurses/curses.h], [],
@@ -593,10 +617,6 @@ else
AC_CHECK_HEADERS([ncurses/term.h], [],
[AC_CHECK_HEADERS([term.h], [],
[AC_MSG_ERROR([can not find required term header file])])])
-
- # check if additional linker flags are needed for keypad(3)
- # (at this point we already link against a working ncurses library)
- AC_SEARCH_LIBS([keypad], [tinfo])
fi
CFLAGS=$htop_save_CFLAGS