diff mbox

[1/2] Use config scripts to detect ncurses libs for menuconfig

Message ID 1361988458-18486-1-git-send-email-jlec@gentoo.org (mailing list archive)
State New, archived
Headers show

Commit Message

Justin Feb. 27, 2013, 6:07 p.m. UTC
From: Justin Lecher <jlec@gentoo.org>

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) to assist finding ncurses.
This patch makes use of it to detect the necessary libs for linking of the
ncurses menuconfig dialog.

Signed-off-by: Justin Lecher <jlec@gentoo.org>
---
 scripts/kconfig/lxdialog/check-lxdialog.sh | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

Comments

Yann E. MORIN Feb. 27, 2013, 6:37 p.m. UTC | #1
Justin, All,

On Wednesday 27 February 2013 jlec@gentoo.org wrote:
> 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) to assist finding ncurses.
> This patch makes use of it to detect the necessary libs for linking of the
> ncurses menuconfig dialog.
> 
> Signed-off-by: Justin Lecher <jlec@gentoo.org>

Usually, patch subjects are of the form:
  subsystem: subject

So I'd suggest the following subject:
    kconfig/menuconfig: use config scripts to detect ncurses libs

That way, it makes it easy to see at first glance what the patch is
about (kconfig/menuconfig), and what it achieves (use config scripts).

> ---
>  scripts/kconfig/lxdialog/check-lxdialog.sh | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
> index c8e8a71..e429207 100644
> --- a/scripts/kconfig/lxdialog/check-lxdialog.sh
> +++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
> @@ -4,15 +4,23 @@
>  # 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 ncursesw5-config --libs >/dev/null 2>&1; then
> +		ncursesw5-config --libs
> +		exit
> +	elif ncurses5-config --libs >/dev/null 2>&1; then
> +		ncurses5-config --libs
> +		exit

No need to run ncurses{,w}5-config twice each. Just do:

    ncursesw5-config --libs 2>/dev/null && exit
    ncurses5-config --libs 2>/dev/null && exit
    [old code unchanged]

This avoids an ugly re-indent of otherwise unchanged code.

On a side note: is the old code still useful, now we use the config
scripts? In other words: are there cases where a ncurses install would
not provide those scripts?

If the answer is 'no', then just trash the old code away.

I've just tested Debian Squeeze (stable for now), and Cygwin, and they
both do provide ncurses{,w}5-config.

> +	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
>  }

Regards,
Yann E. MORIN.
Justin Feb. 28, 2013, 9:35 a.m. UTC | #2
Hello,

> On a side note: is the old code still useful, now we use the config
> scripts? In other words: are there cases where a ncurses install would
> not provide those scripts?
> 
> If the answer is 'no', then just trash the old code away.
> 
> I've just tested Debian Squeeze (stable for now), and Cygwin, and they
> both do provide ncurses{,w}5-config.
> 

I looked into the ncurses releases back to 5.0. The first release
containing is version 5.6 released in 2006. So I would guess we can
assume that every system will have it.


justin
Yann E. MORIN Feb. 28, 2013, 6:08 p.m. UTC | #3
Justin, All,

On Thursday 28 February 2013 justin wrote:
> > On a side note: is the old code still useful, now we use the config
> > scripts? In other words: are there cases where a ncurses install would
> > not provide those scripts?
> > 
> > If the answer is 'no', then just trash the old code away.
> > 
> > I've just tested Debian Squeeze (stable for now), and Cygwin, and they
> > both do provide ncurses{,w}5-config.
> > 
> 
> I looked into the ncurses releases back to 5.0. The first release
> containing is version 5.6 released in 2006. So I would guess we can
> assume that every system will have it.

Well, RHEL4 is still widely used, and it was released in 2005, so will
not have ncurses-5.6 (updates may have it, but not everybody installs
updates).

Regards,
Yann E. MORIN.
Justin Feb. 28, 2013, 9:31 p.m. UTC | #4
On 2/28/13 7:08 PM, Yann E. MORIN wrote:
> 
> Well, RHEL4 is still widely used, and it was released in 2005, so will
> not have ncurses-5.6 (updates may have it, but not everybody installs
> updates).
> 

Hi,

question, will such system be updated then to latest kernel sources? And
if so, can't we require that for the ncurses based config menus need
newer ncurses?

Justin
Yann E. MORIN Feb. 28, 2013, 9:35 p.m. UTC | #5
Justin, All,

On Thursday 28 February 2013 justin wrote:
> On 2/28/13 7:08 PM, Yann E. MORIN wrote:
> > Well, RHEL4 is still widely used, and it was released in 2005, so will
> > not have ncurses-5.6 (updates may have it, but not everybody installs
> > updates).
> 
> question, will such system be updated then to latest kernel sources? And
> if so, can't we require that for the ncurses based config menus need
> newer ncurses?

It's not that those systems will be updated to run the latest kernel, but
rather that those systems can be used to build a newer kernel for another
system (think eg. cross-compilation and embedded).

Regards,
Yann E. MORIN.
Justin Feb. 28, 2013, 9:38 p.m. UTC | #6
On 2/28/13 10:35 PM, Yann E. MORIN wrote:
> It's not that those systems will be updated to run the latest kernel, but
> rather that those systems can be used to build a newer kernel for another
> system (think eg. cross-compilation and embedded).
> 

That's true, I will split the patches as suggested.

Jusitn
diff mbox

Patch

diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index c8e8a71..e429207 100644
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -4,15 +4,23 @@ 
 # 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 ncursesw5-config --libs >/dev/null 2>&1; then
+		ncursesw5-config --libs
+		exit
+	elif ncurses5-config --libs >/dev/null 2>&1; then
+		ncurses5-config --libs
+		exit
+	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
 }