Skip to contentSkip to conversation

Use config scripts to detect ncurses libs for, menuconfig/nconfig dialogs

PATCH In review Justin 2 participants 6 messages Feb 24, 2013 – Feb 27, 2013

Subsystems (2)
lore
Share & tools
lore

Justin

author
#0 lore raw

PATCH 1/1 Use config scripts to detect ncurses libs for, menuconfig/nconfig dialogs

Hi,

when ncurses is build with --with-termlib several symbols are moved to a seperate terminfo library (libtinfo.so). Current Kernel buildsystem results in a build error with menuconfig and nconfig dialogs.

gcc -o scripts/kconfig/mconf scripts/kconfig/mconf.o scripts/kconfig/zconf.tab.o scripts/kconfig/lxdialog/checklist.o scripts/kconfig/lxdialog/util.o scripts/kconfig/lxdialog/inputbox.o scripts/kconfig/lxdialog/textbox.o scripts/kconfig/lxdialog/yesno.o scripts/kconfig/lxdialog/menubox.o -lncursesw scripts/kconfig/mconf.o:mconf.c:function show_help: error: undefined reference to 'stdscr' scripts/kconfig/lxdialog/checklist.o:checklist.c:function print_arrows:
error: undefined reference to 'acs_map' scripts/kconfig/lxdialog/checklist.o:checklist.c:function print_arrows:
error: undefined reference to 'acs_map' scripts/kconfig/lxdialog/checklist.o:checklist.c:function print_arrows:
error: undefined reference to 'acs_map' scripts/kconfig/lxdialog/checklist.o:checklist.c:function print_arrows:
error: undefined reference to 'acs_map' scripts/kconfig/lxdialog/checklist.o:checklist.c:function
dialog_checklist: error: undefined reference to 'stdscr' scripts/kconfig/lxdialog/checklist.o:checklist.c:function
dialog_checklist: error: undefined reference to 'COLS' scripts/kconfig/lxdialog/checklist.o:checklist.c:function
dialog_checklist: error: undefined reference to 'stdscr' scripts/kconfig/lxdialog/checklist.o:checklist.c:function
dialog_checklist: error: undefined reference to 'LINES' scripts/kconfig/lxdialog/checklist.o:checklist.c:function
dialog_checklist: error: undefined reference to 'keypad' scripts/kconfig/lxdialog/checklist.o:checklist.c:function
dialog_checklist: error: undefined reference to 'keypad' scripts/kconfig/lxdialog/util.o:util.c:function dialog_clear: error:
undefined reference to 'COLS' scripts/kconfig/lxdialog/util.o:util.c:function dialog_clear: error:
undefined reference to 'LINES' scripts/kconfig/lxdialog/util.o:util.c:function dialog_clear: error:
undefined reference to 'stdscr' scripts/kconfig/lxdialog/util.o:util.c:function dialog_clear: error:
undefined reference to 'COLS' scripts/kconfig/lxdialog/util.o:util.c:function dialog_clear: error:
undefined reference to 'COLS' scripts/kconfig/lxdialog/util.o:util.c:function init_dialog: error:
undefined reference to 'keypad' scripts/kconfig/lxdialog/util.o:util.c:function init_dialog: error:
undefined reference to 'cbreak' scripts/kconfig/lxdialog/util.o:util.c:function on_key_esc: error:
undefined reference to 'nodelay' scripts/kconfig/lxdialog/util.o:util.c:function on_key_esc: error:
undefined reference to 'keypad' scripts/kconfig/lxdialog/util.o:util.c:function on_key_esc: error:
undefined reference to 'nodelay' scripts/kconfig/lxdialog/inputbox.o:inputbox.c:function dialog_inputbox:
error: undefined reference to 'LINES' scripts/kconfig/lxdialog/textbox.o:textbox.c:function dialog_textbox:
error: undefined reference to 'LINES'
collect2: error: ld returned 1 exit status

Attached patch uses ncurses5-config and pkg-config to detect the libs to link with. Please include this to fix the build error.

justin

From 5c3e9e44432697b9f638c5367e01bdde47adf0f2 Mon Sep 17 00:00:00 2001
From: Justin Lecher <[email protected]>
Date: Sun, 24 Feb 2013 16:02:00 +0100
Subject: [PATCH] Use config scripts to detect ncurses libs for
menuconfig/nconfig dialogs

When building ncurses with --with-termlib several symbols get moved from libncurses.so to libtinfo.so. Thus when linking with libncurses.so, one additionally needs to link with libtinfo.so.

Ncurses provides a config script (ncurses5-config) and an interface with pkg-config. This patch makes use of those to detect the necessary libs for linking of the ncurses menuconfig and nconfig dialogs.

---
 scripts/kconfig/Makefile                   |  2 +-
 scripts/kconfig/lxdialog/check-lxdialog.sh | 22 ++++++++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)
scripts/kconfig/Makefile +1 -1
index 3091794..7649047 100644
@@ -216,7 +216,7 @@ 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	= `pkg-config --libs menu panel ncurses`
 $(obj)/qconf.o: $(obj)/.tmp_qtcheck
 
 ifeq ($(qconf-target),1)
scripts/kconfig/lxdialog/check-lxdialog.sh +14 -8
index c8e8a71..4699c1b 100644
@@ -4,15 +4,21 @@
 # What library to link
 ldflags()
 {
-	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 /
-			if [ $? -eq 0 ]; then
-				echo "-l${lib}"
-				exit
-			fi
+	if type -p ncurses5-config &> /dev/null ; then
+		ncurses5-config --libs
+		exit 0
+	else
+		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 /
+				if [ $? -eq 0 ]; then
+					echo "-l${lib}"
+					exit
+				fi
+			done
 		done
-	done
+	fi
 	exit 1
 }
 
Signature · 1 line
1.8.1.4
#1 lore raw

Justin, All,

Quoted 3 lines · On Sunday 24 February 2013 Justin wrote:

when ncurses is build with --with-termlib several symbols are moved to a seperate terminfo library (libtinfo.so). Current Kernel buildsystem results in a build error with menuconfig and nconfig dialogs.

Do you know of a distribution where this is the case, so I can test?

[--SNIP--]

Quoted 2 lines

Attached patch uses ncurses5-config and pkg-config to detect the libs to link with. Please include this to fix the build error.

Next time, please include the patch directly in the mail body, it is easier to review and comment. Using 'git send-email' does that automatically for you.

Quoted 10 lines

Subject: [PATCH] Use config scripts to detect ncurses libs for
menuconfig/nconfig dialogs

When building ncurses with --with-termlib several symbols get moved from libncurses.so to libtinfo.so. Thus when linking with libncurses.so, one additionally needs to link with libtinfo.so.

Ncurses provides a config script (ncurses5-config) and an interface with pkg-config. This patch makes use of those to detect the necessary libs for linking of the ncurses menuconfig and nconfig dialogs.

I think I would prefer spearate patches, one for mconf, one for nconf.

Quoted 12 lines

---

 scripts/kconfig/Makefile                   |  2 +-
 scripts/kconfig/lxdialog/check-lxdialog.sh | 22 ++++++++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)
scripts/kconfig/Makefile +0 -0
index 3091794..7649047 100644

scripts/kconfig/Makefile HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 · line 221

Quoted 7 lines
scripts/kconfig/Makefile +1 -1
@@ -216,7 +216,7 @@ 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	= `pkg-config --libs menu panel ncurses`

On my distro (Debian stable) ncurses has no pkg-config file installed, so this fails.

Quoted 12 lines
scripts/kconfig/Makefile +0 -0
 $(obj)/qconf.o: $(obj)/.tmp_qtcheck

ifeq ($(qconf-target),1)

(quoted diff) +0 -0

b/scripts/kconfig/lxdialog/check-lxdialog.sh index c8e8a71..4699c1b 100644

scripts/kconfig/lxdialog/check-lxdialog.sh +0 -0
@@ -4,15 +4,21 @@
 
 # What library to link
 ldflags()

scripts/kconfig/lxdialog/check-lxdialog.sh line 9

Quoted 10 lines
scripts/kconfig/lxdialog/check-lxdialog.sh +1 -7
 {
 
-	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 /
-			if [ $? -eq 0 ]; then
-				echo "-l${lib}"
-				exit
-			fi
+	if type -p ncurses5-config &> /dev/null ; then
                                   ^^

This is a bashism, and will not work on purely POSIX shells. Please use: >/dev/null 2>&1

scripts/kconfig/lxdialog/check-lxdialog.sh line 8

Quoted 1 line
scripts/kconfig/lxdialog/check-lxdialog.sh +1 -0
+		ncurses5-config --libs

I'd write:
if ! ncurses5-config --libs 2>/dev/null; then
old-code goes here
fi

scripts/kconfig/lxdialog/check-lxdialog.sh line 9

Quoted 1 line
scripts/kconfig/lxdialog/check-lxdialog.sh +1 -0
+		exit 0

(nit-picking) I'd prefer you be consistent with existing code which just calls 'exit' without a number.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
author
#2 lore raw
Quoted 8 lines · Yann E. MORIN

Justin, All,

Quoted 3 lines · On Sunday 24 February 2013 Justin wrote:

when ncurses is build with --with-termlib several symbols are moved to a seperate terminfo library (libtinfo.so). Current Kernel buildsystem results in a build error with menuconfig and nconfig dialogs.

Do you know of a distribution where this is the case, so I can test?

This is using Gentoo Linux testing with ld.gold. But I assume you will get the same result using any distro with gold.

Quoted 2 lines

I think I would prefer spearate patches, one for mconf, one for nconf.

I will send new patches in a separate mail, so that we can do the review there.

Quoted 6 lines

scripts/kconfig/Makefile HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ · line 219

Quoted 3 lines
scripts/kconfig/Makefile +1 -1
-HOSTLOADLIBES_nconf	= -lmenu -lpanel -lncurses
+HOSTLOADLIBES_nconf	= `pkg-config --libs menu panel ncurses`

On my distro (Debian stable) ncurses has no pkg-config file installed, so this fails.

I already feared that. Will convert it to ncurses5-config which should be available on any recent distro.

Quoted 5 lines

scripts/kconfig/lxdialog/check-lxdialog.sh line 7

Quoted 2 lines
scripts/kconfig/lxdialog/check-lxdialog.sh +1 -1
-			fi
+	if type -p ncurses5-config &> /dev/null ; then
                                   ^^

This is a bashism, and will not work on purely POSIX shells. Please use: >/dev/null 2>&1

Thanks for noting this.

Quoted 4 lines

scripts/kconfig/lxdialog/check-lxdialog.sh line 9

Quoted 1 line
scripts/kconfig/lxdialog/check-lxdialog.sh +1 -0
+		exit 0

(nit-picking) I'd prefer you be consistent with existing code which just calls 'exit' without a number.

I added it to be more precise on the return value. But I don't care as simple exit should result in the same.

Thanks for the review.

#3 lore raw

Justin, All,

Quoted 10 lines · On Monday 25 February 2013 Justin wrote:
Quoted 6 lines · Yann E. MORIN
Quoted 3 lines · On Sunday 24 February 2013 Justin wrote:

when ncurses is build with --with-termlib several symbols are moved to a seperate terminfo library (libtinfo.so). Current Kernel buildsystem results in a build error with menuconfig and nconfig dialogs.

Do you know of a distribution where this is the case, so I can test?

This is using Gentoo Linux testing with ld.gold. But I assume you will get the same result using any distro with gold.

No, I meant a distro where ncurses is built with --with-termlib. On my Debian stable (squeeze), libtinfo does not exist at all, so I can not test linking against it:

    $ apt-file search libtinfo
    (zilch)

But I'll see at installing a Gentoo (if that's not too complex) in a VM to do the checks (can you confirm that Gentoo by default configures ncurses with --with-termlib ?).

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
author
#4 lore raw
Quoted 21 lines · Yann E. MORIN

Justin, All,

Quoted 10 lines · On Monday 25 February 2013 Justin wrote:
Quoted 6 lines · Yann E. MORIN
Quoted 3 lines · On Sunday 24 February 2013 Justin wrote:

when ncurses is build with --with-termlib several symbols are moved to a seperate terminfo library (libtinfo.so). Current Kernel buildsystem results in a build error with menuconfig and nconfig dialogs.

Do you know of a distribution where this is the case, so I can test?

This is using Gentoo Linux testing with ld.gold. But I assume you will get the same result using any distro with gold.

No, I meant a distro where ncurses is built with --with-termlib. On my Debian stable (squeeze), libtinfo does not exist at all, so I can not test linking against it:

    $ apt-file search libtinfo
    (zilch)
Quoted 7 lines

But I'll see at installing a Gentoo (if that's not too complex) in a VM to do the checks (can you confirm that Gentoo by default configures ncurses with --with-termlib ?).

Regards,
Yann E. MORIN.

I can be build optionally (mostly for binary package compatibility reasons) with --with-termlib. I will send a step-by-step instruction how to test this with our live cd later today.

Thanks,
Justin

author
#5 lore raw
In reply to Yann E. MORIN
Quoted 1 line · Yann E. MORIN
Quoted 1 line
Quoted 1 line

Do you know of a distribution where this is the case, so I can test?

Fedora is also building with --with-termlib but they are using a ld script to workaround the linking problem. I talked to our (Gentoo Linux) base-system maintainers but they refused to apply this, instead they said the consuming packages should be fixed. This is now an ongoing effort.

Quoted 4 lines

But I'll see at installing a Gentoo (if that's not too complex) in a VM to do the checks (can you confirm that Gentoo by default configures ncurses with --with-termlib ?).

It is not the "default" configuration in a classic sense, because it will only build with that option if a consuming package requests this.

Here the receipt for generic reproduction:

* Get yourself a copy of our live dvd
(http://gentoo.inode.at//releases/x86/20121221/)
* Kick a vm or boot from the dvd (Make sure you have enough RAM, because you will compile ncurses on it and place the git checkout there.)
* Get a terminal and switch to root
* Update the package db by running: emerge --sync
* Rebuild ncurses with:
ACCEPT_KEYWORDS="~x86" USE="tinfo" emerge -va1 ncurses Important here that "tinfo" is marked as changing USE (colored green)
* Switch to ld.gold with "binutils-config --linker ld.gold" (make sure that it worked out -> ld -v)
* git clone the kernel and do your testing.

Justin