kconfig/lxdialog/check-lxdialog.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Apr 26 21:31:05 2008 +0000 (2008-04-26)
changeset 454 372b2f397baa
child 706 607277e3cdab
permissions -rwxr-xr-x
Configure tsocks with a simple heuristic.

Consider the proxy has to be in a 'local' network. It means it is directly
reachable by the local machine, even if the local machine has to hop through
one or more gates to reach the proxy (often the case in enterprise networks
where class A 10.0.0.0/8 is in fact sub-divided into smaller networks, each
one of them in a different location, eg. 10.1.0.0/16 in a place, while
10.2.0.0/16 would be on the other side of the world). Not being in the same
subnet does not mean the proxy is not available.

So we will build a mask with at most high bits set, which defines a network
that has both the local machine and the proxy. Because a machine may have
more than one interface, build a mask for each of them, removing 127.0.0.1
which is added automagically by tsocks, and removing duplicate masks.

If all of this does not work, then it means the local machine can NOT in fact
reach the proxy, which in turn means the user mis-configured something (most
probably a typo...).

/trunk/scripts/crosstool.sh | 61 52 9 0 +++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 52 insertions(+), 9 deletions(-)
yann@1
     1
#!/bin/sh
yann@1
     2
# Check ncurses compatibility
yann@1
     3
yann@1
     4
# What library to link
yann@1
     5
ldflags()
yann@1
     6
{
yann@1
     7
	$cc -print-file-name=libncursesw.so | grep -q /
yann@1
     8
	if [ $? -eq 0 ]; then
yann@1
     9
		echo '-lncursesw'
yann@1
    10
		exit
yann@1
    11
	fi
yann@1
    12
	$cc -print-file-name=libncurses.so | grep -q /
yann@1
    13
	if [ $? -eq 0 ]; then
yann@1
    14
		echo '-lncurses'
yann@1
    15
		exit
yann@1
    16
	fi
yann@1
    17
	$cc -print-file-name=libcurses.so | grep -q /
yann@1
    18
	if [ $? -eq 0 ]; then
yann@1
    19
		echo '-lcurses'
yann@1
    20
		exit
yann@1
    21
	fi
yann@1
    22
	exit 1
yann@1
    23
}
yann@1
    24
yann@1
    25
# Where is ncurses.h?
yann@1
    26
ccflags()
yann@1
    27
{
yann@1
    28
	if [ -f /usr/include/ncurses/ncurses.h ]; then
yann@1
    29
		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
yann@1
    30
	elif [ -f /usr/include/ncurses/curses.h ]; then
yann@1
    31
		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
yann@1
    32
	elif [ -f /usr/include/ncurses.h ]; then
yann@1
    33
		echo '-DCURSES_LOC="<ncurses.h>"'
yann@1
    34
	else
yann@1
    35
		echo '-DCURSES_LOC="<curses.h>"'
yann@1
    36
	fi
yann@1
    37
}
yann@1
    38
yann@1
    39
# Temp file, try to clean up after us
yann@1
    40
tmp=.lxdialog.tmp
yann@1
    41
trap "rm -f $tmp" 0 1 2 3 15
yann@1
    42
yann@1
    43
# Check if we can link to ncurses
yann@1
    44
check() {
yann@1
    45
	echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null
yann@1
    46
	if [ $? != 0 ]; then
yann@1
    47
		echo " *** Unable to find the ncurses libraries."          1>&2
yann@1
    48
		echo " *** make menuconfig require the ncurses libraries"  1>&2
yann@1
    49
		echo " *** "                                               1>&2
yann@1
    50
		echo " *** Install ncurses (ncurses-devel) and try again"  1>&2
yann@1
    51
		echo " *** "                                               1>&2
yann@1
    52
		exit 1
yann@1
    53
	fi
yann@1
    54
}
yann@1
    55
yann@1
    56
usage() {
yann@1
    57
	printf "Usage: $0 [-check compiler options|-header|-library]\n"
yann@1
    58
}
yann@1
    59
yann@1
    60
if [ $# == 0 ]; then
yann@1
    61
	usage
yann@1
    62
	exit 1
yann@1
    63
fi
yann@1
    64
yann@1
    65
cc=""
yann@1
    66
case "$1" in
yann@1
    67
	"-check")
yann@1
    68
		shift
yann@1
    69
		cc="$@"
yann@1
    70
		check
yann@1
    71
		;;
yann@1
    72
	"-ccflags")
yann@1
    73
		ccflags
yann@1
    74
		;;
yann@1
    75
	"-ldflags")
yann@1
    76
		shift
yann@1
    77
		cc="$@"
yann@1
    78
		ldflags
yann@1
    79
		;;
yann@1
    80
	"*")
yann@1
    81
		usage
yann@1
    82
		exit 1
yann@1
    83
		;;
yann@1
    84
esac