Merge with git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
[powerpc.git] / scripts / kconfig / lxdialog / check-lxdialog.sh
index a3c141b..120d624 100644 (file)
@@ -4,11 +4,22 @@
 # What library to link
 ldflags()
 {
-       if [ `uname` == SunOS ]; then
-               echo '-lcurses'
-       else
+       $cc -print-file-name=libncursesw.so | grep -q /
+       if [ $? -eq 0 ]; then
+               echo '-lncursesw'
+               exit
+       fi
+       $cc -print-file-name=libncurses.so | grep -q /
+       if [ $? -eq 0 ]; then
                echo '-lncurses'
+               exit
+       fi
+       $cc -print-file-name=libcurses.so | grep -q /
+       if [ $? -eq 0 ]; then
+               echo '-lcurses'
+               exit
        fi
+       exit 1
 }
 
 # Where is ncurses.h?
@@ -25,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() {}" | $compiler -xc -
+       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
@@ -48,16 +62,19 @@ if [ $# == 0 ]; then
        exit 1
 fi
 
+cc=""
 case "$1" in
        "-check")
                shift
-               compiler="$@"
+               cc="$@"
                check
                ;;
        "-ccflags")
                ccflags
                ;;
        "-ldflags")
+               shift
+               cc="$@"
                ldflags
                ;;
        "*")