kconfig/lxdialog/check-lxdialog.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Aug 31 23:24:40 2010 +0200 (2010-08-31)
changeset 2107 f5ab0a80e466
parent 1229 8864e5255c2d
child 2125 4009fc9c47d5
permissions -rw-r--r--
binutils/binutils: remove faulty patch

The added code should be conditinal to the target system
being !MIPS, but is based on the host system being !MIPS.

This is plain wrong, and had not been noticed until now
as I never used those binutils versions on MIPS.

See:
http://sourceware.org/ml/crossgcc/2010-08/msg00192.html

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 #!/bin/sh
     2 # Check ncurses compatibility
     3 
     4 OS=`uname`
     5 
     6 # Under MACOS make sure that the macports-installed version is used.
     7 case "$OS" in
     8 	Darwin) BASEDIR="/opt/local";;
     9 	*)      BASEDIR="/usr";;
    10 esac
    11 
    12 INCLUDEPATH="${BASEDIR}/include"
    13 LIBPATH="${BASEDIR}/lib"
    14 
    15 # What library to link
    16 ldflags()
    17 {
    18 	for ext in so a dylib ; do
    19 		for lib in ncursesw ncurses curses ; do
    20 			if [ -f "${LIBPATH}/lib${lib}.${ext}" ]; then
    21 				echo "-L${LIBPATH} -l${lib}"
    22 				exit
    23 			fi
    24 		done
    25 	done
    26 	exit 1
    27 }
    28 
    29 # Where is ncurses.h?
    30 ccflags()
    31 {
    32 	if [ -f "${INCLUDEPATH}/ncursesw/ncurses.h" ]; then
    33 		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncursesw/ncurses.h>\""
    34 	elif [ -f "${INCLUDEPATH}/ncurses/ncurses.h" ]; then
    35 		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncurses/ncurses.h>\""
    36 	elif [ -f "${INCLUDEPATH}/ncursesw/curses.h" ]; then
    37 		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncursesw/curses.h>\""
    38 	elif [ -f "${INCLUDEPATH}/ncurses/curses.h" ]; then
    39 		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncurses/curses.h>\""
    40 	elif [ -f "${INCLUDEPATH}/ncurses.h" ]; then
    41 		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncurses.h>\""
    42 	elif [ -f "${INCLUDEPATH}/curses.h" ]; then
    43 		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<curses.h>\""
    44 	else
    45 		exit 1
    46 	fi
    47 }
    48 
    49 # Temp file, try to clean up after us
    50 tmp=.lxdialog.tmp
    51 trap "rm -f $tmp" 0 1 2 3 15
    52 
    53 # Check if we can link to ncurses
    54 check() {
    55         IF=`echo $(ccflags) | sed -e 's/"//g'`
    56         $cc $IF $(ldflags) -xc - -o $tmp 2>/dev/null <<'EOF'
    57 #include CURSES_LOC
    58 main() {}
    59 EOF
    60 	if [ $? != 0 ]; then
    61 	    echo " *** Unable to find the ncurses libraries or the"       1>&2
    62 	    echo " *** required header files."                            1>&2
    63 	    echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
    64 	    echo " *** "                                                  1>&2
    65 	    echo " *** Install ncurses (ncurses-devel) and try again."    1>&2
    66 	    echo " *** "                                                  1>&2
    67 	    exit 1
    68 	fi
    69 }
    70 
    71 usage() {
    72 	printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
    73 }
    74 
    75 if [ $# -eq 0 ]; then
    76 	usage
    77 	exit 1
    78 fi
    79 
    80 cc=""
    81 case "$1" in
    82 	"-check")
    83 		shift
    84 		cc="$@"
    85 		check
    86 		;;
    87 	"-ccflags")
    88 		ccflags
    89 		;;
    90 	"-ldflags")
    91 		shift
    92 		cc="$@"
    93 		ldflags
    94 		;;
    95 	"*")
    96 		usage
    97 		exit 1
    98 		;;
    99 esac