From 97a61921e379924bd81fa07424cf4de48d0d1b72 Mon Sep 17 00:00:00 2001
From: Evgeny Grin <k2k@narod.ru>
Date: Fri, 19 May 2023 20:27:04 +0300
Subject: [PATCH] configure: fix duplication of ncurses in MCLIBS
AC_SEARCH_LIBS macro adds required library to 'LIBS' variable.
Currently 'LIBS' could be appended to 'MCLIBS' several times leading to
duplication of found values.
Also fixed duplication for 'stdscr' function detection.
Additionally fixed potential problematic situation when 'addwstr' or
'has_colors' detected in one ncurses library (for example 'ncurses'),
while 'stdscr' detected in other ncurses library (for example 'curses').
Such combination leads to problems.
Signed-off-by: Karlson2k (Evgeny Grin) <k2k@narod.ru>
---
m4.include/mc-with-screen-ncurses.m4 | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/m4.include/mc-with-screen-ncurses.m4 b/m4.include/mc-with-screen-ncurses.m4
index 80d8478c9..d4b4ada43 100644
a
|
b
|
AC_DEFUN([mc_WITH_NCURSES], [ |
98 | 98 | dnl check the user supplied location |
99 | 99 | mc_CHECK_NCURSES_BY_PATH([$ac_ncurses_inc_path],[$ac_ncurses_lib_path]) |
100 | 100 | |
101 | | LIBS= |
102 | | AC_SEARCH_LIBS([has_colors], [ncurses], [MCLIBS="$MCLIBS $LIBS"], |
| 101 | LIBS="$MCLIBS" |
| 102 | AC_SEARCH_LIBS([has_colors], [ncurses], [], |
103 | 103 | [AC_MSG_ERROR([Cannot find ncurses library])]) |
104 | | AC_SEARCH_LIBS([stdscr], [tinfo ncurses], [MCLIBS="$MCLIBS $LIBS"], |
| 104 | AC_SEARCH_LIBS([stdscr], [tinfo], [], |
105 | 105 | [AC_MSG_ERROR([Cannot find a library providing stdscr])]) |
106 | | |
| 106 | MCLIBS="$LIBS" |
107 | 107 | |
108 | 108 | screen_type=ncurses |
109 | 109 | screen_msg="NCurses" |
110 | 110 | AC_DEFINE(USE_NCURSES, 1, |
111 | 111 | [Define to use ncurses for screen management]) |
112 | 112 | else |
113 | | LIBS= |
114 | | AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes], |
| 113 | LIBS="$MCLIBS" |
| 114 | AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [ncursesw_found=yes], |
115 | 115 | [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])]) |
116 | | |
117 | | AC_SEARCH_LIBS([stdscr], [tinfow tinfo ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS"], |
118 | | [AC_MSG_ERROR([Cannot find a library providing stdscr])]) |
| 116 | MCLIBS="$LIBS" |
119 | 117 | |
120 | 118 | if test x"$ncursesw_found" = "x"; then |
121 | | LIBS= |
122 | | AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"], |
| 119 | LIBS="$MCLIBS" |
| 120 | AC_SEARCH_LIBS([has_colors], [ncurses curses], [], |
123 | 121 | [AC_MSG_ERROR([Cannot find ncurses library])]) |
124 | | AC_SEARCH_LIBS([stdscr], [tinfo ncurses curses], [MCLIBS="$MCLIBS $LIBS"], |
125 | | [AC_MSG_ERROR([Cannot find a library providing stdscr])]) |
| 122 | MCLIBS="$LIBS" |
126 | 123 | fi |
| 124 | LIBS="$MCLIBS" |
| 125 | AC_SEARCH_LIBS([stdscr], [tinfow tinfo], [MCLIBS="$MCLIBS $LIBS"], |
| 126 | [AC_MSG_ERROR([Cannot find a library providing stdscr])]) |
| 127 | MCLIBS="$LIBS" |
127 | 128 | |
128 | 129 | dnl Check the header |
129 | 130 | ncurses_h_found= |