dnl Process this file with autoconf to produce a configure script.
dnl configure.ac for xpuzzles.
AC_INIT([xmball],[m4_esyscmd(grep VERSION version.h | cut -f2 -d\" | tr -d '\n')],[bagleyd AT verizon.net])
AC_SUBST([PACKAGE_NAME])dnl

dnl Checks for programs.
AC_ARG_WITH(gcc,
[  --with-gcc              use GCC to compile])
dnl AC_ARG_WITH(debug,
dnl [  --with-debug            compile with -g, if no optimize])

test -n "$CC" && cc_specified=yes
case ${with_gcc} in
  yes ) CC=gcc ;;
dnl yes ) CC=g++ ;;
  no  ) CC=cc ;;
  *   ) AC_PROG_CC;;
dnl  *   ) AC_PROG_CXX ;;
esac

dnl case ${with_debug} in
dnl   yes ) CFLAGS="${CFLAGS} -g" ;;
dnl   no ) CFLAGS="${CFLAGS} -O" ;;
dnl esac

if test "${CC}" = "clang" -o "${CC}" = "clang++" -o "${CC}" = "g++" ; then
  CFLAGS="-g -Wall"
fi
if test "${CC}" = "gcc" ; then
  CFLAGS="${CFLAGS} -Wall -Wstrict-prototypes -Wnested-externs -Wmissing-prototypes -Wno-overlength-strings -Wdeclaration-after-statement -U__STRICT_ANSI__"
dnl include files may not support this: -std=c89
fi

AC_PROG_LN_S
AC_PROG_CPP
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_INSTALL
dnl Optional features.
dnl add copious amounts of debugging with gcc

dnl Checks for header files.
dnl AC_CHECK_HEADERS(poll.h sys/poll.h)
AC_CHECK_HEADERS(fcntl.h sys/select.h sys/time.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

srand=no
AC_CHECK_FUNC(srand48,
  [AC_DEFINE([HAVE_RAND48], [1], [Random Number Generator using 48 bits is available])
   AC_MSG_CHECKING([for srand48 declaration])
   AC_EGREP_HEADER(srand48, stdlib.h,
     AC_DEFINE([DECLARED_SRAND48], [1], [Declared SRAND48 is available])
       AC_MSG_RESULT(yes),
     AC_MSG_RESULT(no))])
  if test $ac_cv_func_srand48 = no; then
    AC_CHECK_FUNC(srandom, AC_DEFINE([HAVE_RANDOM], [1], [Random Number Generator using 32 bits is available]))
    if test $ac_cv_func_srandom = no; then
      AC_CHECK_FUNC(srand, AC_DEFINE([HAVE_RAND], [1], [Low quality Random Number Generator using 32 bits is available])
        srand=yes)
dnl       AC_DEFINE(MAXRAND,32768.0) except on AIXV3
    fi
dnl     else
dnl       AC_DEFINE(MAXRAND,2147483648.0)
dnl   else
dnl     AC_DEFINE(MAXRAND,2147483648.0)
  fi

dnl Rather have a usleep
AC_CHECK_FUNC(usleep, AC_DEFINE([HAVE_USLEEP], [1], [microsecond sleep is available]))
if test $ac_cv_func_usleep = no; then
AC_CHECK_FUNC(nanosleep, AC_DEFINE([HAVE_NANOSLEEP], [1], [nanosecond sleep is available]))
fi

AC_ARG_ENABLE(constpixmaps, [  --enable-constpixmaps   g++ build with make constpixmaps; make],
  constpixmaps=$enableval,
  constpixmaps=no)
if test "$constpixmaps" = "yes"; then
  AC_MSG_RESULT([enabling constpixmaps])
  CFLAGS="${CFLAGS} -DCONSTPIXMAPS"
fi

dnl Checks for library functions.
dnl AC_CHECK_FUNCS(select)
AC_CHECK_FUNCS(snprintf)

dnl X Window System files.
AC_PATH_XTRA
if test "$no_x" = yes; then
  XLIBS=NONE
else
  if test -n "${x_includes}"; then
    XWIDGETINC="-I${x_includes} ${XWIDGETINC}"
dnl    if test "${CC}" = "gcc" ; then
   dnl   Do not warn me about anything here
dnl      XWIDGETINC="-isystem ${x_includes} ${XWIDGETINC}"
dnl    fi
  fi
  XLIBS="${x_libraries}"
  if test -n "${x_libraries}"; then
    XWIDGET_LDFLAGS="/usr/lib:${x_libraries}"
    XWIDGETLIBPATHS="-L${x_libraries} ${XWIDGETLIBPATHS}"
  fi
  LIBS="${X_PRE_LIBS} -lXt -lX11 ${X_EXTRA_LIBS} ${LIBS}"
fi

# Try and find the app-defaults directory.
AC_DEFUN([AC_PATH_X_APP_DEFAULTS_XMKMF],
  [
  rm -fr conftestdir
  if mkdir conftestdir; then
    cd conftestdir
    # Make sure to not put "make" in the Imakefile rules, since we grep it out.
    cat > Imakefile <<'EOF'
acfindx:
  @echo 'ac_x_app_defaults="${XAPPLOADDIR}"'
EOF
    if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
      # GNU make sometimes prints "make[1]: Entering...", which'd confuse us.
      eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
    fi
    cd ..
    rm -fr conftestdir
  fi])

AC_DEFUN([AC_PATH_X_APP_DEFAULTS_DIRECT],
[  # Look for the directory under a standard set of common directories.
  # Check X11 before X11Rn because it's often a symlink to the current release.
  for ac_dir in         \
    /lib/X11/app-defaults \
    /lib/app-defaults \
    /lib/X11R6/app-defaults \
    /lib/X11R6/X11/app-defaults \
    /lib/X11R5/app-defaults \
    /lib/X11R5/X11/app-defaults \
    /lib/X11R4/app-defaults \
    /lib/X11R4/X11/app-defaults \
    ; \
  do
    found=""
    if test -d "${prefix}$ac_dir"; then
      ac_x_app_defaults=\\\$\\\{prefix\\\}$ac_dir
    found="1"
      break
    fi
  done
  if test -z "$found"; then
  for ac_dir in         \
    /usr/X11/lib/app-defaults     \
    /usr/X11R6/lib/app-defaults     \
    /usr/X11R6/lib/X11/app-defaults   \
    /usr/X11R5/lib/app-defaults     \
    /usr/X11R5/lib/X11/app-defaults   \
    /usr/X11R4/lib/app-defaults     \
    /usr/X11R4/lib/X11/app-defaults   \
            \
    /usr/lib/X11/app-defaults     \
    /usr/lib/X11R6/app-defaults     \
    /usr/lib/X11R5/app-defaults     \
    /usr/lib/X11R4/app-defaults     \
            \
    /usr/local/X11/lib/app-defaults   \
    /usr/remote/X11/lib/app-defaults   \
    /usr/local/X11R6/lib/app-defaults   \
    /usr/local/X11R6/lib/X11/app-defaults   \
    /usr/local/X11R5/lib/app-defaults   \
    /usr/local/X11R5/lib/X11/app-defaults   \
    /usr/local/X11R4/lib/app-defaults   \
    /usr/local/X11R4/lib/X11/app-defaults   \
            \
    /usr/local/lib/X11/app-defaults   \
    /usr/remote/lib/X11/app-defaults   \
    /usr/local/lib/X11R6/app-defaults   \
    /usr/local/lib/X11R6/X11/app-defaults \
    /usr/local/lib/X11R5/app-defaults   \
    /usr/local/lib/X11R5/X11/app-defaults \
    /usr/local/lib/X11R4/app-defaults   \
    /usr/local/lib/X11R4/X11/app-defaults \
            \
    /usr/X386/lib/X11/app-defaults    \
    /usr/x386/lib/X11/app-defaults    \
    /usr/XFree86/lib/X11/app-defaults   \
            \
    /usr/lib/X11/app-defaults     \
    /usr/unsupported/lib/X11/app-defaults \
    /usr/athena/lib/X11/app-defaults    \
    /usr/local/x11r5/lib/X11/app-defaults \
    /usr/lpp/Xamples/lib/X11/app-defaults \
    /lib/usr/lib/X11/app-defaults   \
    /usr/local/lib/app-defaults   \
    /usr/remote/lib/app-defaults   \
            \
    /usr/openwin/lib/app-defaults   \
    /usr/openwin/lib/X11/app-defaults   \
    /usr/openwin/share/lib/app-defaults   \
    /usr/openwin/share/lib/X11/app-defaults \
            \
    /X11R6/lib/app-defaults     \
    /X11R5/lib/app-defaults     \
    /X11R4/lib/app-defaults     \
    ; \
  do
    if test -d "$ac_dir"; then
      ac_x_app_defaults=$ac_dir
      break
    fi
  done
    fi
])

AC_DEFUN([AC_PATH_X_APP_DEFAULTS],
  [AC_REQUIRE_CPP()
    AC_CACHE_CHECK([for X app-defaults directory], ac_cv_x_app_defaults,
     [AC_PATH_X_APP_DEFAULTS_XMKMF
      AC_PATH_X_APP_DEFAULTS_DIRECT
      if test x"$ac_x_app_defaults" = x; then
        ac_cv_x_app_defaults="/usr/lib/X11/app-defaults"
      else
        # Record where we found app-defaults for the cache.
        ac_cv_x_app_defaults="$ac_x_app_defaults"
      fi])
    eval ac_x_app_defaults="$ac_cv_x_app_defaults"])

AC_PATH_X_APP_DEFAULTS
APPDEFAULTS=$ac_x_app_defaults

AC_ARG_WITH(includes, [  --with-includes=DIR     search include DIR for optional packages below])
case "x$withval" in
x/*|x.*)
  extra_include=$withval
  AC_MSG_RESULT([adding $extra_include to include search path for following packages ])
  if test ! -d $extra_include; then
    AC_MSG_RESULT([Warning: Directory $extra_include does not exist])
  fi
  ;;
*)
  extra_include=""
  ;;
esac

AC_ARG_WITH(libraries, [  --with-libraries=DIR    search library DIR for optional packages below])
case "x$withval" in
x/*|x.*)
  extra_lib=$withval
  AC_MSG_RESULT([adding $extra_lib to library search path for following packages])
  if test ! -d $extra_lib; then
    AC_MSG_RESULT([Warning: Directory $extra_lib does not exist])
  fi
  ;;
*)
  extra_lib=""
  ;;
esac

dnl Xmu XMU EDITRES Editres editres

AC_DEFUN([AC_PATH_EDITRES_DIRECT],
[test -z "$editres_direct_test_library" && editres_direct_test_library=Xmu
test -z "$editres_direct_test_function" && editres_direct_test_function=_XEditResCheckMessages
test -z "$editres_direct_test_include" && editres_direct_test_include=X11/Xmu/Editres.h
  for ac_dir in               \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11R4/include        \
    /usr/X11/include          \
                              \
    /usr/include/X11          \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
    /usr/include/X11R4        \
                              \
    /usr/local/X11/include    \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
    /usr/local/X11R4/include  \
                              \
    /usr/local/include/X11    \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
    /usr/local/include/X11R4  \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include      \
                              \
    /usr/local/include        \
    /usr/remote/include       \
    /usr/include              \
    /usr/unsupported/include  \
    /usr/athena/include       \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
                              \
    /usr/openwin/include      \
    /usr/openwin/share/include \
    $extra_include            \
    ; \
  do
    if test -r "$ac_dir/$editres_direct_test_include"; then
      no_editres= ac_editres_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$editres_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_editres_includes" | sed s/include/lib/` \
                          \
    /usr/X11/lib          \
    /usr/X11R6/lib        \
    /usr/X11R5/lib        \
    /usr/X11R4/lib        \
                          \
    /usr/lib/X11          \
    /usr/lib/X11R6        \
    /usr/lib/X11R5        \
    /usr/lib/X11R4        \
                          \
    /usr/local/X11/lib    \
    /usr/local/X11R6/lib  \
    /usr/local/X11R5/lib  \
    /usr/local/X11R4/lib  \
                          \
    /usr/local/lib/X11    \
    /usr/local/lib/X11R6  \
    /usr/local/lib/X11R5  \
    /usr/local/lib/X11R4  \
                          \
    /usr/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/remote/lib       \
    /usr/unsupported/lib  \
    /usr/athena/lib       \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    /lib/usr/lib/X11      \
                          \
    /usr/openwin/lib      \
    /usr/openwin/share/lib \
    $extra_lib            \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${editres_direct_test_library}.$ac_extension; then
      no_editres= ac_editres_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_EDITRES],
[AC_REQUIRE_CPP()dnl

editres_includes=NONE
editres_libraries=NONE

AC_MSG_CHECKING(for Editres)
AC_ARG_WITH(editres, [  --without-editres          disable debugger for XIntrinsics])
if test "x$with_editres" = xno; then
  no_editres=yes
else
  if test "x$editres_includes" != xNONE && test "x$editres_libraries" != xNONE; then
    no_editres=
  else
AC_CACHE_VAL(ac_cv_path_editres,
[# One or both of these vars are not set, and there is no cached value.
no_editres=yes
AC_PATH_EDITRES_DIRECT

if test "$no_editres" = yes; then
  ac_cv_path_editres="no_editres=yes"
else
  ac_cv_path_editres="no_editres= ac_editres_includes=$ac_editres_includes ac_editres_libraries=$ac_editres_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_editres"
fi # with_editres != no

if test "$no_editres" = yes; then
  AC_MSG_RESULT(no)
else
  AC_DEFINE([USE_XMU], [1], [using X11 Miscellaneous Utilities])
  LIBS="-lXmu ${LIBS}"
  test "x$editres_includes" = xNONE && editres_includes=$ac_editres_includes
  test "x$editres_libraries" = xNONE && editres_libraries=$ac_editres_libraries
  ac_cv_path_editres="no_editres= ac_editres_includes=$editres_includes ac_editres_libraries=$editres_libraries"
  AC_MSG_RESULT([libraries $editres_libraries, headers $editres_includes])
fi
])

AC_PATH_EDITRES

if test "x$editres_libraries" != x ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$editres_libraries"
  XWIDGETLIBPATHS="-L$editres_libraries ${XWIDGETLIBPATHS}"
fi
if test "x$editres_includes" != x ; then
  XWIDGETINC="${XWIDGETINC} -I$editres_includes"
fi

dnl Xm MOTIF Motif motif

AC_DEFUN([AC_PATH_MOTIF_DIRECT],
[test -z "$motif_direct_test_library" && motif_direct_test_library=Xm
test -z "$motif_direct_test_function" && motif_direct_test_function=XmCreatePushButton
test -z "$motif_direct_test_include" && motif_direct_test_include=Xm/Xm.h
  for ac_dir in               \
    /usr/include/Motif1.2     \
    /usr/Motif1.2/include     \
                              \
    /usr/motif/include        \
                              \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11R4/include        \
                              \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
    /usr/include/X11R4        \
                              \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
    /usr/local/X11R4/include  \
                              \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
    /usr/local/include/X11R4  \
                              \
    /usr/X11/include          \
    /usr/include/X11          \
    /usr/local/X11/include    \
    /usr/local/include/X11    \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/dt/include           \
                              \
    /usr/local/include        \
    /usr/remote/include       \
    /usr/include              \
    /usr/unsupported/include  \
    /usr/athena/include       \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
    $extra_include            \
    ; \
  do
    if test -r "$ac_dir/$motif_direct_test_include"; then
      no_motif= ac_motif_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$motif_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_motif_includes" | sed s/include/lib/` \
    /usr/lib/Motif1.2     \
    /usr/Motif1.2/lib     \
                          \
    /usr/motif/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/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/remote/lib       \
    /usr/unsupported/lib  \
    /usr/athena/lib       \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    $extra_lib            \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${motif_direct_test_library}.$ac_extension; then
      no_motif= ac_motif_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_MOTIF],
[AC_REQUIRE_CPP()dnl

motif_includes=NONE
motif_libraries=NONE

AC_MSG_CHECKING(for Motif)
AC_ARG_WITH(motif, [  --without-motif         disable Motif])
if test "x$with_motif" = xno; then
  no_motif=yes
else
  if test "x$motif_includes" != xNONE && test "x$motif_libraries" != xNONE; then
    no_motif=
  else
AC_CACHE_VAL(ac_cv_path_motif,
[# One or both of these vars are not set, and there is no cached value.
no_motif=yes
AC_PATH_MOTIF_DIRECT

if test "$no_motif" = yes; then
  ac_cv_path_motif="no_motif=yes"
else
  ac_cv_path_motif="no_motif= ac_motif_includes=$ac_motif_includes ac_motif_libraries=$ac_motif_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_motif"
fi # with_motif != no

if test "$no_motif" = yes; then
  AC_MSG_RESULT(no)
else
  AC_DEFINE([HAVE_MOTIF], [1], [Motif is available])
  LIBS="-lXm ${LIBS}"
  test "x$motif_includes" = xNONE && motif_includes=$ac_motif_includes
  test "x$motif_libraries" = xNONE && motif_libraries=$ac_motif_libraries
  ac_cv_path_motif="no_motif= ac_motif_includes=$motif_includes ac_motif_libraries=$motif_libraries"
  AC_MSG_RESULT([libraries $motif_libraries, headers $motif_includes])
fi
])

AC_PATH_MOTIF

if test "x$motif_libraries" != x ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$motif_libraries"
  XWIDGETLIBPATHS="-L$motif_libraries ${XWIDGETLIBPATHS}"
fi
if test "x$motif_includes" != x ; then
  XWIDGETINC="${XWIDGETINC} -I$motif_includes"
fi

XM_PREFIX=
AC_ARG_ENABLE(xm_prefix, [  --enable-xm-prefix      install binary with an xm prefix (instead of an x)],
  xm_prefix=$enableval,
  xm_prefix=no)
if test "$xm_prefix" = "yes"; then
  AC_MSG_RESULT([enabling xm-prefix])
  XM_PREFIX=m
fi

dnl Athena ATHENA athena

AC_ARG_WITH(athena, [  --without-athena        disable Athena (all Xaw libs)])
if test "x$with_athena" = xno; then
  with_xaw3dxft=no
  with_xaw3d=no
  with_nextaw=no
  with_xaw=no
fi

dnl Xaw3dxft XAW3DXFT xaw3dxft

AC_DEFUN([AC_PATH_XAW3DXFT_DIRECT],
[test -z "$xaw3dxft_direct_test_library" && xaw3dxft_direct_test_library=Xaw3dxft
test -z "$xaw3dxft_direct_test_function" && xaw3dxft_direct_test_function=XawDialGetValueString
test -z "$xaw3dxft_direct_test_include" && xaw3dxft_direct_test_include=X11/Xaw3dxft/Command.h
  for ac_dir in               \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11R4/include        \
                              \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
    /usr/include/X11R4        \
                              \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
    /usr/local/X11R4/include  \
                              \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
    /usr/local/include/X11R4  \
                              \
    /usr/X11/include          \
    /usr/include/X11          \
    /usr/local/X11/include    \
    /usr/local/include/X11    \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/dt/include           \
                              \
    /usr/local/include        \
    /usr/remote/include       \
    /usr/include              \
    /usr/unsupported/include  \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
    $extra_include            \
    ; \
  do
    if test -r "$ac_dir/$xaw3dxft_direct_test_include"; then
      no_xaw3dxft= ac_xaw3dxft_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$xaw3dxft_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_xaw3dxft_includes" | sed s/include/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/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/remote/lib       \
    /usr/unsupported/lib  \
    /usr/xaw3dxft/lib       \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    $extra_lib            \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${xaw3dxft_direct_test_library}.$ac_extension; then
      no_xaw3dxft= ac_xaw3dxft_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_XAW3DXFT],
[AC_REQUIRE_CPP()dnl

xaw3dxft_includes=NONE
xaw3dxft_libraries=NONE

AC_MSG_CHECKING(for Xaw3dxft)
AC_ARG_WITH(xaw3dxft, [  --without-xaw3dxft      disable Xaw3dxft])
if test "x$with_xaw3dxft" = xno; then
  no_xaw3dxft=yes
else
  if test "x$xaw3dxft_includes" != xNONE && test "x$xaw3dxft_libraries" != xNONE; then
    no_xaw3dxft=
  else
AC_CACHE_VAL(ac_cv_path_xaw3dxft,
[# One or both of these vars are not set, and there is no cached value.
no_xaw3dxft=yes
AC_PATH_XAW3DXFT_DIRECT

if test "$no_xaw3dxft" = yes; then
  ac_cv_path_xaw3dxft="no_xaw3dxft=yes"
else
  ac_cv_path_xaw3dxft="no_xaw3dxft= ac_xaw3dxft_includes=$ac_xaw3dxft_includes ac_xaw3dxft_libraries=$ac_xaw3dxft_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_xaw3dxft"
fi # with_xaw3dxft != no

if test "$no_motif" = yes; then
  if test "$no_xaw3dxft" = yes; then
    AC_MSG_RESULT(no)
  else
    AC_DEFINE([HAVE_ATHENA], [1], [Athena is available])
    AC_DEFINE([HAVE_LIB_XAW3DXFT], [1], [Xaw3dxft is available])
    LIBS="-lXaw3dxft ${LIBS}"
    test "x$xaw3dxft_includes" = xNONE && xaw3dxft_includes=$ac_xaw3dxft_includes
    test "x$xaw3dxft_libraries" = xNONE && xaw3dxft_libraries=$ac_xaw3dxft_libraries
    ac_cv_path_xaw3dxft="no_xaw3dxft= ac_xaw3dxft_includes=$xaw3dxft_includes ac_xaw3dxft_libraries=$xaw3dxft_libraries"
    AC_MSG_RESULT([libraries $xaw3dxft_libraries, headers $xaw3dxft_includes])
  fi
else
  AC_MSG_RESULT(ignored - using Motif)
fi
])

AC_PATH_XAW3DXFT

if test "x$xaw3dxft_libraries" != x ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$xaw3dxft_libraries"
  XWIDGETLIBPATHS="-L$xaw3dxft_libraries ${XWIDGETLIBPATHS}"
fi
if test "x$xaw3dxft_includes" != x ; then
  XWIDGETINC="${XWIDGETINC} -I$xaw3dxft_includes"
fi

dnl Xaw3d XAW3D xaw3d

AC_DEFUN([AC_PATH_XAW3D_DIRECT],
[test -z "$xaw3d_direct_test_library" && xaw3d_direct_test_library=Xaw3d
test -z "$xaw3d_direct_test_function" && xaw3d_direct_test_function=XawDialGetValueString
test -z "$xaw3d_direct_test_include" && xaw3d_direct_test_include=X11/Xaw3d/Command.h
  for ac_dir in               \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11R4/include        \
                              \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
    /usr/include/X11R4        \
                              \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
    /usr/local/X11R4/include  \
                              \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
    /usr/local/include/X11R4  \
                              \
    /usr/X11/include          \
    /usr/include/X11          \
    /usr/local/X11/include    \
    /usr/local/include/X11    \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/dt/include           \
                              \
    /usr/local/include        \
    /usr/remote/include       \
    /usr/include              \
    /usr/unsupported/include  \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
    $extra_include            \
    ; \
  do
    if test -r "$ac_dir/$xaw3d_direct_test_include"; then
      no_xaw3d= ac_xaw3d_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$xaw3d_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_xaw3d_includes" | sed s/include/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/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/remote/lib       \
    /usr/unsupported/lib  \
    /usr/xaw3d/lib       \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    $extra_lib            \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${xaw3d_direct_test_library}.$ac_extension; then
      no_xaw3d= ac_xaw3d_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_XAW3D],
[AC_REQUIRE_CPP()dnl

xaw3d_includes=NONE
xaw3d_libraries=NONE

AC_MSG_CHECKING(for Xaw3d)
AC_ARG_WITH(xaw3d, [  --without-xaw3d         disable Xaw3d])
if test "x$with_xaw3d" = xno; then
  no_xaw3d=yes
else
  if test "x$xaw3d_includes" != xNONE && test "x$xaw3d_libraries" != xNONE; then
    no_xaw3d=
  else
AC_CACHE_VAL(ac_cv_path_xaw3d,
[# One or both of these vars are not set, and there is no cached value.
no_xaw3d=yes
AC_PATH_XAW3D_DIRECT

if test "$no_xaw3d" = yes; then
  ac_cv_path_xaw3d="no_xaw3d=yes"
else
  ac_cv_path_xaw3d="no_xaw3d= ac_xaw3d_includes=$ac_xaw3d_includes ac_xaw3d_libraries=$ac_xaw3d_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_xaw3d"
fi # with_xaw3d != no

if test "$no_motif" = yes; then
  if test "$no_xaw3dxft" = yes; then
    if test "$no_xaw3d" = yes; then
      AC_MSG_RESULT(no)
    else
      AC_DEFINE([HAVE_ATHENA], [1], [Athena is available])
      AC_DEFINE([HAVE_LIB_XAW3D], [1], [Xaw3d is available])
      LIBS="-lXaw3d ${LIBS}"
      test "x$xaw3d_includes" = xNONE && xaw3d_includes=$ac_xaw3d_includes
      test "x$xaw3d_libraries" = xNONE && xaw3d_libraries=$ac_xaw3d_libraries
      ac_cv_path_xaw3d="no_xaw3d= ac_xaw3d_includes=$xaw3d_includes ac_xaw3d_libraries=$xaw3d_libraries"
      AC_MSG_RESULT([libraries $xaw3d_libraries, headers $xaw3d_includes])
    fi
  else
    AC_MSG_RESULT(ignored - using Xaw3dxft)
  fi
else
  AC_MSG_RESULT(ignored - using Motif)
fi
])

AC_PATH_XAW3D

if test "x$xaw3d_libraries" != x ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$xaw3d_libraries"
  XWIDGETLIBPATHS="-L$xaw3d_libraries ${XWIDGETLIBPATHS}"
fi
if test "x$xaw3d_includes" != x ; then
  XWIDGETINC="${XWIDGETINC} -I$xaw3d_includes"
fi

dnl neXtaw NEXTAW nextaw

AC_DEFUN([AC_PATH_NEXTAW_DIRECT],
[test -z "$nextaw_direct_test_library" && nextaw_direct_test_library=neXtaw
test -z "$nextaw_direct_test_function" && nextaw_direct_test_function=XawDialGetValueString
test -z "$nextaw_direct_test_include" && nextaw_direct_test_include=X11/neXtaw/Command.h
  for ac_dir in               \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11R4/include        \
                              \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
    /usr/include/X11R4        \
                              \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
    /usr/local/X11R4/include  \
                              \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
    /usr/local/include/X11R4  \
                              \
    /usr/X11/include          \
    /usr/include/X11          \
    /usr/local/X11/include    \
    /usr/local/include/X11    \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/dt/include           \
                              \
    /usr/local/include        \
    /usr/remote/include       \
    /usr/include              \
    /usr/unsupported/include  \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
    $extra_include            \
    ; \
  do
    if test -r "$ac_dir/$nextaw_direct_test_include"; then
      no_nextaw= ac_nextaw_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$nextaw_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_nextaw_includes" | sed s/include/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/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/remote/lib       \
    /usr/unsupported/lib  \
    /usr/nextaw/lib       \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    $extra_lib            \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${nextaw_direct_test_library}.$ac_extension; then
      no_nextaw= ac_nextaw_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_NEXTAW],
[AC_REQUIRE_CPP()dnl

nextaw_includes=NONE
nextaw_libraries=NONE

AC_MSG_CHECKING(for neXtaw)
AC_ARG_WITH(nextaw, [  --without-nextaw        disable neXtaw])
if test "x$with_nextaw" = xno; then
  no_nextaw=yes
else
  if test "x$nextaw_includes" != xNONE && test "x$nextaw_libraries" != xNONE; then
    no_nextaw=
  else
AC_CACHE_VAL(ac_cv_path_nextaw,
[# One or both of these vars are not set, and there is no cached value.
no_nextaw=yes
AC_PATH_NEXTAW_DIRECT

if test "$no_nextaw" = yes; then
  ac_cv_path_nextaw="no_nextaw=yes"
else
  ac_cv_path_nextaw="no_nextaw= ac_nextaw_includes=$ac_nextaw_includes ac_nextaw_libraries=$ac_nextaw_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_nextaw"
fi # with_nextaw != no

if test "$no_motif" = yes; then
  if test "$no_xaw3dxft" = yes; then
    if test "$no_xaw3d" = yes; then
      if test "$no_editres" = yes; then
        no_nextaw=yes
        AC_MSG_RESULT(ignored - requires editres)
      else
        if test "$no_nextaw" = yes; then
          AC_MSG_RESULT(no)
        else
          AC_DEFINE([HAVE_ATHENA], [1], [Athena is available])
          AC_DEFINE([HAVE_LIB_NEXTAW], [1], [neXtaw is available])
          LIBS="-lneXtaw ${LIBS}"
          test "x$nextaw_includes" = xNONE && nextaw_includes=$ac_nextaw_includes
          test "x$nextaw_libraries" = xNONE && nextaw_libraries=$ac_nextaw_libraries
          ac_cv_path_nextaw="no_nextaw= ac_nextaw_includes=$nextaw_includes ac_nextaw_libraries=$nextaw_libraries"
          AC_MSG_RESULT([libraries $nextaw_libraries, headers $nextaw_includes])
        fi
      fi
    else
      AC_MSG_RESULT(ignored - using Xaw3d)
    fi
  else
    AC_MSG_RESULT(ignored - using Xaw3dxft)
  fi
else
  AC_MSG_RESULT(ignored - using Motif)
fi
])

AC_PATH_NEXTAW

if test "x$nextaw_libraries" != x ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$nextaw_libraries"
  XWIDGETLIBPATHS="-L$nextaw_libraries ${XWIDGETLIBPATHS}"
fi
if test "x$xaw3d_includes" != x ; then
  XWIDGETINC="${XWIDGETINC} -I$nextaw_includes"
fi

dnl XawPlus XAWPLUS xawplus

AC_DEFUN([AC_PATH_XAWPLUS_DIRECT],
[test -z "$xawplus_direct_test_library" && xawplus_direct_test_library=XawPlus
test -z "$xawplus_direct_test_function" && xawplus_direct_test_function=XawDialGetValueString
test -z "$xawplus_direct_test_include" && xawplus_direct_test_include=X11/XawPlus/Command.h
  for ac_dir in               \
    /usr/athena/include       \
                              \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11R4/include        \
                              \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
    /usr/include/X11R4        \
                              \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
    /usr/local/X11R4/include  \
                              \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
    /usr/local/include/X11R4  \
                              \
    /usr/X11/include          \
    /usr/include/X11          \
    /usr/local/X11/include    \
    /usr/local/include/X11    \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/dt/include           \
                              \
    /usr/local/include        \
    /usr/remote/include       \
    /usr/include              \
    /usr/unsupported/include  \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
    $extra_include            \
    ; \
  do
    if test -r "$ac_dir/$xawplus_direct_test_include"; then
      no_xawplus= ac_xawplus_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$xawplus_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_xawplus_includes" | sed s/include/lib/` \
    /usr/athena/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/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/remote/lib       \
    /usr/unsupported/lib  \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    $extra_lib            \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${xawplus_direct_test_library}.$ac_extension; then
      no_xawplus= ac_xawplus_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_XAWPLUS],
[AC_REQUIRE_CPP()dnl

xawplus_includes=NONE
xawplus_libraries=NONE

AC_MSG_CHECKING(for XawPlus)
AC_ARG_WITH(xawplus, [  --without-xawplus           disable XawPlus])
if test "x$with_xawplus" = xno; then
  no_xawplus=yes
else
  if test "x$xawplus_includes" != xNONE && test "x$xawplus_libraries" != xNONE; then
    no_xawplus=
  else
AC_CACHE_VAL(ac_cv_path_xawplus,
[# One or both of these vars are not set, and there is no cached value.
no_xawplus=yes
AC_PATH_XAWPLUS_DIRECT

if test "$no_xawplus" = yes; then
  ac_cv_path_xawplus="no_xawplus=yes"
else
  ac_cv_path_xawplus="no_xawplus= ac_xawplus_includes=$ac_xawplus_includes ac_xawplus_libraries=$ac_xawplus_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_xawplus"
fi # with_xawplus != no

if test "$no_motif" = yes; then
  if test "$no_xaw3dxft" = yes; then
    if test "$no_xaw3d" = yes; then
      if test "$no_nextaw" = yes; then
        if test "$no_xawplus" = yes; then
          AC_MSG_RESULT(no)
        else
          AC_DEFINE([HAVE_ATHENA], [1], [Athena is available])
          AC_DEFINE([HAVE_LIB_XAWPLUS], [1], [XawPlus is available])
          LIBS="-lXawPlus ${LIBS}"
          test "x$xawplus_includes" = xNONE && xawplus_includes=$ac_xawplus_includes
          test "x$xawplus_libraries" = xNONE && xawplus_libraries=$ac_xawplus_libraries
          ac_cv_path_xawplus="no_xawplus= ac_xawplus_includes=$xawplus_includes ac_xawplus_libraries=$xawplus_libraries"
          AC_MSG_RESULT([libraries $xawplus_libraries, headers $xawplus_includes])
        fi
      else
        AC_MSG_RESULT(ignored - using neXtaw)
      fi
    else
      AC_MSG_RESULT(ignored - using Xaw3d)
    fi
  else
    AC_MSG_RESULT(ignored - using Xaw3dxft)
  fi
else
  AC_MSG_RESULT(ignored - using Motif)
fi
])

AC_PATH_XAWPLUS

if test "x$xawplus_libraries" != x ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$xawplus_libraries"
  XWIDGETLIBPATHS="-L$xawplus_libraries ${XWIDGETLIBPATHS}"
fi
if test "x$xawplus_includes" != x ; then
  XWIDGETINC="${XWIDGETINC} -I$xawplus_includes"
fi

dnl Xaw XAW xaw

AC_DEFUN([AC_PATH_XAW_DIRECT],
[test -z "$xaw_direct_test_library" && xaw_direct_test_library=Xaw
test -z "$xaw_direct_test_function" && xaw_direct_test_function=XawDialGetValueString
test -z "$xaw_direct_test_include" && xaw_direct_test_include=X11/Xaw/Command.h
  for ac_dir in               \
    /usr/athena/include       \
                              \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11R4/include        \
                              \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
    /usr/include/X11R4        \
                              \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
    /usr/local/X11R4/include  \
                              \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
    /usr/local/include/X11R4  \
                              \
    /usr/X11/include          \
    /usr/include/X11          \
    /usr/local/X11/include    \
    /usr/local/include/X11    \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/dt/include           \
                              \
    /usr/local/include        \
    /usr/remote/include       \
    /usr/include              \
    /usr/unsupported/include  \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
    $extra_include            \
    ; \
  do
    if test -r "$ac_dir/$xaw_direct_test_include"; then
      no_xaw= ac_xaw_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$xaw_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_xaw_includes" | sed s/include/lib/` \
    /usr/athena/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/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/remote/lib       \
    /usr/unsupported/lib  \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    $extra_lib            \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${xaw_direct_test_library}.$ac_extension; then
      no_xaw= ac_xaw_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_XAW],
[AC_REQUIRE_CPP()dnl

xaw_includes=NONE
xaw_libraries=NONE

AC_MSG_CHECKING(for Xaw)
AC_ARG_WITH(xaw, [  --without-xaw           disable Xaw])
if test "x$with_xaw" = xno; then
  no_xaw=yes
else
  if test "x$xaw_includes" != xNONE && test "x$xaw_libraries" != xNONE; then
    no_xaw=
  else
AC_CACHE_VAL(ac_cv_path_xaw,
[# One or both of these vars are not set, and there is no cached value.
no_xaw=yes
AC_PATH_XAW_DIRECT

if test "$no_xaw" = yes; then
  ac_cv_path_xaw="no_xaw=yes"
else
  ac_cv_path_xaw="no_xaw= ac_xaw_includes=$ac_xaw_includes ac_xaw_libraries=$ac_xaw_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_xaw"
fi # with_xaw != no

if test "$no_motif" = yes; then
  if test "$no_xaw3dxft" = yes; then
    if test "$no_xaw3d" = yes; then
      if test "$no_nextaw" = yes; then
        if test "$no_xawplus" = yes; then
          if test "$no_xaw" = yes; then
            AC_MSG_RESULT(no)
          else
            AC_DEFINE([HAVE_ATHENA], [1], [Athena is available])
            LIBS="-lXaw ${LIBS}"
            test "x$xaw_includes" = xNONE && xaw_includes=$ac_xaw_includes
            test "x$xaw_libraries" = xNONE && xaw_libraries=$ac_xaw_libraries
            ac_cv_path_xaw="no_xaw= ac_xaw_includes=$xaw_includes ac_xaw_libraries=$xaw_libraries"
            AC_MSG_RESULT([libraries $xaw_libraries, headers $xaw_includes])
          fi
        else
          AC_MSG_RESULT(ignored - using XawPlus)
        fi
      else
        AC_MSG_RESULT(ignored - using neXtaw)
      fi
    else
      AC_MSG_RESULT(ignored - using Xaw3d)
    fi
  else
    AC_MSG_RESULT(ignored - using Xaw3dxft)
  fi
else
  AC_MSG_RESULT(ignored - using Motif)
fi
])

AC_PATH_XAW

if test "x$xaw_libraries" != x ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$xaw_libraries"
  XWIDGETLIBPATHS="-L$xaw_libraries ${XWIDGETLIBPATHS}"
fi
if test "x$xaw_includes" != x ; then
  XWIDGETINC="${XWIDGETINC} -I$xaw_includes"
fi

dnl Xpm XPM xpm

AC_DEFUN([AC_PATH_XPM_DIRECT],
[test -z "$xpm_direct_test_library" && xpm_direct_test_library=Xpm
test -z "$xpm_direct_test_function" && xpm_direct_test_function=XpmCreateImageFromData
test -z "$xpm_direct_test_include" && xpm_direct_test_include=X11/xpm.h
  for ac_dir in               \
    /usr/include              \
    /usr/openwin/include      \
    /usr/openwin/share/include \
    /usr/include/Vk           \
                              \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11R4/include        \
                              \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
    /usr/include/X11R4        \
                              \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
    /usr/local/X11R4/include  \
                              \
    /usr/local/include/X11    \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
    /usr/local/include/X11R4  \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/local/include        \
    /usr/remote/include       \
    /usr/include              \
    /usr/unsupported/include  \
    /usr/athena/include       \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
    $extra_include            \
    ; \
  do
    if test -r "$ac_dir/$xpm_direct_test_include"; then
      no_xpm= ac_xpm_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Do not add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$xpm_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_xpm_includes" | sed s%/X11$%% | sed s/include/lib/` \
    /usr/include              \
    /usr/openwin/include      \
    /usr/openwin/share/include \
    /usr/include/Vk           \
                          \
    /usr/X11R6/lib        \
    /usr/X11R5/lib        \
    /usr/X11R4/lib        \
                          \
    /usr/lib/X11R6        \
    /usr/lib/X11R5        \
    /usr/lib/X11R4        \
                          \
    /usr/local/X11/lib    \
    /usr/local/X11R6/lib  \
    /usr/local/X11R5/lib  \
    /usr/local/X11R4/lib  \
                          \
    /usr/local/lib/X11    \
    /usr/local/lib/X11R6  \
    /usr/local/lib/X11R5  \
    /usr/local/lib/X11R4  \
                          \
    /usr/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/remote/lib       \
    /usr/unsupported/lib  \
    /usr/athena/lib       \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    $extra_lib            \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${xpm_direct_test_library}.$ac_extension; then
      no_xpm= ac_xpm_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_XPM],
[AC_REQUIRE_CPP()dnl

xpm_includes=NONE
xpm_libraries=NONE

AC_MSG_CHECKING(for XPM)
AC_ARG_WITH(xpm, [  --without-xpm           disable color icon])
if test "x$with_xpm" = xno; then
  no_xpm=yes
else
  if test "x$xpm_includes" != xNONE && test "x$xpm_libraries" != xNONE; then
    no_xpm=
  else
AC_CACHE_VAL(ac_cv_path_xpm,
[# One or both of these vars are not set, and there is no cached value.
no_xpm=yes
AC_PATH_XPM_DIRECT

if test "$no_xpm" = yes; then
  ac_cv_path_xpm="no_xpm=yes"
else
  ac_cv_path_xpm="no_xpm= ac_xpm_includes=$ac_xpm_includes ac_xpm_libraries=$ac_xpm_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_xpm"
fi # with_xpm != no

if test "$no_xpm" = yes; then
  AC_MSG_RESULT(no)
else
  AC_DEFINE([HAVE_XPM], [1], [XPM, color imaging, is available])
  LIBS="${LIBS} -lXpm"
  test "x$xpm_includes" = xNONE && xpm_includes=$ac_xpm_includes
  test "x$xpm_libraries" = xNONE && xpm_libraries=$ac_xpm_libraries
  ac_cv_path_xpm="no_xpm= ac_xpm_includes=$xpm_includes ac_xpm_libraries=$xpm_libraries"
  AC_MSG_RESULT([libraries $xpm_libraries, headers $xpm_includes])
fi
])

AC_PATH_XPM

if test "x$xpm_libraries" != x && test "x$xpm_libraries" != xNONE ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$xpm_libraries"
  XWIDGETLIBPATHS="${XWIDGETLIBPATHS} -L$xpm_libraries"
fi
if test "x$xpm_includes" != x && test "x$xpm_includes" != xNONE ; then
  XWIDGETINC="${XWIDGETINC} -I$xpm_includes"
fi

dnl OpenGL opengl

AC_DEFUN([AC_PATH_OPENGL_DIRECT],
[test -z "$opengl_direct_test_library" && opengl_direct_test_library=GL
test -z "$opengl_direct_test_library" && opengl_direct_test_library=GLU
test -z "$opengl_direct_test_function" && opengl_direct_test_function=glXCreateContext
test -z "$opengl_direct_test_include" && opengl_direct_test_include=GL/gl.h
test -z "$opengl_direct_test_include" && opengl_direct_test_include=GL/glu.h
  for ac_dir in               \
    /usr/include              \
    /usr/openwin/include      \
    /usr/openwin/share/include \
                              \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11R4/include        \
                              \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
    /usr/include/X11R4        \
                              \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
    /usr/local/X11R4/include  \
                              \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
    /usr/local/include/X11R4  \
                              \
    /usr/X11/include          \
    /usr/include/X11          \
    /usr/local/X11/include    \
    /usr/local/include/X11    \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/local/include        \
    /usr/include              \
    /usr/unsupported/include  \
    /usr/athena/include       \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
    ; \
  do
    if test -r "$ac_dir/$opengl_direct_test_include"; then
      no_opengl= ac_opengl_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$opengl_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_opengl_includes" | sed s/include/lib/` \
    /usr/lib              \
    /usr/openwin/lib      \
    /usr/openwin/share/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/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/unsupported/lib  \
    /usr/athena/lib       \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${opengl_direct_test_library}.$ac_extension; then
      no_opengl= ac_opengl_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_OPENGL],
[AC_REQUIRE_CPP()dnl

opengl_includes=NONE
opengl_libraries=NONE

AC_MSG_CHECKING(for OpenGL)
AC_ARG_WITH(opengl, [  --without-opengl        disable OpenGL])
if test "x$with_opengl" = xno; then
  no_opengl=yes
else
  if test "x$opengl_includes" != xNONE && test "x$opengl_libraries" != xNONE; then
    no_opengl=
  else
AC_CACHE_VAL(ac_cv_path_opengl,
[# One or both of these vars are not set, and there is no cached value.
no_opengl=yes
AC_PATH_OPENGL_DIRECT

if test "$no_opengl" = yes; then
  ac_cv_path_opengl="no_opengl=yes"
else
  ac_cv_path_opengl="no_opengl= ac_opengl_includes=$ac_opengl_includes ac_opengl_libraries=$ac_opengl_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_opengl"
fi # with_opengl != no

if test "$no_opengl" = yes; then
  AC_MSG_RESULT(no)
else
  AC_DEFINE([HAVE_OPENGL], [1], [OpenGL, 3D Graphics, is available])
  LIBS="-lGL -lGLU ${LIBS} -lm"
  test "x$opengl_includes" = xNONE && opengl_includes=$ac_opengl_includes
  test "x$opengl_libraries" = xNONE && opengl_libraries=$ac_opengl_libraries
  ac_cv_path_opengl="no_opengl= ac_opengl_includes=$opengl_includes ac_opengl_libraries=$opengl_libraries"
  AC_MSG_RESULT([libraries $opengl_libraries, headers $opengl_includes])
fi
])

AC_PATH_OPENGL

if test "x$opengl_libraries" != x ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$opengl_libraries"
  XWIDGETLIBPATHS="-L$opengl_libraries ${XWIDGETLIBPATHS}"
fi
if test "x$opengl_includes" != x ; then
  XWIDGETINC="${XWIDGETINC} -I$opengl_includes"
fi

AC_MSG_CHECKING(for sound file extension)
WAVDIR=""
SOUNDEXT=".au"
AC_ARG_ENABLE(wav_format, [  --enable-wav-format     use wav files instead of au files for sound],
  wav_format=$enableval,
  wav_format=no)
if test "$wav_format" = "yes"; then
  WAVDIR="/win32"
  SOUNDEXT=".wav"
fi
AC_MSG_RESULT([using $SOUNDEXT])

sound=none

NOPLAY="#"
if test "$sound" = none; then
  AC_MSG_CHECKING(for DEF_PLAY)
  AC_ARG_ENABLE(def_play, [  --disable-def-play=program
                          set def-play to program that plays sounds],def_play=$enableval,def_play=yes)
  if test "$def_play" = "yes"; then
    def_play=play.sh # yes is a bad default here
  fi
  if test "$def_play" != no; then
    AC_MSG_RESULT([defining option DEF_PLAY = "$def_play"])
    AC_DEFINE_UNQUOTED([DEF_PLAY], ["$def_play"], [program to play sounds])
    sound=$def_play
    NOPLAY=""
  else
    AC_MSG_RESULT(no)
  fi
fi

dnl RPLAY RPlay rplay

AC_DEFUN([AC_PATH_RPLAY_DIRECT],
[test -z "$rplay_direct_test_library" && rplay_direct_test_library=rplay
test -z "$rplay_direct_test_function" && rplay_direct_test_function=rplay_open_default
test -z "$rplay_direct_test_include" && rplay_direct_test_include=rplay.h
  for ac_dir in               \
    /usr/X11R6.5.1/include    \
    /usr/X11R6.4/include      \
    /usr/X11R6.3/include      \
    /usr/X11R6.2/include      \
    /usr/X11R6.1/include      \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11/include          \
    /usr/local/include        \
    /usr/remote/include       \
    /usr/include              \
    $extra_include            \
    ; \
  do
    if test -r "$ac_dir/$rplay_direct_test_include"; then
      no_rplay= ac_rplay_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Do not add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$rplay_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_rplay_includes" | sed s/include/lib/` \
                          \
    /usr/X11R6.5.1/lib    \
    /usr/X11R6.4/lib      \
    /usr/X11R6.3/lib      \
    /usr/X11R6.2/lib      \
    /usr/X11R6.1/lib      \
    /usr/X11R6/lib        \
    /usr/X11R5/lib        \
    /usr/X11/lib          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/remote/lib       \
    $extra_lib            \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${rplay_direct_test_library}.$ac_extension; then
      no_rplay= ac_rplay_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_RPLAY],
[AC_REQUIRE_CPP()dnl

rplay_includes=NONE
rplay_libraries=NONE

AC_MSG_CHECKING(for RPLAY)
AC_ARG_WITH(rplay, [  --without-rplay         disable RPLAY sounds])
if test "x$with_rplay" = xno; then
  no_rplay=yes
else
  if test "x$rplay_includes" != xNONE && test "x$rplay_libraries" != xNONE; then
    no_rplay=
  else
AC_CACHE_VAL(ac_cv_path_rplay,
[# One or both of these vars are not set, and there is no cached value.
no_rplay=yes
AC_PATH_RPLAY_DIRECT

if test "$no_rplay" = yes; then
  ac_cv_path_rplay="no_rplay=yes"
else
  ac_cv_path_rplay="no_rplay= ac_rplay_includes=$ac_rplay_includes ac_rplay_libraries=$ac_rplay_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_rplay"
fi # with_rplay != no

if test "$no_rplay" = yes; then
  AC_MSG_RESULT(no)
else
dnl  solaris26=no
dnl  case "${canonical}" in
dnl    *-*-solaris2.6 )
dnl    solaris26=yes
dnl    ;;
dnl  esac
dnl  if test "$CC" = gcc && test "$solaris26" = yes; then
dnl    AC_MSG_RESULT(ignored - problems here with gcc and solaris2.6)
dnl  else
  if test "$sound" = none; then
    sound=rplay
    AC_DEFINE([USE_RPLAY], [1], [using RPLAY audio])
    LIBS="${LIBS} -lrplay"
    test "x$rplay_includes" = xNONE && rplay_includes=$ac_rplay_includes
    test "x$rplay_libraries" = xNONE && rplay_libraries=$ac_rplay_libraries
    ac_cv_path_rplay="no_rplay= ac_rplay_includes=$rplay_includes ac_rplay_libraries=$rplay_libraries"
    AC_MSG_RESULT([libraries $rplay_libraries, headers $rplay_includes])
  else
    AC_MSG_RESULT(ignored - using previous definition for sound)
  fi
dnl  fi
fi
])

AC_PATH_RPLAY

if test "x$rplay_libraries" != x && test "x$rplay_libraries" != xNONE ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$rplay_libraries"
  XWIDGETLIBPATHS="${XWIDGETLIBPATHS} -L$rplay_libraries"
fi
if test "x$rplay_includes" != x && test "x$rplay_includes" != xNONE ; then
  XWIDGETINC="${XWIDGETINC} -I$rplay_includes"
fi

dnl ESOUND Enlightenment sound daemon

AC_DEFUN([AC_PATH_ESOUND],
[AC_REQUIRE_CPP()dnl

esound_includes=NONE
esound_libraries=NONE

AC_MSG_CHECKING(for ESOUND)
AC_ARG_WITH(esound,            [  --with-esound           enable Enlightenment Sound Daemon sounds])
AC_ARG_WITH(esound_config,     [  --with-esound-config    use this configurator for Enlightenment Sound Daemon])
AC_ARG_WITH(esound_prefix,     [  --with-esound-prefix    use this prefix for Enlightenment Sound Daemon])
AC_ARG_WITH(esound_includes,   [  --with-esound-includes  use this dir for Enlightenment Sound Daemon headers])
AC_ARG_WITH(esound_libraries,  [  --with-esound-libraries use this dir for Enlightenment Sound Daemon libs])
if test "x$with_esound" = xno; then
  no_esound=yes
else
  if test "x$esound_includes" != xNONE && test "x$esound_libraries" != xNONE; then
    no_esound=
    if test "x$esound_config" = "x"; then
      if test "x$esound_prefix" != "x"; then
        esound_config="$esound_prefix/bin/esd-config"
      else
        esound_config="esd-config"
      fi
    else
      if test "x$esound_prefix" = "x"; then
        esound_prefix=`($esound_config --prefix) 2>/dev/null`
      fi
    fi
  else
    if test "x$esound_config" = "x"; then
      if test "x$esound_prefix" != "x"; then
        esound_config="$esound_prefix/bin/esd-config"
      else
        esound_config="esd-config"
      fi
    else
      if test "x$esound_prefix" = "x"; then
        esound_prefix=`($esound_config --prefix) 2>/dev/null`
      fi
    fi
AC_CACHE_VAL(ac_cv_path_esound,
[# One or both of these vars are not set, and there is no cached value.
no_esound=yes
no_esound_config=yes
if test "x$esound_prefix" != "x"; then
  ac_esound_prefix=$esound_prefix
  ac_esound_includes=$ac_esound_prefix/include
  ac_esound_libraries=$ac_esound_prefix/lib
  no_esound="ac_esound_config=$ac_esound_config ac_esound_prefix=$ac_esound_prefix ac_esound_includes=$ac_esound_includes ac_esound_libraries=$ac_esound_libraries"
else
  ac_esound_config="$esound_config"
  ac_esound_prefix=`($esound_config --prefix) 2>/dev/null`
  if test $? != 0; then
    no_esound=yes
    no_esound_config=yes
    ac_esound_config=""
    ac_esound_prefix=""
  else
    no_esound=
    no_esound_config=
    ac_esound_includes=$ac_esound_prefix/include
    ac_esound_libraries=$ac_esound_prefix/lib
  fi
fi
if test "$no_esound" = yes; then
  ac_cv_path_esound="no_esound=yes"
else
  ac_cv_path_esound="no_esound= ac_esound_config=\"$ac_esound_config\" ac_esound_prefix=\"$ac_esound_prefix\" ac_esound_includes=\"$ac_esound_includes\" ac_esound_libraries=\"$ac_esound_libraries\""
fi])dnl
  fi
  eval "$ac_cv_path_esound"
fi # with_esound != no

if test "$no_esound_config" = yes; then
  AC_MSG_RESULT(no esd-config)
else
  if test "$no_esound" = yes; then
    AC_MSG_RESULT(no)
  else
    if test "$sound" = none; then
      sound=esound
      AC_DEFINE([USE_ESOUND], [1], [using ESOUND audio])
      AC_DEFINE([HAVE_LIBESD], [1], [LIBESD audio is available])
      #if test "x$prefix" = xNONE; then
      #  AC_DEFINE_UNQUOTED([SOUNDPATH], ["/usr/local/share/games/xpuzzles"], [sound path])
      #else
      #  AC_DEFINE_UNQUOTED([SOUNDPATH], ["${prefix}/share/games/xpuzzles"], [sound path])
      #fi
      test "x$esound_config" = xNONE && esound_config=$ac_esound_config
      test "x$esound_prefix" = xNONE && esound_prefix=$ac_esound_prefix
      test "x$esound_includes" = xNONE && esound_includes=$ac_esound_includes
      test "x$esound_libraries" = xNONE && esound_libraries=$ac_esound_libraries
      ac_cv_path_esound="no_esound= ac_esound_config=$esound_config ac_esound_prefix=$esound_prefix ac_esound_includes=$esound_includes ac_esound_libraries=$esound_libraries"
      AC_MSG_RESULT([libraries $esound_libraries, headers $esound_includes])
    else
      AC_MSG_RESULT(ignored - using previous definition for sound)
    fi
  fi
fi
])

AC_PATH_ESOUND

if test "x$esound_libraries" != x && test "x$esound_libraries" != xNONE ; then
  LIBS="${LIBS} `$esound_config --libs -laudiofile`"
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$esound_libraries"
  XWIDGETLIBPATHS="${XWIDGETLIBPATHS} -L$esound_libraries"
fi
if test "x$esound_includes" != x && test "x$esound_includes" != xNONE ; then
  XWIDGETINC="${XWIDGETINC} -I$esound_includes `$esound_config --cflags`"
fi

dnl NAS audio

AC_DEFUN([AC_PATH_NAS_DIRECT],
[test -z "$nas_direct_test_library" && nas_direct_test_library=audio
test -z "$nas_direct_test_function" && nas_direct_test_function=AuOpenServer
test -z "$nas_direct_test_include" && nas_direct_test_include=audio/audio.h
  for ac_dir in               \
    /usr/X11R6.5.1/include    \
    /usr/X11R6.4/include      \
    /usr/X11R6.3/include      \
    /usr/X11R6.2/include      \
    /usr/X11R6.1/include      \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11/include          \
    /usr/local/include        \
    /usr/remote/include       \
    /usr/include              \
    $extra_include            \
    ; \
  do
    if test -r "$ac_dir/$nas_direct_test_include"; then
      no_nas= ac_nas_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Do not add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$nas_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_nas_includes" | sed s/include/lib/` \
                          \
    /usr/X11R6.5.1/lib    \
    /usr/X11R6.4/lib      \
    /usr/X11R6.3/lib      \
    /usr/X11R6.2/lib      \
    /usr/X11R6.1/lib      \
    /usr/X11R6/lib        \
    /usr/X11R5/lib        \
    /usr/X11/lib          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/remote/lib       \
    $extra_lib            \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${nas_direct_test_library}.$ac_extension; then
      no_nas= ac_nas_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS="$ac_save_LIBS"])
AC_DEFUN([AC_PATH_NAS],
[AC_REQUIRE_CPP()dnl

nas_includes=NONE
nas_libraries=NONE

AC_MSG_CHECKING(for NAS)
AC_ARG_WITH(nas, [  --without-nas           disable NAS sounds])
if test "x$with_nas" = xno; then
  no_nas=yes
else
  if test "x$nas_includes" != xNONE && test "x$nas_libraries" != xNONE; then
    no_nas=
  else
AC_CACHE_VAL(ac_cv_path_nas,
[# One or both of these vars are not set, and there is no cached value.
no_nas=yes
AC_PATH_NAS_DIRECT

if test "$no_nas" = yes; then
  ac_cv_path_nas="no_nas=yes"
else
  ac_cv_path_nas="no_nas= ac_nas_includes=$ac_nas_includes ac_nas_libraries=$ac_nas_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_nas"
fi # with_nas != no

if test "$no_nas" = yes; then
  AC_MSG_RESULT(no)
else
  if test "$sound" = none; then
    sgi=no
    case "${canonical}" in
      *-*-irix5* | *-*-irix6* )
        sgi=yes
      ;;
    esac
    if test "$sgi" = yes; then
      AC_MSG_RESULT(ignored - problems here with audio and nas)
    else
      sound=nas
      AC_DEFINE([USE_NAS], [1], [using NAS audio])
      LIBS="${LIBS} -laudio"
dnl    LIBS="${LIBS} -lnas"
      test "x$nas_includes" = xNONE && nas_includes=$ac_nas_includes
      test "x$nas_libraries" = xNONE && nas_libraries=$ac_nas_libraries
      ac_cv_path_nas="no_nas= ac_nas_includes=$nas_includes ac_nas_libraries=$nas_libraries"
      AC_MSG_RESULT([libraries $nas_libraries, headers $nas_includes])
    fi
  else
    AC_MSG_RESULT(ignored - using previous definition for sound)
  fi
fi
])

AC_PATH_NAS

if test "x$nas_libraries" != x && test "x$nas_libraries" != xNONE ; then
  XWIDGET_LDFLAGS="${XWIDGET_LDFLAGS}:$nas_libraries"
  XWIDGETLIBPATHS="${XWIDGETLIBPATHS} -L$nas_libraries"
fi
if test "x$nas_includes" != x && test "x$nas_includes" != xNONE ; then
  XWIDGETINC="${XWIDGETINC} -I$nas_includes"
fi

dnl Now we handle the various system dependent problems
dnl that aren't addressed in the X header files, or things dealing
dnl with utility quirks on some systems.

AC_CANONICAL_HOST
canonical=$host
case "${canonical}" in

  *-*-aix2* | *-*-aix3.0* | *-*-aix3.1* )
    AC_DEFINE([LESS_THAN_AIX3_2], [1], [less than AIX Version 3.2])
  ;;

  *-*-cygwin* )
    LIBS="${LIBS} -lSM -lICE"
  ;;

  *-*-freebsd* | *-*-netbsd* | *-*-openbsd* )
    XWIDGETLDFLAGS="-R${XWIDGET_LDFLAGS}"
  ;;

  *-*-hpux* )
    if test "${CC}" = "cc" ; then
      CFLAGS="${CFLAGS} -Aa -z -D_HPUX_SOURCE"
      GPROF_CFLAGS="${GPROF_CFLAGS} -Aa -z -D_HPUX_SOURCE"
    fi
  ;;

  *-*-irix5* | *-*-irix6* )
    if test "${CC}" = "cc" ; then
      CFLAGS="${CFLAGS} -fullwarn"
    fi
  ;;

  *-*-linux* )
    if test "${CC}" = "g++" -o "${CC}" = "clang++" ; then
      CFLAGS="${CFLAGS} -pedantic"
    else
      CFLAGS="${CFLAGS} -std=c99 -pedantic"
    fi
    AC_DEFINE([linux], [1], [Linux OS])
    AC_DEFINE([_POSIX_SOURCE], [1], [POSIX source])
    AC_DEFINE([_BSD_SOURCE], [1], [BSD source])
    AC_DEFINE([_DEFAULT_SOURCE], [1], [DEFAULT source])
    AC_DEFINE([_GNU_SOURCE], [1], [GNU source])
    AC_DEFINE([HAVE_CUSERID], [1], [HAVE cuserid])
  ;;

  *-*-solaris2* )
    AC_DEFINE([SYSV], [1], [System 5])
    AC_DEFINE([SVR4], [1], [System 5 Rev 4])
    XWIDGETLDFLAGS="-R${XWIDGET_LDFLAGS}"
    LIBS="${LIBS} -lsocket -lnsl -lposix4"
  ;;

esac

XWIDGETLIBS="${XWIDGETLIBPATHS} ${LIBS}"
AC_SUBST(XWIDGETLDFLAGS)
AC_SUBST(XWIDGETINC)
AC_SUBST(XLIBS)
AC_SUBST(XWIDGETLIBS)
AC_SUBST(XM_PREFIX)
AC_SUBST(APPDEFAULTS)
AC_SUBST(LINT)
AC_SUBST(WAVDIR)
AC_SUBST(SOUNDEXT)
AC_SUBST(NOPLAY)

dnl AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
