@@ -450,20 +450,39 @@ htop_check_curses_capability () {
450450 # At this point we have not checked the name of curses header, so
451451 # use forward declaration for the linking tests below.
452452
453- # htop calls refresh(), which might be implemented as a macro.
454- # It is more reliable to test linking with doupdate(), which
455- # refresh() would call internally.
456- AC_MSG_CHECKING ( [ for doupdate in $htop_msg_linker_flags] )
453+ # htop uses keypad() and "stdscr", but for ncurses implementation,
454+ # the symbols are in "-ltinfo" and not "-lncurses".
455+ # Check "-ltinfo" symbols first, as libncurses might require
456+ # explicit "-ltinfo" to link (for internal dependency).
457+ AC_MSG_CHECKING ( [ for keypad in $htop_msg_linker_flags] )
457458 AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [
458- int doupdate(void);
459+ /* extern WINDOW* stdscr; */
460+ /* int keypad(WINDOW* win, bool enable); */
461+ extern void* stdscr;
462+ int keypad(void* win, int enable);
459463 ] ] , [ [
460- doupdate( );
464+ keypad(stdscr, 0 );
461465 ] ] ) ] ,
462- [ AC_MSG_RESULT ( yes )
463- htop_curses_capability=nonwide] ,
466+ [ AC_MSG_RESULT ( yes ) ] ,
464467 [ AC_MSG_RESULT ( no )
465468 htop_curses_status=1] )
466469
470+ # htop calls refresh(), which might be implemented as a macro.
471+ # It is more reliable to test linking with doupdate(), which
472+ # refresh() would call internally.
473+ if test "$htop_curses_status" -eq 0; then
474+ AC_MSG_CHECKING ( [ for doupdate in $htop_msg_linker_flags] )
475+ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [
476+ int doupdate(void);
477+ ] ] , [ [
478+ doupdate();
479+ ] ] ) ] ,
480+ [ AC_MSG_RESULT ( yes )
481+ htop_curses_capability=nonwide] ,
482+ [ AC_MSG_RESULT ( no )
483+ htop_curses_status=1] )
484+ fi
485+
467486 if test "x$htop_curses_status$enable_unicode" = x0yes; then
468487 AC_MSG_CHECKING ( [ for mvadd_wchnstr in $htop_msg_linker_flags] )
469488 AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [
@@ -553,6 +572,15 @@ none-*|nonwide-yes)
553572 if htop_check_curses_capability "" "-l$curses_name"; then
554573 break
555574 fi
575+ # For ncurses implementation, an extra "-ltinfo" or "-ltinfow"
576+ # flag might be needed to link.
577+ if test "x$enable_unicode" = xyes &&
578+ htop_check_curses_capability "" "-l$curses_name -ltinfow"; then
579+ break
580+ fi
581+ if htop_check_curses_capability "" "-l$curses_name -ltinfo"; then
582+ break
583+ fi
556584 done
557585 ;;
558586esac
@@ -579,10 +607,6 @@ if test "x$enable_unicode" = xyes; then
579607 [ AC_CHECK_HEADERS ( [ ncurses/term.h] , [ ] ,
580608 [ AC_CHECK_HEADERS ( [ term.h] , [ ] ,
581609 [ AC_MSG_ERROR ( [ can not find required term header file] ) ] ) ] ) ] )
582-
583- # check if additional linker flags are needed for keypad(3)
584- # (at this point we already link against a working ncurses library with wide character support)
585- AC_SEARCH_LIBS ( [ keypad] , [ tinfow tinfo] )
586610else
587611 AC_CHECK_HEADERS ( [ curses.h] , [ ] ,
588612 [ AC_CHECK_HEADERS ( [ ncurses/curses.h] , [ ] ,
@@ -593,10 +617,6 @@ else
593617 AC_CHECK_HEADERS ( [ ncurses/term.h] , [ ] ,
594618 [ AC_CHECK_HEADERS ( [ term.h] , [ ] ,
595619 [ AC_MSG_ERROR ( [ can not find required term header file] ) ] ) ] )
596-
597- # check if additional linker flags are needed for keypad(3)
598- # (at this point we already link against a working ncurses library)
599- AC_SEARCH_LIBS ( [ keypad] , [ tinfo] )
600620fi
601621CFLAGS=$htop_save_CFLAGS
602622
0 commit comments