#!/bin/csh -f
#
# Let user know what's going on...
#
set verbose
#
mv -f Makefile Makefile.bak >& /dev/null
#
# Unfortunately, some systems vary where they find imake, imake's config
# files, and/or xmkmf.  You may need to be clever to get Makefiles
# generated if your system is non-standard.  The following tries its best
# to generate the Makefiles for you...
#
if ( -d /usr/lib/X11/config) then
  if ( -x /usr/bin/X11/imake ) then
    # Things are in standard places
    /usr/bin/X11/imake -DUseInstalled -I/usr/lib/X11/config -DTOPDIR=.
  else
    # Hope imake is on your path!
    imake -DUseInstalled -I/usr/lib/X11/config -DTOPDIR=.
  endif
else # Try non-standard places vendor locations
  # Look for IBM's non-standard placement of imake
  if ( -d /usr/lpp/X11/Xamples/config) then
    if ( -x /usr/lpp/X11/Xamples/config/imake ) then
      # Things are in non-standard IBM AIX places
      /usr/lpp/X11/Xamples/config/imake -DUseInstalled -I/usr/lpp/X11/Xamples/config -DTOPDIR=.
    else
      # Hope imake is on your path!
      imake -DUseInstalled -I/usr/lpp/X11/Xamples/config -DTOPDIR=.
    endif
  else
    # Look for Sun's non-standard placement of imake and xmkmf
    if ( -x /usr/openwin/bin/xmkmf ) then
      # Make sure that /usr/openwin/bin is at the front of your
      # path so that you pick up /usr/openwin/bin/imake when 
      # you run /usr/openwin/bin/xmkmf instead of some other
      # imake potentially mismatched with the /usr/openwin/lib/config
      # config files.
      set path = ( /usr/openwin/bin $path )
      /usr/openwin/bin/xmkmf
    else
      # Look for FreeBSD's non-standard placement of imake and xmkmf
      if ( -d /usr/X11R6/lib/X11/config ) then
        if ( -x /usr/X11R6/bin/imake ) then
          # We found FreeBSD's location for imake and xmkmf
          /usr/X11R6/bin/imake -DUseInstalled -I/usr/X11R6/lib/X11/config -DTOPDIR=.
        else
          # Hope imake is on your path!
          imake -DUseInstalled -I/usr/X11R6/lib/X11/config -DTOPDIR=.
        endif
      else
        # Hope xmkmf is on your path!
        xmkmf     
      endif
    endif
  endif
endif
make Makefiles

## man subdirectory is not built by default
## uncomment line below to build its Makefiles
#make SUBDIRS=man Makefiles

make depend
