kconfig/lxdialog/check-lxdialog.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Aug 02 18:26:53 2011 +0200 (2011-08-02)
changeset 2592 4908eb2b6f17
parent 2125 4009fc9c47d5
permissions -rw-r--r--
scripts/functions: cvs retrieval first tries the mirror for tarballs

The cvs download helper looks for the local tarballs dir to see if it
can find a pre-downloaded tarball, and if it does not find it, does
the actual fetch to upstream via cvs.

In the process, it does not even try to get a tarball from the local
mirror, which can be useful if the mirror has been pre-populated
manually (or with a previously downloaded tree).

Fake a tarball get with the standard tarball-download helper, but
without specifying any upstream URL, which makes the helper directly
try the LAN mirror.

Of course, if no mirror is specified, no URL wil be available, and
the standard cvs retrieval will kick in.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
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@1087
     7
	for ext in so a dylib ; do
yann@1087
     8
		for lib in ncursesw ncurses curses ; do
yann@2125
     9
			$cc -print-file-name=lib${lib}.${ext} | grep -q /
yann@2125
    10
			if [ $? -eq 0 ]; then
yann@2125
    11
				echo "-l${lib}"
yann@1087
    12
				exit
yann@1087
    13
			fi
yann@1087
    14
		done
yann@1087
    15
	done
yann@1
    16
	exit 1
yann@1
    17
}
yann@1
    18
yann@1
    19
# Where is ncurses.h?
yann@1
    20
ccflags()
yann@1
    21
{
yann@2125
    22
	if [ -f /usr/include/ncurses/ncurses.h ]; then
yann@2125
    23
		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
yann@2125
    24
	elif [ -f /usr/include/ncurses/curses.h ]; then
yann@2125
    25
		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
yann@2448
    26
	elif [ -f /usr/include/ncursesw/curses.h ]; then
yann@2448
    27
		echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
yann@2125
    28
	elif [ -f /usr/include/ncurses.h ]; then
yann@2125
    29
		echo '-DCURSES_LOC="<ncurses.h>"'
yann@1
    30
	else
yann@2125
    31
		echo '-DCURSES_LOC="<curses.h>"'
yann@1
    32
	fi
yann@1
    33
}
yann@1
    34
yann@1
    35
# Temp file, try to clean up after us
yann@1
    36
tmp=.lxdialog.tmp
yann@1
    37
trap "rm -f $tmp" 0 1 2 3 15
yann@1
    38
yann@1
    39
# Check if we can link to ncurses
yann@1
    40
check() {
yann@2125
    41
        $cc -xc - -o $tmp 2>/dev/null <<'EOF'
yann@1087
    42
#include CURSES_LOC
yann@1087
    43
main() {}
yann@1087
    44
EOF
yann@1087
    45
	if [ $? != 0 ]; then
yann@1087
    46
	    echo " *** Unable to find the ncurses libraries or the"       1>&2
yann@1087
    47
	    echo " *** required header files."                            1>&2
yann@1087
    48
	    echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
yann@1087
    49
	    echo " *** "                                                  1>&2
yann@1087
    50
	    echo " *** Install ncurses (ncurses-devel) and try again."    1>&2
yann@1087
    51
	    echo " *** "                                                  1>&2
yann@1087
    52
	    exit 1
yann@1
    53
	fi
yann@1
    54
}
yann@1
    55
yann@1
    56
usage() {
yann@1229
    57
	printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
yann@1
    58
}
yann@1
    59
yann@706
    60
if [ $# -eq 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