dnl Process this file with autoconf to produce a configure script.
AC_INIT(isdnctrl.c)
AC_PREFIX_DEFAULT(/usr)

I4LCONFDIR=`eval echo ${CONFIG_I4LCONFDIR:-"/etc/isdn"}`
I4LCONFFILE=`eval echo ${CONFIG_CONFFILE:-"/etc/isdn"}`
I4LVERSION=${I4LVERSION:-"?.?"}
CONFIG_KERNELDIR=${CONFIG_KERNELDIR:-"/usr/src/linux"}
CONFIG_SBINDIR=${CONFIG_SBINDIR:-"/sbin"}
CONFIG_MANDIR=${CONFIG_MANDIR:-"/usr/man"}
CONFIG_ISDNCTRL_CONF=${CONFIG_ISDNCTRL_CONF:-"n"}
CONFIG_ISDNCTRL_TIMRU=${CONFIG_ISDNCTRL_TIMRU:-"n"}
CONFIG_ISDNCTRL_DWABC_UDP_INFO=${CONFIG_ISDNCTRL_DWABC_UDP_INFO:-"n"}
MANDATE=`grep CHECKIN isdnctrl.man.in | awk '{print $4}'`

dnl Checks for programs.
AC_PROG_INSTALL
AC_PROG_CC

dnl Checks for libraries.
AC_TYPE_SIGNAL

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/ioctl.h unistd.h)

dnl Find current kernel source
AC_FIND_KERNEL

dnl
dnl AC_CHECK_FILE is not defined in my autoconf 2.12.
dnl If my autoconf is too old, let me know -lt <lt@toetsch.at>
dnl but AC_CHECK_HEADERS is known so I take this
dnl
dnl AC_CHECK_FILE($CONFIG_KERNELDIR/include/linux/isdn.h,,
dnl 	AC_MSG_ERROR("$CONFIG_KERNELDIR/include/linux/isdn.h missing. Kernel installed?")
dnl )
dnl AC_CHECK_FILE($CONFIG_KERNELDIR/include/linux/isdnif.h,,
dnl 	AC_MSG_ERROR("$CONFIG_KERNELDIR/include/linux/isdnif.h missing. Kernel installed?")
dnl )
dnl
dnl Check for triggercps and ciscok depend on CONFIG_KERNELDIR,
dnl so AC_FIND_KERNEL must be called before.
dnl

AC_CHECK_HEADERS($CONFIG_KERNELDIR/include/linux/isdn.h $CONFIG_KERNELDIR/include/linux/isdnif.h,
		 ,
	         AC_MSG_ERROR(Isdn header files not found. Kernel installed?))

AC_CHECK_TRIGGERCPS
AC_CHECK_CISCOK
AC_CHECK_TIMRU

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Checks for library functions.

dnl Optional sbin directory
AC_ARG_WITH(sbin,
	[  --with-sbin=DIR         Set dir where binary is istalled. [/sbin]],
	CONFIG_SBINDIR="${withval}"
	AC_DEFINE(CONFIG_SBINDIR,"${withval}"),
)

dnl Optional man directory
AC_ARG_WITH(man,
	[  --with-man=DIR          Set manpage dir. [/usr/man]],
	CONFIG_MANDIR="${withval}"
	AC_DEFINE(CONFIG_MANDIR,"${withval}"),
)

dnl Optional config-file-option
AC_ARG_ENABLE(cfile,
	[  --enable-cfile          Enable configfile option [no]],
	CONFIG_ISDNCTRL_CONF=y
	AC_DEFINE(CONFIG_ISDNCTRL_CONF,y),
)

dnl Optional timru-option
AC_ARG_ENABLE(timru,
	[  --enable-timru          Enable dynamic timeout rules [no]],
	CONFIG_ISDNCTRL_TIMRU=y
	AC_DEFINE(CONFIG_ISDNCTRL_TIMRU,y),
)

AC_SUBST(INSTALL)
AC_SUBST(MANDATE)
AC_SUBST(I4LCONFDIR)
AC_SUBST(I4LCONFFILE)
AC_SUBST(I4LVERSION)
AC_SUBST(CONFIG_ISDNCTRL_CONF)
AC_SUBST(CONFIG_ISDNCTRL_TIMRU)
AC_SUBST(CONFIG_ISDNCTRL_DWABC_UDP_INFO)
AC_SUBST(CONFIG_KERNELDIR)
AC_SUBST(CONFIG_SBINDIR)
AC_SUBST(CONFIG_MANDIR)
AC_CONFIG_HEADER(config.h)
AC_OUTPUT(Makefile isdnctrl.man .isdnctrl_conf.man .isdnctrl_timru.man)
