summaryrefslogtreecommitdiffstats
path: root/tqtinterface/qt4/config.tests/x11/xcursor.test
blob: 514e33ca91ac589e1086838431ceece3678d6cbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh

XCURSOR=yes
XCONFIG=$1/qmake.conf
VERBOSE=$2
shift 2
IN_LIBDIRS=""
IN_INCDIRS=""
PARAMS=$@
for PARAM in $PARAMS; do
    PREFIX=`echo $PARAM | sed 's/^\(..\).*/\1/'`
    case $PREFIX in
    -L)
	CLIBDIR=`echo $PARAM | sed -e 's/^-L//'`
	IN_LIBDIRS="$IN_LIBDIRS $CLIBDIR"
	;;
    -I)
        CINCDIR=`echo $PARAM | sed -e 's/^-I//'`
        IN_INCDIRS="$IN_INCDIRS $CINCDIR"
        ;;
    *) ;;
    esac 
done

# debuggery
[ "$VERBOSE" = "yes" ] && echo "Xcursor auto-detection... ($*)"

# check for the Xcursor library
XDIRS=`sed -n -e '/^QMAKE_LIBDIR_X11[	]*=/ { s/[^=]*=[	 ]*//; s/-L/ /g; p; }' $XCONFIG`
LIBDIRS="$IN_LIBDIRS $XDIRS /usr/shlib /usr/lib /lib"
F=
for LIBDIR in $LIBDIRS; do
    FOUND_LIB=`ls $LIBDIR/libXcursor.* 2>/dev/null`
    if [ ! -z "$FOUND_LIB" ]; then
	F=yes
	[ "$VERBOSE" = "yes" ] && echo "  Found Xcursor lib in $LIBDIR"
	break
    fi
done
if [ -z "$F" ]; then
    XCURSOR=no
    [ "$VERBOSE" = "yes" ] && echo "  Could not find Xcursor lib anywhere in $LIBDIRS"
fi
    
# check for Xcursor.h
XCURSOR_H=
if [ "$XCURSOR" = "yes" ]; then
    INC="X11/Xcursor/Xcursor.h"
    XDIRS=`sed -n -e '/^QMAKE_INCDIR_X11[	]*=/ { s/[^=]*=[	 ]*//; s/-I/ /g; p; }' $XCONFIG`
    INCDIRS="$IN_INCDIRS $XDIRS /usr/include /include"
    F=
    for INCDIR in $INCDIRS; do
	if [ -f $INCDIR/$INC ]; then
	    F=yes
	    XCURSOR_H=$INCDIR/$INC
	    [ "$VERBOSE" = "yes" ] && echo "  Found $INC in $INCDIR"
	    break
	fi
    done
    if [ -z "$F" ]
    then
	XCURSOR=no
	[ "$VERBOSE" = "yes" ] && echo "  Could not find $INC anywhere in $INCDIRS"
    fi
fi

# verify that we are using Xcursor 1.x
if [ "$XCURSOR" = "yes" ]; then
    XCURSOR_MAJOR=`egrep 'XCURSOR(_LIB)?_MAJOR' $XCURSOR_H | head -n 1 | awk '{ print \$3 }'`
    XCURSOR_MINOR=`egrep 'XCURSOR(_LIB)?_MINOR' $XCURSOR_H | head -n 1 | awk '{ print \$3 }'`
    if [ -z "$XCURSOR_MAJOR" -o -z "$XCURSOR_MINOR" ]; then
        XCURSOR=no
	[ "$VERBOSE" = "yes" ] && \
	    echo "  Could not find Xcursor version."
    elif [ "$XCURSOR_MAJOR" != "1" ]; then
        XCURSOR=no
	[ "$VERBOSE" = "yes" ] && \
	    echo "  Found Xcursor version $XCURSOR_MAJOR.$XCURSOR_MINOR, version 1.0 or higher required."
    else
	[ "$VERBOSE" = "yes" ] && \
	    echo "  Found Xcursor version $XCURSOR_MAJOR.$XCURSOR_MINOR"	
    fi
fi

# done
if [ "$XCURSOR" != "yes" ]; then
    [ "$VERBOSE" = "yes" ] && echo "Xcursor disabled."
    exit 0
else
    [ "$VERBOSE" = "yes" ] && echo "Xcursor enabled."
    exit 1
fi