kconfig: fix /dev/null breakage
authorSam Ravnborg <sam@mars.ravnborg.org>
Sat, 21 Jan 2006 11:03:09 +0000 (12:03 +0100)
committerSam Ravnborg <sam@mars.ravnborg.org>
Sat, 21 Jan 2006 11:03:09 +0000 (12:03 +0100)
While running "make menuconfig" and "make mrproper"
some people experienced that /dev/null suddenly changed
permissions or suddenly became a regular file.
The main reason was that /dev/null was used as output
to gcc in the check-lxdialog.sh script and gcc did
some strange things with the output file; in this
case /dev/null when it errorred out.

Following patch implements a suggestion
from Bryan O'Sullivan <bos@serpentine.com> to
use gcc -print-file-name=libxxx.so.

Also the Makefile is adjusted to not resolve value of
HOST_EXTRACFLAGS and HOST_LOADLIBES until they are actually used.
This prevents us from calling gcc when running make *clean/mrproper

Thanks to Eyal Lebedinsky <eyal@eyal.emu.id.au> and
Jean Delvare <khali@linux-fr.org> for the first error reports.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---

scripts/kconfig/lxdialog/Makefile
scripts/kconfig/lxdialog/check-lxdialog.sh

index fae3e29..bbf4887 100644 (file)
@@ -2,8 +2,11 @@
 #
 
 check-lxdialog  := $(srctree)/$(src)/check-lxdialog.sh
-HOST_EXTRACFLAGS:= $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
-HOST_LOADLIBES  := $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
+
+# Use reursively 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)
+HOST_LOADLIBES   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
  
 HOST_EXTRACFLAGS += -DLOCALE 
 
index 448e353..120d624 100644 (file)
@@ -4,17 +4,17 @@
 # What library to link
 ldflags()
 {
-       echo "main() {}" | $cc -lncursesw -xc - -o /dev/null 2> /dev/null
+       $cc -print-file-name=libncursesw.so | grep -q /
        if [ $? -eq 0 ]; then
                echo '-lncursesw'
                exit
        fi
-       echo "main() {}" | $cc -lncurses -xc - -o /dev/null 2> /dev/null
+       $cc -print-file-name=libncurses.so | grep -q /
        if [ $? -eq 0 ]; then
                echo '-lncurses'
                exit
        fi
-       echo "main() {}" | $cc -lcurses -xc - -o /dev/null 2> /dev/null
+       $cc -print-file-name=libcurses.so | grep -q /
        if [ $? -eq 0 ]; then
                echo '-lcurses'
                exit
@@ -36,10 +36,13 @@ ccflags()
        fi
 }
 
-compiler=""
+# 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() {
-       echo "main() {}" | $cc -xc - -o /dev/null 2> /dev/null
+       echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null
        if [ $? != 0 ]; then
                echo " *** Unable to find the ncurses libraries."          1>&2
                echo " *** make menuconfig require the ncurses libraries"  1>&2
@@ -59,6 +62,7 @@ if [ $# == 0 ]; then
        exit 1
 fi
 
+cc=""
 case "$1" in
        "-check")
                shift