tdir=$osname-$arch-X11$$
mkdir $tdir; cp Imakefile $tdir; cd $tdir
cmd="xmkmf"; . ../log_cmd
if test -f Makefile; then
  eval `make gp-X11 >&5 2>&1 | grep -v make`
  x11pth="$usrlibdir $libdir";
fi
cd ..; rm -rf $tdir

# Check xmkmf answer
# X11 -- Headers
if test ! -f $Xincroot/X11/Xos.h; then
  x11pth="$addlib64\
    /usr/openwin/share/lib\
    /usr/openwin/lib\
    /usr/X11R6/lib       /usr/X11R5/lib       /usr/X11R4/lib\
    /usr/lib/X11R6       /usr/lib/X11R5       /usr/lib/X11R4\
    /usr/local/X11R6/lib /usr/local/X11R5/lib /usr/local/X11R4/lib\
    /usr/local/lib/X11R6 /usr/local/lib/X11R5 /usr/local/lib/X11R4\
    /usr/X11/lib\
    /usr/lib/X11\
    /usr/local/X11/lib\
    /usr/local/lib/X11\
    /usr/XFree86/lib/X11\
    /usr/lib\
    /usr/local/lib\
    /usr/athena/lib\
  ";
  pth=`echo $x11pth | sed 's,/lib,/include,g'`
  x=`./locate X11/Xos.h '' $pth`
  case $x in
   /*) Xincroot=`echo $x | sed 's,/X11/Xos.h,,'`;;
   *)  Xincroot=;;
  esac
fi
if test -f $Xincroot/X11/Xos.h; then
  echo ..."Found X11 header files in $Xincroot/X11"
  X11_INC="-I$Xincroot"
fi
# X11 -- Lib
pth=$x11pth
lib=X11; . ./locatelib
if test -n "$X11"; then
  X11_LIBS="-L$X11 -lX11 $extralib"
else
  exe=$osname-$arch-X11$$
  cmd="$CC $CFLAGS $extraflag $X11_INC -o $exe has_X11.c -lX11 $extralib"
  . log_cmd
  if test -r $exe; then
    X11_LIBS="-lX11 $extralib"
  else
    echo "### X11 not found"
    X11_LIBS=
    X11_INC=
  fi
fi
rm -f $exe $exe$exe_suff;
echo ..."X11 libraries: $X11_LIBS"
