summaryrefslogtreecommitdiffstats
path: root/tqtinterface/qt4/config.tests/x11/opengl.test
blob: 463df620c44c2220543f3b5fb9fa82266418d353 (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
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh

OPENGL=yes
XCONFIG=$1/qmake.conf
THREAD=$2
VERBOSE=$3
shift 3
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 "OpenGL auto-detection... ($*)"

# check for lib
LIBS=`sed -n -e '/^QMAKE_LIBS_OPENGL[	 ]*=/ { s/[^=]*=[	 ]*//; s/-l/ /g; p; }' $XCONFIG`
GLDIRS=`sed -n -e '/^QMAKE_LIBDIR_OPENGL[	 ]*=/ { s/[^=]*=[	 ]*//; p; }' $XCONFIG`
XDIRS=`sed -n -e '/^QMAKE_LIBDIR_X11[	 ]*=/ { s/[^=]*=[	 ]*//; p; }' $XCONFIG`
LIBDIRS="$IN_LIBDIRS $GLDIRS $XDIRS /usr/shlib /usr/lib /lib"
for L in $LIBS; do
    FOUND_LIB=
    F=
    for LIBDIR in $LIBDIRS; do
	FOUND_LIB=`ls $LIBDIR/lib$L.* 2>/dev/null`
	if [ ! -z "$FOUND_LIB" ]; then
	    F=yes
	    [ "$VERBOSE" = "yes" ] && echo "  Found $L lib in $LIBDIR"
	    break
	fi
    done
    if [ ! -z "$FOUND_LIB" -a  ! "x$THREAD" = "xyes" -a ! -z "$F" ]; then
	LDD_P=`which ldd 2>/dev/null`
	if [ ! -z "$LDD_P" ]; then
	    for a in $FOUND_LIB; do
		if $LDD_P $a 2>/dev/null | grep -i thread >/dev/null 2>&1; then
		    FOUND_LIB=$a
		    F_REASON="threads"
		    F=
		    break
		fi
	    done
	fi
    fi
    if [ -z "$F" ]; then
	OPENGL=no
	if [ "x$F_REASON" = "xthreads" ]; then
	   echo
	   echo "WARNING: $FOUND_LIB is threaded!"
	   echo "The Qt OpenGL module requires Qt to be configured with -thread."
	   echo
	else
	   [ "$VERBOSE" = "yes" ] && echo "  Could not tqfind $L lib anywhere in $LIBDIRS"
	fi
	break
    fi
done

# check for headers
if [ "$OPENGL" = "yes" ]; then
    INCS="GL/gl.h GL/glu.h"
    GLDIRS=`sed -n -e '/^QMAKE_INCDIR_OPENGL[	 ]*=/ { s/[^=]*=[	 ]*//; p; }' $XCONFIG`
    XDIRS=`sed -n -e '/^QMAKE_INCDIR_X11[	]*=/ { s/[^=]*=[	 ]*//; p; }' $XCONFIG`
    INCDIRS="$IN_INCDIRS $GLDIRS $XDIRS /usr/include /include"

    for I in $INCS; do
	F=
	for INCDIR in $INCDIRS; do
	    if [ -f $INCDIR/$I ]; then
		F=yes
		[ "$VERBOSE" = "yes" ] && echo "  Found $I in $INCDIR"
		break
	    fi
	done
	if [ -z "$F" ]; then
	    OPENGL=no
	    [ "$VERBOSE" = "yes" ] && echo "  Could not tqfind $I anywhere in $INCDIRS"
	    break
	fi
    done
fi

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