kconfig/lxdialog/check-lxdialog.sh
changeset 375 4beb099d5aa4
child 706 607277e3cdab
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/kconfig/lxdialog/check-lxdialog.sh	Wed Sep 12 17:35:07 2007 +0000
     1.3 @@ -0,0 +1,84 @@
     1.4 +#!/bin/sh
     1.5 +# Check ncurses compatibility
     1.6 +
     1.7 +# What library to link
     1.8 +ldflags()
     1.9 +{
    1.10 +	$cc -print-file-name=libncursesw.so | grep -q /
    1.11 +	if [ $? -eq 0 ]; then
    1.12 +		echo '-lncursesw'
    1.13 +		exit
    1.14 +	fi
    1.15 +	$cc -print-file-name=libncurses.so | grep -q /
    1.16 +	if [ $? -eq 0 ]; then
    1.17 +		echo '-lncurses'
    1.18 +		exit
    1.19 +	fi
    1.20 +	$cc -print-file-name=libcurses.so | grep -q /
    1.21 +	if [ $? -eq 0 ]; then
    1.22 +		echo '-lcurses'
    1.23 +		exit
    1.24 +	fi
    1.25 +	exit 1
    1.26 +}
    1.27 +
    1.28 +# Where is ncurses.h?
    1.29 +ccflags()
    1.30 +{
    1.31 +	if [ -f /usr/include/ncurses/ncurses.h ]; then
    1.32 +		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
    1.33 +	elif [ -f /usr/include/ncurses/curses.h ]; then
    1.34 +		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
    1.35 +	elif [ -f /usr/include/ncurses.h ]; then
    1.36 +		echo '-DCURSES_LOC="<ncurses.h>"'
    1.37 +	else
    1.38 +		echo '-DCURSES_LOC="<curses.h>"'
    1.39 +	fi
    1.40 +}
    1.41 +
    1.42 +# Temp file, try to clean up after us
    1.43 +tmp=.lxdialog.tmp
    1.44 +trap "rm -f $tmp" 0 1 2 3 15
    1.45 +
    1.46 +# Check if we can link to ncurses
    1.47 +check() {
    1.48 +	echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null
    1.49 +	if [ $? != 0 ]; then
    1.50 +		echo " *** Unable to find the ncurses libraries."          1>&2
    1.51 +		echo " *** make menuconfig require the ncurses libraries"  1>&2
    1.52 +		echo " *** "                                               1>&2
    1.53 +		echo " *** Install ncurses (ncurses-devel) and try again"  1>&2
    1.54 +		echo " *** "                                               1>&2
    1.55 +		exit 1
    1.56 +	fi
    1.57 +}
    1.58 +
    1.59 +usage() {
    1.60 +	printf "Usage: $0 [-check compiler options|-header|-library]\n"
    1.61 +}
    1.62 +
    1.63 +if [ $# == 0 ]; then
    1.64 +	usage
    1.65 +	exit 1
    1.66 +fi
    1.67 +
    1.68 +cc=""
    1.69 +case "$1" in
    1.70 +	"-check")
    1.71 +		shift
    1.72 +		cc="$@"
    1.73 +		check
    1.74 +		;;
    1.75 +	"-ccflags")
    1.76 +		ccflags
    1.77 +		;;
    1.78 +	"-ldflags")
    1.79 +		shift
    1.80 +		cc="$@"
    1.81 +		ldflags
    1.82 +		;;
    1.83 +	"*")
    1.84 +		usage
    1.85 +		exit 1
    1.86 +		;;
    1.87 +esac