www.pudn.com > voipAutoDialer.rar > configure.in, change:2002-05-31,size:7035b


AC_INIT(voip-device.c,voip-device.c)
AC_CONFIG_HEADER(voip-config.h)

dnl look for some programs we need 
AC_PATH_PROG(RMMOD,  rmmod,  rmmod,  $PATH:/sbin:/usr/sbin)
AC_SUBST(RMMOD)

AC_PATH_PROG(LSMOD, lsmod, lsmod, $PATH:/sbin:/usr/sbin)
AC_SUBST(LSMOD)

AC_PATH_PROG(DEPMOD, depmod, depod, $PATH:/sbin:/usr/sbin)
AC_SUBST(DEPMOD)

AC_PROG_AWK

AC_PROG_INSTALL
AC_SUBST(INSTALL)

dnl determine driver version
AC_MSG_CHECKING(for driver version)
DRIVER_VER_MAJOR=`grep VOIP_VER_MAJOR voip-ver.h | $AWK '{print$3}'`
DRIVER_VER_MINOR=`grep VOIP_VER_MINOR voip-ver.h | $AWK '{print$3}'`
DRIVER_BLD_VER=`grep VOIP_BLD_VER voip-ver.h | $AWK '{print$3}'`
DRIVER_VERSION="${DRIVER_VER_MAJOR}.${DRIVER_VER_MINOR}.${DRIVER_BLD_VER}"

if test -n $DRIVER_VERSION ; then
  AC_MSG_RESULT(version is $DRIVER_VERSION)
else
  AC_MSG_RESULT(unknown)
  AC_MSG_ERROR(Could not find driver version)
fi
AC_SUBST(DRIVER_VERSION)

dnl determine directory for kernel sources
AC_MSG_CHECKING(for kernel source directory)
KERNEL_DIR=/lib/modules/`uname -r`/build
if test -n "$with_kernel_src" ; then
  KERNEL_DIR=$with_kernel_src
  if \! test -d $KERNEL_DIR ; then
    AC_MSG_RESULT(no)
    AC_MSG_ERROR(Cannot find specified directory $KERNEL_SRC)
  fi
elif test \! -d $KERNEL_DIR ; then
  KERNEL_DIR=`find /usr/src/ -maxdepth 1 -type l -name linux-\* | sort | head -1`
  if test \! -n $KERNEL_DIR ; then
    KERNEL_DIR=`find /usr/src/ -maxdepth 1 -type d -name linux-\* | sort | head -1`
    if test \! -n $KERNEL_DIR ; then
      AC_MSG_RESULT(no)
      AC_MSG_ERROR(Kernel source not in $KERNEL_DIR Use --with-kernel-src option to set location)
    fi
  fi
fi
AC_MSG_RESULT([yes ($KERNEL_DIR)])

AC_SUBST(KERNEL_DIR)

dnl see if source is present in directory
AC_MSG_CHECKING(for complete kernel source)
if test -e $KERNEL_DIR/Makefile ; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_MSG_ERROR(Cannot continue without complete kernel source)
  exit
fi

dnl check to see if kernel is configured
AC_MSG_CHECKING(for configured kernel)
if test -e $KERNEL_DIR/.config ; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_MSG_ERROR(Run "make menuconfig" in kernel directory to configure kernel and try again)
  exit
fi

dnl determine version of running kernel
AC_MSG_CHECKING(running kernel version)
VER=`uname -r`
if test -n $VER ; then
  AC_MSG_RESULT([ok ($VER)])
else
  AC_MSG_RESULT(cannot determine running kernel version via \"uname -r\")
  AC_MSG_ERROR(Cannot continue without knowing kernel version)
fi
AC_SUBST(VER)

dnl determine directory for kernel includes
AC_MSG_CHECKING(for kernel includes directory)
if test -d /lib/modules/$VER/build/include/ ; then
  INCLUDE_DIR=/lib/modules/$VER/build/include
  AC_MSG_RESULT([yes ($INCLUDE_DIR)])
else
  INCLUDE_DIR=/usr/include
  AC_MSG_RESULT([no ($INCLUDE_DIR)])
fi
AC_SUBST(INCLUDE_DIR)

dnl get kernel version of source code
AC_MSG_CHECKING(that running and kernel source versions match)
SOURCE_VERSION=`grep '^VERSION' $KERNEL_DIR/Makefile | $AWK '{print$3;}'`
SOURCE_PATCHLEVEL=`grep '^PATCHLEVEL' $KERNEL_DIR/Makefile | $AWK '{print$3;}'`
SOURCE_SUBLEVEL=`grep '^SUBLEVEL' $KERNEL_DIR/Makefile | $AWK '{print$3;}'`
SOURCE_EXTRAVERSION=`grep '^EXTRAVERSION' $KERNEL_DIR/Makefile | $AWK '{print$3;}'`

SOURCE_VER="${SOURCE_VERSION}.${SOURCE_PATCHLEVEL}.${SOURCE_SUBLEVEL}${SOURCE_EXTRAVERSION}"

if test "$VER" = "$SOURCE_VER" ; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_MSG_WARN(Kernel source version $SOURCE_VER does not match running version. This kernel module may not work correctly)
fi

dnl make sure kernel is compiled for modules
AC_MSG_CHECKING(for kernel compiled with modules)
HAS_MODULE=`grep '^CONFIG_MODULES' $KERNEL_DIR/.config | cut -d= -f2`
if test "$HAS_MODULE" = "y" ; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_MSG_ERROR(Kernel must be recompiled with modules support)
fi 

dnl find modules directory
AC_MSG_CHECKING("modules directory")
if test \! -d /lib/modules ; then
  AC_MSG_RESULT(no)
  AC_MSG_ERROR(Could not find modules directory /lib/modules)
else
  if test \! -d /lib/modules/$VER ; then
    AC_MSG_RESULT(no)
    AC_MSG_ERROR(Could not find modules directory /lib/modules/$VER)
  else
    AC_MSG_RESULT([yes (/lib/modules/$VER)])
    MODULE_DIR=/lib/modules/$VER
  fi
fi

dnl check if phone module is already in kernel
AC_MSG_CHECKING("if kernel compiled with phone module")
HAS_MODULE=`grep '^CONFIG_PHONE' $KERNEL_DIR/.config | cut -d= -f2`
if test "$HAS_MODULE" = "y" ; then
  AC_MSG_RESULT(no)
  AC_MSG_ERROR(Change kernel to include CONFIG_PHONE as a module rather than built-in to kernel)
elif test "$HAS_MODULE" = "n" ; then
  AC_MSG_RESULT(no)
  AC_MSG_ERROR(Change kernel to include CONFIG_PHONE as a module)
else
  AC_MSG_RESULT(yes)
fi 

dnl check if USB support is in kernel
AC_MSG_CHECKING("for USB support in kernel")
HAS_MODULE=`grep '^CONFIG_USB=' $KERNEL_DIR/.config | cut -d= -f2`
if test "$HAS_MODULE" = "y" || test "$HAS_MODULE" = "m"; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_MSG_ERROR(Kernel must be recompiled with USB support)
fi 

dnl if kernel version if 2.4, check if ISAPNP is configured in kernel
if test $SOURCE_VERSION -eq 2 && test $SOURCE_PATCHLEVEL -ge 4 ; then
  AC_DEFINE(VOIP_KERNEL_TYPE, 2, standard 2.4 kernel)
  MODULE_DIR="$MODULE_DIR/kernel/drivers/telephony"
fi

dnl if kernel version is 2.2, check kill_fasync call
if test $SOURCE_VERSION -eq 2 && test $SOURCE_PATCHLEVEL -eq 2 ; then
  AC_DEFINE(VOIP_ASYNC_QUEUE, 1)

  dnl checking kill_fasync call
  AC_MSG_CHECKING("kernel for RedHat kill_fasync")
  if test -n "$with_redhat_kernel" ; then
    AC_MSG_RESULT([yes (forced)])
    AC_DEFINE(VOIP_KERNEL_TYPE, 1, Forced RedHat 2.2 kernel)
  else
    OLD_CFLAGS=$CFLAGS
    CFLAGS="$CFLAGS -Wall -D__KERNEL__ -DMODULE -I/usr/include"
    AC_TRY_COMPILE([#include <linux/fs.h>], {struct fasync_struct * a = 0; kill_fasync(a,0);}, VOIP_FASYNC_TYPE=0, VOIP_FASYNC_TYPE=1)
    if test "$VOIP_FASYNC_TYPE" = "1" ; then
      AC_MSG_RESULT("yes")
      AC_DEFINE(VOIP_KERNEL_TYPE, 1, RedHat 2.2 kernel)
    else
      AC_MSG_RESULT("no")
      AC_DEFINE(VOIP_KERNEL_TYPE, 0, standard 2.2 kernel)
    fi
    CFLAGS=$OLD_CFLAGS
  fi

  MODULE_DIR="$MODULE_DIR/misc"
fi
AC_SUBST(MODULE_DIR)

if test \! -n $VOIP_KERNEL_TYPE ; then
  AC_MSG_ERROR(Unable to configure for kernel version $SOURCE_VER)
fi

dnl check for phone devices
AC_MSG_CHECKING("for /dev/phone devices")
if test -c /dev/phone0 ; then
  AC_MSG_RESULT("yes")
else
  AC_MSG_RESULT("no")
  AC_MSG_WARN(Run phone_dev_create script when finished to create phone devices)
fi

dnl Checking for option to set maximum number of devices
AC_MSG_CHECKING("for max VOIP device count")
if test "$with_max_device_count" = "" ; then
  VOIP_MAX=4
elif test $with_max_device_count -lt 1 || test $with_max_device_count -gt 16 ; then
  AC_MSG_ERROR(Cannot set maximum number of devices to $with_max_device_count)
else
  VOIP_MAX=$with_max_device_count
fi
AC_MSG_RESULT($VOIP_MAX devices)
AC_SUBST(VOIP_MAX)

AC_OUTPUT(Makefile)