kconfig: use pkg-config for ncurses detection master origin/master current
authorBarret Rhoden <brho@cs.berkeley.edu>
Sun, 17 Nov 2019 18:13:00 +0000 (13:13 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Sun, 17 Nov 2019 18:13:00 +0000 (13:13 -0500)
From Linux commits be8af2d54a66 ("kconfig/lxdialog: get ncurses CFLAGS
with pkg-config") and 7285996aa000 ("kconfig: nconfig: fix multi-byte
UTF handling").

Our Kconfig was built off of Linux's back in 2013, and it's showing its
age with more recent toolchains and libraries.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
scripts/kconfig/Makefile
scripts/kconfig/lxdialog/check-lxdialog.sh

index 3091794..72f03d7 100644 (file)
@@ -216,7 +216,11 @@ HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
 
 HOSTLOADLIBES_mconf   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
 
-HOSTLOADLIBES_nconf    = -lmenu -lpanel -lncurses
+HOSTLOADLIBES_nconf     = $(shell \
+                                pkg-config --libs menuw panelw ncursesw 2>/dev/null \
+                                || pkg-config --libs menu panel ncurses 2>/dev/null \
+                                || echo "-lmenu -lpanel -lncurses"  )
+
 $(obj)/qconf.o: $(obj)/.tmp_qtcheck
 
 ifeq ($(qconf-target),1)
index c8e8a71..5075ebf 100644 (file)
@@ -4,6 +4,8 @@
 # What library to link
 ldflags()
 {
+       pkg-config --libs ncursesw 2>/dev/null && exit
+       pkg-config --libs ncurses 2>/dev/null && exit
        for ext in so a dll.a dylib ; do
                for lib in ncursesw ncurses curses ; do
                        $cc -print-file-name=lib${lib}.${ext} | grep -q /
@@ -19,12 +21,17 @@ ldflags()
 # Where is ncurses.h?
 ccflags()
 {
-       if [ -f /usr/include/ncursesw/curses.h ]; then
-               echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
+       if pkg-config --cflags ncursesw 2>/dev/null; then
+               echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1'
+       elif pkg-config --cflags ncurses 2>/dev/null; then
+               echo '-DCURSES_LOC="<ncurses.h>"'
+       elif [ -f /usr/include/ncursesw/curses.h ]; then
+               echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
+               echo ' -DNCURSES_WIDECHAR=1'
        elif [ -f /usr/include/ncurses/ncurses.h ]; then
                echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
        elif [ -f /usr/include/ncurses/curses.h ]; then
-               echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
+               echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
        elif [ -f /usr/include/ncurses.h ]; then
                echo '-DCURSES_LOC="<ncurses.h>"'
        else