dnl Process this file with autoconf to produce a configure script.
AC_INIT(curs.c)
AC_CONFIG_HEADER(config.h)
dnl Checks for programs.
AC_PROG_CC
AC_DEFINE(_GORD_LIBS)
dnl Checks for libraries.
dnl Replace `main' with a function in -lncurses:
AC_CHECK_LIB(ncurses, mvchgat)
AC_CHECK_LIB(pthread, pthread_create)

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h strings.h sys/ioctl.h sys/time.h unistd.h)
AC_CHECK_HEADERS(netinet/ip_icmp.h)
AC_CHECK_HEADERS(netinet/ip.h)
AC_CHECK_HEADERS(netinet/tcp.h)
AC_CHECK_HEADERS(netinet/ip_tcp.h)
AC_CHECK_HEADERS(netinet/udp.h)
AC_CHECK_HEADERS(netinet/ip_udp.h)
AC_CHECK_HEADERS(netinet/if_ether.h)
AC_CHECK_HEADERS(netinet/in.h)
AC_CHECK_HEADERS(netinet/socket.h)
AC_CHECK_HEADERS(net/if.h)
AC_CHECK_HEADERS(net/if_ppp.h)
AC_CHECK_HEADERS(netinet/if_ether.h netinet/in.h ncurses.h ncurses/curses.h)
AC_CHECK_HEADERS(ncurses.h)
AC_CHECK_HEADERS(pthread.h)
AC_CHECK_HEADERS(ncurses/curses.h)
AC_CHECK_HEADERS(curses.h)
AC_CHECK_HEADERS(sys/if_packet.h)
AC_CHECK_HEADERS(linux/if_packet.h)
AC_CHECK_HEADERS(net/if_packet.h)


if test x$ac_cv_header_sys_if_packet_h = xyes; then
  AC_DEFINE(SYS_IF_PACKET_H)
else
  if test x$ac_cv_header_linux_if_packet_h = xyes; then
	AC_DEFINE(LINUX_IF_PACKET_H)
  else
  	if test x$ac_cv_header_net_if_packet_h = xyes; then
		AC_DEFINE(NET_IF_PACKET_H)
  	fi
  fi
fi
if test x$ac_cv_header_ncurses_curses_h = xyes; then
  AC_DEFINE(NEWCURSES_SUPP)
else
   if test x$ac_cv_header_ncurses_h = xyes; then
	AC_DEFINE(NEWCURSESROOT_SUPP)
   else
	if test x$ac_cv_header_curses_h = xyes; then
		AC_DEFINE(REGULARCURSES_SUPP)
	else
		AC_MSG_ERROR([There is no support for ncurses.h])
   	fi
   fi
fi

if test x$ac_cv_header_netinet_ip_h = xyes; then
  AC_DEFINE(NETINET_SUPP_ip)
  AC_EGREP_HEADER("ip_options",/usr/include/netinet/ip.h,is_opt=1,is_opt=0)
  if test $is_opt = 1; then
	AC_DEFINE(LINUX_IP_OPTIONS)
  fi
else
   AC_CHECK_HEADERS(linux/ip.h)
   if test x$ac_cv_header_linux_ip_h = xyes; then
   	AC_DEFINE(LINUXINET_SUPP_ip)
	AC_EGREP_HEADER("ip_options",/usr/include/linux/ip.h,is_opt=1,is_opt=0)
	if test $is_opt = 1; then
		AC_DEFINE(LINUX_IP_OPTIONS)
	fi
   else
	AC_MSG_ERROR([There is no support in standard NETINET/LINUX for
		ip.h])
   fi
fi

if test x$ac_cv_header_netinet_ip_tcp_h = xyes; then
  AC_DEFINE(NETINET_SUPP_ip_tcp)
else
     if test x$ac_cv_header_netinet_tcp_h = xyes; then
  	AC_DEFINE(NETINET_SUPP_tcp)
     else
        AC_CHECK_HEADERS(linux/tcp.h)
        if test x$ac_cv_header_linux_tcp_h = xyes; then
        	AC_DEFINE(LINUXINET_SUPP_tcp)
        else
	     AC_MSG_ERROR([There is no support in standard NETINET/LINUX for tcp.h])
        fi
     fi
fi
if test x$ac_cv_header_netinet_ip_udp_h = xyes; then
  AC_DEFINE(NETINET_SUPP_ip_udp)
else
    if test x$ac_cv_header_netinet_udp_h = xyes; then
        AC_DEFINE(NETINET_SUPP_udp)
    else
        AC_CHECK_HEADERS(linux/udp.h)
        if test x$ac_cv_header_linux_udp_h = xyes; then
   	     AC_DEFINE(LINUXINET_SUPP_udp)
        else
 	     AC_MSG_ERROR([There is no support in standard NETINET/LINUX for udp.h])
        fi
    fi
fi
if test x$ac_cv_header_netinet_ip_icmp_h = xyes; then
  AC_DEFINE(NETINET_SUPP_icmp)
else
   AC_CHECK_HEADERS(linux/icmp.h)
   if test x$ac_cv_header_linux_icmp_h = xyes; then
   	AC_DEFINE(LINUXINET_SUPP_icmp)
   else
	AC_MSG_ERROR([There is no support in standard NETINET/LINUX for
		icmp.h])
   fi
fi

if test x$ac_cv_header_netinet_if_ether_h = xyes; then
  AC_DEFINE(NETINET_SUPP_if_ether)
else
   AC_CHECK_HEADERS(linux/if_ether.h)
   if test x$ac_cv_header_linux_if_ether_h = xyes; then
   	AC_DEFINE(LINUXINET_SUPP_if_ether)
   else
	AC_MSG_ERROR([There is no support in standard NETINET/LINUX for
		if_ether.h])
   fi
fi


if test x$ac_cv_header_netinet_in_h = xyes; then
  AC_DEFINE(NETINET_SUPP_in)
else
   AC_CHECK_HEADERS(linux/in.h)
   if test x$ac_cv_header_linux_in_h = xyes; then
   	AC_DEFINE(LINUXINET_SUPP_in)
   else
	AC_MSG_ERROR([There is no support in standard NETINET/LINUX for
		in.h])
   fi
fi

if test x$ac_cv_header_net_if_h = xyes; then
  AC_DEFINE(NETINET_SUPP_if)
else
   AC_CHECK_HEADERS(linux/if.h)
   if test x$ac_cv_header_linux_if_h = xyes; then
   	AC_DEFINE(LINUXINET_SUPP_if)
   else
	AC_MSG_ERROR([There is no support in standard NETINET/LINUX for
		if.h])
   fi
fi

if test x$ac_cv_header_net_if_ppp_h = xyes; then
  AC_DEFINE(NETINET_SUPP_if_ppp)
else
   AC_CHECK_HEADERS(linux/if_ppp.h)
   if test x$ac_cv_header_linux_if_ppp_h = xyes; then
   	AC_DEFINE(LINUXINET_SUPP_if_ppp)
   else
	AC_MSG_ERROR([There is no support in standard NETINET/LINUX for
		if_ppp.h])
   fi
fi

dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_PID_T
AC_HEADER_TIME

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(select socket strstr uname)

AC_OUTPUT(Makefile Make.common)
