Skip to content

Commit 1a1631f

Browse files
committed
curses: ncurses may define curs_set outside of curses
This is a very poor design decision that sadly we need to work around. There is no technical reason why all curses functions are not defined in libcurses. Thanks to Lars Wendler <polynomial-c@gentoo.org> for the initial patch.
1 parent 216835c commit 1a1631f

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

configure

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,39 @@ int main(void) {
462462
EOF
463463
if $XCC _curses.c -o _curses -lcurses 2>&3; then
464464
LIB_CURSES=-lcurses
465+
echo "$LIB_CURSES"
465466
fi
466467
rm -f _curses.c _curses
467468
fi
469+
470+
# ncurses may have curs_set in libtinfo and not libcurses.
471+
# This is a very poor design as other curses implementations
472+
# do not have this limitation.
473+
if [ -n "$LIB_CURSES" ]; then
474+
printf "Testing for curs_set in $LIB_CURSES ... "
475+
cat <<EOF >_curses.c
476+
#include <curses.h>
477+
int main(void) {
478+
curs_set(1);
479+
return 0;
480+
}
481+
EOF
482+
if $XCC _curses.c -o _curses $LIB_CURSES 2>&3; then
483+
echo "yes"
484+
else
485+
if $XCC _curses.c -o _curses $LIB_CURSES -ltinfo 2>&3; then
486+
echo "no (libtinfo)"
487+
LIB_CURSES="$LIB_CURSES -ltinfo"
488+
else
489+
echo "no and not found"
490+
[ "$WITH_CURSES" = yes ] && exit 1
491+
LIB_CURSES=
492+
fi
493+
fi
494+
rm -f _curses.c _curses
495+
fi
496+
468497
if [ -n "$LIB_CURSES" ]; then
469-
echo "$LIB_CURSES"
470498
echo "LIB_CURSES= $LIB_CURSES" >>$CONFIG_MK
471499
UI="dhcpcd-curses${UI:+ }$UI"
472500

0 commit comments

Comments
 (0)