ia64/xen-unstable

view tools/check/funcs.sh @ 19834:edd603e77be4

tools: fix x11 check

X.org is installed in /usr/X11R7.
Attached patch covers this in the x11 check.
Xen has no direct X11 dependency
(it's inherited from SDL and SDL is optional for qemu-dm)
so warn but don't fail if no X11 is installed.
Fixes build problem on distributions which build their packages (*BSD
and Gentoo).

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 25 12:59:46 2009 +0100 (2009-06-25)
parents 6ba04ec03dec
children
line source
1 # has is the same as which, except it handles cross environments
2 has() {
3 if [ -z "$CROSS_COMPILE" ]; then
4 command which "$@"
5 return $?
6 fi
8 check_sys_root || return 1
10 # subshell to prevent pollution of caller's IFS
11 (
12 IFS=:
13 for p in $PATH; do
14 if [ -x "$CROSS_SYS_ROOT/$p/$1" ]; then
15 echo "$CROSS_SYS_ROOT/$p/$1"
16 return 0
17 fi
18 done
19 return 1
20 )
21 }
23 has_or_fail() {
24 has "$1" >/dev/null || fail "can't find $1"
25 }
27 has_header() {
28 case $1 in
29 /*) ;;
30 *) set -- "/usr/include/$1" ;;
31 esac
33 check_sys_root || return 1
35 test -r "$CROSS_SYS_ROOT$1"
36 return $?
37 }
39 has_lib() {
40 check_sys_root || return 1
42 # subshell to prevent pollution of caller's environment
43 (
44 PATH=/sbin:$PATH # for ldconfig
46 # This relatively common in a sys-root; libs are installed but
47 # ldconfig hasn't run there, so ldconfig -p won't work.
48 if [ "$OS" = Linux -a ! -f "$CROSS_SYS_ROOT/etc/ld.so.cache" ]; then
49 echo "Please run ldconfig -r \"$CROSS_SYS_ROOT\" to generate ld.so.cache"
50 # fall through; ldconfig test below should fail
51 fi
52 ldconfig -p ${CROSS_SYS_ROOT+-r "$CROSS_SYS_ROOT"} | grep -Fq "$1"
53 return $?
54 )
55 }
57 test_link() {
58 # subshell to trap removal of tmpfile
59 (
60 unset tmpfile
61 trap 'rm -f "$tmpfile"; exit' 0 1 2 15
62 tmpfile=`mktemp` || return 1
63 ld "$@" -o "$tmpfile" >/dev/null 2>&1
64 return $?
65 )
66 }
68 # this function is used commonly above
69 check_sys_root() {
70 [ -z "$CROSS_COMPILE" ] && return 0
71 if [ -z "$CROSS_SYS_ROOT" ]; then
72 echo "please set CROSS_SYS_ROOT in the environment"
73 return 1
74 fi
75 if [ ! -d "$CROSS_SYS_ROOT" ]; then
76 echo "no sys-root found at $CROSS_SYS_ROOT"
77 return 1
78 fi
79 }
81 warning() {
82 echo
83 echo " *** `basename "$0"` FAILED${*+: $*}"
84 }
86 fail() {
87 echo
88 echo " *** `basename "$0"` FAILED${*+: $*}"
89 exit 1
90 }