dnl #########################################################################
dnl ##
dnl ## check for a unique program in the source directory
dnl ##

AC_INIT(xgap.c)
AC_CONFIG_AUX_DIR(../../cnf)


dnl #########################################################################
dnl ##
dnl ## create a config file from "config.hin"
dnl ##

AC_CONFIG_HEADER(config.h:../cnf/config.hin)


dnl #########################################################################
dnl ##
dnl ## check for compiler features
dnl ##

AC_PROG_CC
AC_PROG_CC_C_O
AC_C_CONST
AC_CHECK_SIZEOF(short) # no space between 'short' and ')'
AC_CHECK_SIZEOF(int) # no space between 'int' and ')'
AC_CHECK_SIZEOF(long) # no space between 'long' and ')'


dnl #########################################################################
dnl ##
dnl ## check for structs and typedefs
dnl ##

AC_STRUCT_ST_RDEV
AC_TYPE_UID_T


dnl #########################################################################
dnl ##
dnl ## find a canonical name for the system
dnl ##

AC_CANONICAL_SYSTEM


dnl #########################################################################
dnl ##
dnl ## check for the existence of various header files
dnl ##

AC_HEADER_STDC
AC_CHECK_HEADERS( libc.h unistd.h )


dnl #########################################################################
dnl ##
dnl ## check for timing functions
dnl ##

AC_HEADER_TIME
AC_CHECK_HEADERS( sys/time.h )


dnl #########################################################################
dnl ##
dnl ## check for fork, wait, execute functions
dnl ##

AC_HEADER_SYS_WAIT
AC_FUNC_WAIT3
AC_TYPE_PID_T


dnl #########################################################################
dnl ##
dnl ## check for tty and pseudo tty functions
dnl ##

AC_CHECK_HEADERS( fcntl.h sgtty.h termios.h termio.h sys/ioctl.h sys/select.h )
AC_CHECK_FUNCS( select getpseudotty _getpty getpt ptsname_r )


dnl #########################################################################
dnl ##
dnl ## check for signal handling
dnl ##

AC_CHECK_HEADERS( signal.h sys/signal.h )
AC_CHECK_FUNCS( signal )
AC_TYPE_SIGNAL
if test "$ac_cv_type_signal" = "void"; then
  AC_DEFINE( HAVE_SIGNAL_VOID )
fi


dnl #########################################################################
dnl ##
dnl ## check for directory handling
dnl ##

AC_HEADER_DIRENT
AC_FUNC_CLOSEDIR_VOID


dnl #########################################################################
dnl ##
dnl ## checks where the X11 libraries (this should be the last test)
dnl ##

AC_PATH_XTRA

if test "$have_x" != yes;  then
    AC_MSG_ERROR([XGAP needs XWindows X11R5 or later including the
    development files like header files, usually you can install these
    using the package manager of your operating system. For debian-derived
    Linux distributions these packages are called
        libx11-dev
        libxaw7-dev
        libxt-dev
    Note that depending on your operating system, these packages could
    be called differently.])
fi

AC_MSG_CHECKING(for broken exposure compress in open windows)
case "$target" in

  *-*-sunos*)
    case "$x_libraries" in
      *openwin*)
	AC_DEFINE( HAVE_BROKEN_TEXT_EXPORE_COMPRESS )
	X_EXTRA_LIBS="$X_EXTRA_LIBS -lm $x_libraries/libXmu.a"
	AC_MSG_RESULT([yes (let's hope it works)])
        ;;

      *)
	AC_MSG_RESULT([no (good)])
	;;

    esac
    ;;

  *)
    AC_MSG_RESULT([no (good)])
    ;;

esac




dnl #########################################################################
dnl ##
dnl ## generate a makefile
dnl ##

AC_OUTPUT(Makefile:../cnf/Makegap.in)
