PR#5477 use pkg-config to configure graphics on linux

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12110 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Damien Doligez 2012-02-01 21:30:35 +00:00
parent 3a15ca4ea1
commit fd944666c2
1 changed files with 60 additions and 41 deletions

43
configure vendored
View File

@ -1221,9 +1221,21 @@ fi
# Determine the location of X include files and libraries
# If the user specified -x11include and/or -x11lib, these settings
# are used. Otherwise, we check whether there is pkg-config, and take
# the flags from there. Otherwise, we search the location.
x11_include="not found"
x11_link="not found"
if test -z "$x11_include_dir" -a -z "$x11_lib_dir"; then
if pkg-config --exists x11 2>/dev/null; then
x11_include=`pkg-config --cflags x11`
x11_link=`pkg-config --libs x11`
fi
fi
if test "$x11_include" = "not found"; then
for dir in \
$x11_include_dir \
\
@ -1272,7 +1284,8 @@ for dir in \
; \
do
if test -f $dir/X11/X.h; then
x11_include=$dir
x11_include_dir=$dir
x11_include="-I$dir"
break
fi
done
@ -1280,7 +1293,7 @@ done
if test "$x11_include" = "not found"; then
x11_try_lib_dir=''
else
x11_try_lib_dir=`echo $x11_include | sed -e 's|include|lib|'`
x11_try_lib_dir=`echo $x11_include_dir | sed -e 's|include|lib|'`
fi
for dir in \
@ -1326,9 +1339,6 @@ for dir in \
\
/usr/openwin/lib \
/usr/openwin/share/lib \
\
/usr/lib/i386-linux-gnu \
/usr/lib/x86_64-linux-gnu \
; \
do
if test -f $dir/libX11.a || \
@ -1349,21 +1359,30 @@ do
break
fi
done
fi
if test "x11_include" != "not found"; then
if test "$x11_include" = "-I/usr/include"; then
x11_include=""
fi
if ./hasgot $x11_include $x11_link -i X11/Xlib.h XrmInitialize; then
echo "X11 works"
else
echo "Cannot compile X11 program"
x11_include="not found"
fi
fi
if test "$x11_include" = "not found" || test "$x11_link" = "not found"
then
echo "X11 not found, the \"graph\" library will not be supported."
x11_include=""
x11_include="n/a"
x11_link="n/a"
else
echo "Location of X11 include files: $x11_include/X11"
echo "Options for compiling for X11: $x11_include"
echo "Options for linking with X11: $x11_link"
otherlibraries="$otherlibraries graph"
if test "$x11_include" = "/usr/include"; then
x11_include=""
else
x11_include="-I$x11_include"
fi
fi
echo "X11_INCLUDES=$x11_include" >> Makefile
echo "X11_LINK=$x11_link" >> Makefile