#!/bin/sh

# Run "xmkmf"
# Since invocation of Sun OpenWindow's "xmkmf" is different from 
# X11R* "xmkmf", we need to check how to invoke it.

# Check if we have OpenWindow.
NO_OPENWIN=1
if test -d /usr/openwin; then 
  NO_OPENWIN=0
  # If OPENWINHOME is not set, we do not use OpenWindow
  if test X-${OPENWINHOME+set} != X-set; then  
    NO_OPENWIN=1
  fi
fi

# In case we have OpenWindow but an "xmkmf" to be executed is not 
# an OpenWindow's "xmkmf", we do not use OpenWindow. 
if test ${NO_OPENWIN} = 0; then 
  if test X-`../whereisit xmkmf` != X-${OPENWINHOME}/bin/xmkmf; then
    NO_OPENWIN=1
  fi
fi

# Run "xmkmf" accroding to the check result.
case ${NO_OPENWIN} in
0)
  echo Use OpenWindow
  echo "Running 'xmkmf $OPENWINHOME/lib .'"
  xmkmf $OPENWINHOME/lib .
  ;;
1)
  echo Use X11.
  echo "Running 'xmkmf -a'"
  xmkmf -a
  ;;
esac
