public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaud Lacombe <lacombar@gmail.com>
To: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	Michal Marek <mmarek@suse.cz>
Cc: Arnaud Lacombe <lacombar@gmail.com>
Subject: [RFC 6/7] kconfig: move ncurses checks to `scripts/kconfig/check.sh'
Date: Fri,  1 Jul 2011 21:47:38 -0400	[thread overview]
Message-ID: <1309571259-15241-7-git-send-email-lacombar@gmail.com> (raw)
In-Reply-To: <1309571259-15241-1-git-send-email-lacombar@gmail.com>

---
 scripts/kconfig/Makefile                   |   24 +-------
 scripts/kconfig/check.sh                   |   50 ++++++++++++++++
 scripts/kconfig/lxdialog/check-lxdialog.sh |   84 ----------------------------
 3 files changed, 54 insertions(+), 104 deletions(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 5021817..4e934f1 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -141,14 +141,6 @@ help:
 	@echo  '  listnewconfig   - List new options'
 	@echo  '  oldnoconfig     - Same as silentoldconfig but set new symbols to n (unset)'
 
-# lxdialog stuff
-check-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
-
-# Use recursively expanded variables so we do not call gcc unless
-# we really need to do so. (Do not call gcc as part of make mrproper)
-HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
-                    -DLOCALE
-
 # ===========================================================================
 # Shared Makefile for the various kconfig executables:
 # conf:	  Used for defconfig, oldconfig and related targets
@@ -184,10 +176,12 @@ KC_CHECK := gettext
 
 ifeq ($(MAKECMDGOALS),nconfig)
 	hostprogs-y += nconf
+	KC_CHECK += ncurses
 endif
 
 ifeq ($(MAKECMDGOALS),menuconfig)
 	hostprogs-y += mconf
+	KC_CHECK += ncurses
 endif
 
 ifeq ($(MAKECMDGOALS),update-po-config)
@@ -211,26 +205,16 @@ clean-files	+= zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
 clean-files     += mconf qconf gconf nconf
 clean-files     += config.pot linux.pot
 
-# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
-PHONY += $(obj)/dochecklxdialog
-$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
-$(obj)/dochecklxdialog:
-	$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
-
-always := dochecklxdialog
-
 # generated files seem to need this to find local include files
 HOSTCFLAGS_lex.zconf.o	:= -I$(src)
 HOSTCFLAGS_zconf.tab.o	:= -I$(src)
 
 HOSTCFLAGS_gconf.o	= -Wno-missing-prototypes
 
-HOSTLOADLIBES_mconf   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
-
-HOSTLOADLIBES_nconf	= -lmenu -lpanel -lncurses
-
+HOSTLOADLIBES_nconf	= -lmenu -lpanel
 
 need-check := $(addprefix $(obj)/,$(frontends-objs))
+need-check += $(addprefix $(obj)/,$(lxdialog))
 
 $(need-check): $(obj)/.tmp_check
 
diff --git a/scripts/kconfig/check.sh b/scripts/kconfig/check.sh
index 4456d63..ec551b7 100755
--- a/scripts/kconfig/check.sh
+++ b/scripts/kconfig/check.sh
@@ -47,6 +47,55 @@ check_gtk()
 	echo "HOSTLOADLIBES_gconf	+= $libs"   >> ${obj}/.tmp_check
 }
 
+check_ncurses()
+{
+	local cflags=""
+	local libs=""
+
+	ncurses_h="ncursesw/curses.h ncurses/ncurses.h ncurses/curses.h"
+	ncurses_h="${ncurses_h} ncurses.h curses.h"
+
+	for header in ${ncurses_h}; do
+		if echo "#include <${header}>" | \
+		    $HOSTCC -xc -E -c -o /dev/null - 2> /dev/null; then
+			cflags="-DCURSES_LOC=\"<$header>\""
+			break
+		fi
+	done
+
+	if [ -z "$cflags" ]; then
+		echo "  *"
+		echo "  * Unable to find the required ncurses header files."
+		echo "  * "
+		echo "  * Please install ncurses (ncurses-devel) and try again."
+		echo "  *"
+		false
+	fi
+
+	for ext in so a dylib ; do
+		for lib in ncursesw ncurses curses; do
+			filename="$($HOSTCC -print-file-name=lib${lib}.${ext})"
+			if [ "$filename" != "lib${lib}.${ext}" ]; then
+				libs=-l$lib
+				break
+			fi
+		done
+		[ -n "$libs" ] && break
+	done
+
+	if [ -z "$libs" ]; then
+		echo "  * Unable to find the required ncurses library."
+		echo "  *"
+		echo "  * Please install ncurses (ncurses-devel) and try again."
+		echo "  * "
+		false
+	fi
+
+	echo "HOSTCFLAGS	+=$cflags" >> ${obj}/.tmp_check
+	echo "HOSTLOADLIBES_mconf	+= $libs"   >> ${obj}/.tmp_check
+	echo "HOSTLOADLIBES_nconf	+= $libs"   >> ${obj}/.tmp_check
+}
+
 check_qt()
 {
 	local cflags=""
@@ -114,6 +163,7 @@ for arg in $*; do
 	case $arg in
 	gettext)	;;
 	gtk)		;;
+	ncurses)	;;
 	qt)		;;
 	*)
 		echo "  *"
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index 82cc3a8..e69de29 100644
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -1,84 +0,0 @@
-#!/bin/sh
-# Check ncurses compatibility
-
-# What library to link
-ldflags()
-{
-	for ext in so 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
-	exit 1
-}
-
-# Where is ncurses.h?
-ccflags()
-{
-	if [ -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>"'
-	elif [ -f /usr/include/ncursesw/curses.h ]; then
-		echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
-	elif [ -f /usr/include/ncurses.h ]; then
-		echo '-DCURSES_LOC="<ncurses.h>"'
-	else
-		echo '-DCURSES_LOC="<curses.h>"'
-	fi
-}
-
-# Temp file, try to clean up after us
-tmp=.lxdialog.tmp
-trap "rm -f $tmp" 0 1 2 3 15
-
-# Check if we can link to ncurses
-check() {
-        $cc -xc - -o $tmp 2>/dev/null <<'EOF'
-#include CURSES_LOC
-main() {}
-EOF
-	if [ $? != 0 ]; then
-	    echo " *** Unable to find the ncurses libraries or the"       1>&2
-	    echo " *** required header files."                            1>&2
-	    echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
-	    echo " *** "                                                  1>&2
-	    echo " *** Install ncurses (ncurses-devel) and try again."    1>&2
-	    echo " *** "                                                  1>&2
-	    exit 1
-	fi
-}
-
-usage() {
-	printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
-}
-
-if [ $# -eq 0 ]; then
-	usage
-	exit 1
-fi
-
-cc=""
-case "$1" in
-	"-check")
-		shift
-		cc="$@"
-		check
-		;;
-	"-ccflags")
-		ccflags
-		;;
-	"-ldflags")
-		shift
-		cc="$@"
-		ldflags
-		;;
-	"*")
-		usage
-		exit 1
-		;;
-esac
-- 
1.7.3.4.574.g608b.dirty


  parent reply	other threads:[~2011-07-02  1:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06 19:16 [RFC] Kconfig library check merge Arnaud Lacombe
2011-07-01 14:11 ` Michal Marek
2011-07-02  0:33   ` Arnaud Lacombe
2011-07-02  1:47 ` [RFC 0/7] " Arnaud Lacombe
2011-07-02  1:47   ` [RFC 1/7] kconfig/Makefile: add pretty printer for moc(1) Arnaud Lacombe
2011-07-02  1:47   ` [RFC 2/7] kconfig/Makefile: ensure `conf' appears last in `hostprogs-y' Arnaud Lacombe
2011-07-02  1:47   ` [RFC 3/7] kconfig/check.sh: prepare for generic check Arnaud Lacombe
2011-07-05 22:37     ` Valdis.Kletnieks
2011-07-05 22:48       ` Arnaud Lacombe
2011-07-02  1:47   ` [RFC 4/7] kconfig: move QT checks to `scripts/kconfig/check.sh' Arnaud Lacombe
2011-07-02  1:47   ` [RFC 5/7] kconfig: move GTK " Arnaud Lacombe
2011-07-02  1:47   ` Arnaud Lacombe [this message]
2011-07-02  1:47   ` [RFC 7/7] kconfig: add stub for nconf checks Arnaud Lacombe
2011-07-18 19:03   ` [RFC 0/7] Kconfig library check merge Arnaud Lacombe
2011-07-19 13:06     ` Michal Marek
2011-08-16  5:29       ` Arnaud Lacombe
2011-08-19 14:02         ` Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1309571259-15241-7-git-send-email-lacombar@gmail.com \
    --to=lacombar@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox