kconfig: use POSIX equality test in check-lxdialog.sh
[firefly-linux-kernel-4.4.55.git] / scripts / kconfig / lxdialog / check-lxdialog.sh
index 448e353923f3b52545a7473d4ff5a4e342a7f959..9681476b96e7fcf371840d78e17aa85657d327a1 100644 (file)
@@ -4,21 +4,15 @@
 # What library to link
 ldflags()
 {
-       echo "main() {}" | $cc -lncursesw -xc - -o /dev/null 2> /dev/null
-       if [ $? -eq 0 ]; then
-               echo '-lncursesw'
-               exit
-       fi
-       echo "main() {}" | $cc -lncurses -xc - -o /dev/null 2> /dev/null
-       if [ $? -eq 0 ]; then
-               echo '-lncurses'
-               exit
-       fi
-       echo "main() {}" | $cc -lcurses -xc - -o /dev/null 2> /dev/null
-       if [ $? -eq 0 ]; then
-               echo '-lcurses'
-               exit
-       fi
+       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
 }
 
@@ -36,10 +30,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
@@ -54,11 +51,12 @@ usage() {
        printf "Usage: $0 [-check compiler options|-header|-library]\n"
 }
 
-if [ $# == 0 ]; then
+if [ $# -eq 0 ]; then
        usage
        exit 1
 fi
 
+cc=""
 case "$1" in
        "-check")
                shift