summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--acinclude.m489
-rwxr-xr-xbootstrap.sh25
-rwxr-xr-xbuild_tools/genmodconf107
-rwxr-xr-xbuild_tools/genudevrules35
-rwxr-xr-xbuild_tools/make_firmware_object.in11
-rwxr-xr-xbuild_tools/make_svn_branch_name61
-rwxr-xr-xbuild_tools/make_tree8
-rwxr-xr-xbuild_tools/make_version56
-rwxr-xr-xbuild_tools/make_version_h9
-rw-r--r--build_tools/menuselect-deps.in1
-rwxr-xr-xbuild_tools/test_kernel_git80
-rwxr-xr-xbuild_tools/uninstall-modules41
-rwxr-xr-xbuild_tools/zaptel_svn_tarball90
-rw-r--r--configure.ac132
14 files changed, 745 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644
index 0000000..b8cd151
--- /dev/null
+++ b/acinclude.m4
@@ -0,0 +1,89 @@
+# AST_EXT_LIB([NAME], [FUNCTION], [package header], [package symbol name], [package friendly name], [additional LIB data])
+
+AC_DEFUN([AST_EXT_LIB],
+[
+AC_ARG_WITH([$1], AC_HELP_STRING([--with-$1=PATH],[use $5 files in PATH]),[
+case ${withval} in
+ n|no)
+ USE_$4=no
+ ;;
+ y|ye|yes)
+ $4_MANDATORY="yes"
+ ;;
+ *)
+ $4_DIR="${withval}"
+ $4_MANDATORY="yes"
+ ;;
+esac
+])
+
+PBX_LIB$4=0
+
+if test "${USE_$4}" != "no"; then
+ pbxlibdir=""
+ if test "x${$4_DIR}" != "x"; then
+ pbxlibdir="-L${$1_DIR}/lib"
+ fi
+ AC_CHECK_LIB([$1], [$2], [AST_$4_FOUND=yes], [AST_$4_FOUND=no], ${pbxlibdir} $6)
+
+ if test "${AST_$4_FOUND}" = "yes"; then
+ $4_LIB="-l$1 $6"
+ $4_HEADER_FOUND="1"
+ if test "x${$4_DIR}" != "x"; then
+ $4_LIB="${pbxlibdir} ${$4_LIB}"
+ $4_INCLUDE="-I${$4_DIR}/include"
+ if test "x$3" != "x" ; then
+ AC_CHECK_HEADER([${$4_DIR}/include/$3], [$4_HEADER_FOUND=1], [$4_HEADER_FOUND=0] )
+ fi
+ else
+ if test "x$3" != "x" ; then
+ AC_CHECK_HEADER([$3], [$4_HEADER_FOUND=1], [$4_HEADER_FOUND=0] )
+ fi
+ fi
+ if test "x${$4_HEADER_FOUND}" = "x0" ; then
+ if test ! -z "${$4_MANDATORY}" ;
+ then
+ AC_MSG_NOTICE(***)
+ AC_MSG_NOTICE(*** It appears that you do not have the $1 development package installed.)
+ AC_MSG_NOTICE(*** Please install it to include $5 support, or re-run configure)
+ AC_MSG_NOTICE(*** without explicitly specifying --with-$1)
+ exit 1
+ fi
+ $4_LIB=""
+ $4_INCLUDE=""
+ PBX_LIB$4=0
+ else
+ PBX_LIB$4=1
+ AC_DEFINE_UNQUOTED([HAVE_$4], 1, [Define to indicate the $5 library])
+ fi
+ elif test ! -z "${$4_MANDATORY}";
+ then
+ AC_MSG_NOTICE(***)
+ AC_MSG_NOTICE(*** The $5 installation on this system appears to be broken.)
+ AC_MSG_NOTICE(*** Either correct the installation, or run configure)
+ AC_MSG_NOTICE(*** without explicity specifying --with-$1)
+ exit 1
+ fi
+fi
+AC_SUBST([$4_LIB])
+AC_SUBST([$4_INCLUDE])
+AC_SUBST([PBX_LIB$4])
+])
+
+
+AC_DEFUN(
+[AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
+ GNU_MAKE='Not Found' ;
+ for a in make gmake gnumake ; do
+ if test -z "$a" ; then continue ; fi ;
+ if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then
+ GNU_MAKE=$a ;
+ break;
+ fi
+ done ;
+) ;
+if test "x$GNU_MAKE" = "xNot Found" ; then
+ AC_MSG_ERROR(*** Please install GNU make. It is required to build Zaptel!)
+fi
+AC_SUBST([GNU_MAKE])
+])
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 0000000..b26b828
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+check_for_app() {
+ $1 --version 2>&1 >/dev/null
+ if [ $? != 0 ]
+ then
+ echo "Please install $1 and run bootstrap.sh again!"
+ exit 1
+ fi
+}
+
+AUTOCONF_VERSION=2.59
+AUTOMAKE_VERSION=1.9
+export AUTOCONF_VERSION
+export AUTOMAKE_VERSION
+
+check_for_app autoconf
+check_for_app automake
+check_for_app aclocal
+echo "Generating the configure script ..."
+aclocal 2>/dev/null
+autoconf
+automake --add-missing --copy 2>/dev/null
+
+exit 0
diff --git a/build_tools/genmodconf b/build_tools/genmodconf
new file mode 100755
index 0000000..ada453e
--- /dev/null
+++ b/build_tools/genmodconf
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+# this script makes an attempt to build a proper set of rules
+# for loading the Zaptel modules and automatically running ztcfg
+#
+# it accepts three parameters:
+# the kernel major version being targeted (either linux24 or linux26)
+# the root prefix to be used for finding/creating the files
+# the list of module names being installed
+#
+# the process is as follows:
+#
+# for linux24, the file can be located either at /etc/modules.conf (combined
+# with all other rules) or in /etc/modutils/zaptel (only the Zaptel rules)
+#
+# for linux26, the file can be located at /etc/modprobe.conf (combined with all
+# other rules), /etc/modprobe.d/zaptel (Zaptel only) or /etc/modules.d/zaptel
+# (Zaptel only)
+#
+# when the file is Zaptel rules only, then we don't preserve the existing
+# contents of the file; the system administrator can put desired options and
+# overrides in a separate file with a name that appears earlier in the sort
+# order, so there is no need to edit the file produced by this script
+#
+# when the file is combined with all other rules, then we make a backup
+# of it and remove all the old Zaptel rules we can find, replacing them with
+# new ones
+#
+# in addition, for linux26, versions of module-init-tools 3.2.0 and later
+# have the ability to pass module parameters specified on the modprobe command
+# line to commands in 'install' rules, thus keeping them from being lost, so
+# we try to determine what version is installed and take advantage of that
+
+if [ "${1}" = "linux24" ]; then
+ if [ -d ${2}/etc/modutils ]; then
+ target=${2}/etc/modutils/zaptel
+ elif [ -f ${2}/etc/modules.conf ]; then
+ target=${2}/etc/modules.conf
+ combined=1
+ else
+ echo No suitable location for module rules can be found... exiting.
+ exit 1
+ fi
+elif [ "${1}" = "linux26" ]; then
+ toolver=`/sbin/modprobe --version 2>/dev/null| awk '{print $3}' | cut -d. -f2 | cut -d- -f1`
+ if [ ${toolver} -ge 2 ]; then
+ cmdopts=\$CMDLINE_OPTS
+ fi
+ if [ -d ${2}/etc/modprobe.d ]; then
+ target=${2}/etc/modprobe.d/zaptel
+ elif [ -d ${2}/etc/modules.d ]; then
+ target=${2}/etc/modules.d/zaptel
+ elif [ -f ${2}/etc/modprobe.conf ]; then
+ target=${2}/etc/modprobe.conf
+ combined=1
+ elif [ -f ${2}/etc/conf.modules ]; then
+ target=${2}/etc/conf.modules
+ combined=1
+ else
+ echo No suitable location for module rules can be found... exiting.
+ exit 1
+ fi
+else
+ echo Unknown kernel build version requested... exiting.
+ exit 1
+fi
+
+if [ -n "${combined}" ]; then
+ if [ -f ${target} ]; then
+ mv ${target} ${target}.bak
+ cat ${target}.bak | grep -v "alias char-major-250" | grep -v "alias char-major-196" > ${target}
+ fi
+else
+ if [ -f ${target} ]; then
+ mv ${target} ${target}.bak
+ fi
+ echo "# automatically generated file; do not edit" > ${target}
+fi
+
+echo Building ${target}...
+
+if [ "${1}" = "linux24" ]; then
+ for mod in ${3}; do
+ if ! grep -q "post-install ${mod} " ${target}; then
+ echo "post-install ${mod} /sbin/ztcfg" >> ${target}
+ fi
+ done
+elif [ "${1}" = "linux26" ]; then
+ for mod in ${3}; do
+ if ! grep -q "install ${mod} " ${target}; then
+ echo "install ${mod} /sbin/modprobe --ignore-install ${mod} ${cmdopts} && /sbin/ztcfg" >> ${target}
+ fi
+ done
+fi
+
+if [ -z "${combined}" ]; then
+ echo "***"
+ echo "*** WARNING:"
+ echo "*** If you had custom settings in ${target},"
+ echo "*** they have been moved to ${target}.bak."
+ echo "***"
+ echo "*** In the future, do not edit ${target}, but"
+ echo "*** instead put your changes in another file"
+ echo "*** in the same directory so that they will not"
+ echo "*** be overwritten by future Zaptel updates."
+ echo "***"
+fi
diff --git a/build_tools/genudevrules b/build_tools/genudevrules
new file mode 100755
index 0000000..17e1f90
--- /dev/null
+++ b/build_tools/genudevrules
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+ver=`udevinfo -V | cut -f3 -d" "`
+
+if [ -z "${ver}" ]; then
+ # nobody has that old version, anyway.
+ ver=54
+fi
+
+# udev versions prior to 055 use a single '=' for matching key values
+# udev versions 055 and later support '==' for that purpose, and versions
+# beyond 092 will probably make it mandatory
+#
+# very old versions of udev required naming rules and permissions rules to be
+# in separate files, but it's not clear at what version number that changed
+
+if [ ${ver} -gt 54 ]; then
+ match="=="
+else
+ match="="
+fi
+
+cat <<EOF
+# udev rules to generate the /dev/zap device files (if not yet provided
+# by your distribution):
+KERNEL${match}"zapctl", NAME="zap/ctl"
+KERNEL${match}"zaptranscode", NAME="zap/transcode"
+KERNEL${match}"zaptimer", NAME="zap/timer"
+KERNEL${match}"zapchannel", NAME="zap/channel"
+KERNEL${match}"zappseudo", NAME="zap/pseudo"
+KERNEL${match}"zap[0-9]*", NAME="zap/%n"
+
+# zaptel devices with ownership/permissions for running as non-root
+SUBSYSTEM${match}"zaptel", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+EOF
diff --git a/build_tools/make_firmware_object.in b/build_tools/make_firmware_object.in
new file mode 100755
index 0000000..1c301a4
--- /dev/null
+++ b/build_tools/make_firmware_object.in
@@ -0,0 +1,11 @@
+#!/bin/sh -e
+
+# make an object file from a raw binary firmware file
+# arguments:
+# 1 - firmware file
+# 2 - output file
+
+bfdname=@BDFNAME@
+bfdarch=@BDFARCH@
+
+objcopy -I binary ${1} -B ${bfdarch} -O ${bfdname} ${2} --rename-section .data=.rodata,alloc,load,data,contents,readonly
diff --git a/build_tools/make_svn_branch_name b/build_tools/make_svn_branch_name
new file mode 100755
index 0000000..b4b712d
--- /dev/null
+++ b/build_tools/make_svn_branch_name
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+PARTS=`LANG=C svn info | grep URL | awk '{print $2;}' | sed -e s:^.*/svn/zaptel/:: | sed -e 's:/: :g'`
+BRANCH=0
+TEAM=0
+TAG=0
+
+REV=`svnversion -c . | cut -d: -f2`
+
+if [ "${PARTS}" = "trunk" ]
+then
+ echo 'trunk'-r${REV}
+ exit 0
+fi
+
+for PART in $PARTS
+do
+ if [ ${TAG} != 0 ]
+ then
+ RESULT="${PART}"
+ break
+ fi
+
+ if [ ${BRANCH} != 0 ]
+ then
+ RESULT="${RESULT}-${PART}"
+ break
+ fi
+
+ if [ ${TEAM} != 0 ]
+ then
+ RESULT="${RESULT}-${PART}"
+ continue
+ fi
+
+ if [ "${PART}" = "branches" ]
+ then
+ BRANCH=1
+ RESULT="branch"
+ continue
+ fi
+
+ if [ "${PART}" = "tags" ]
+ then
+ TAG=1
+ continue
+ fi
+
+ if [ "${PART}" = "team" ]
+ then
+ TEAM=1
+ continue
+ fi
+done
+
+if [ ${TAG} != 0 ]
+then
+ echo ${RESULT}
+else
+ echo ${RESULT##-}-r${REV}
+fi
diff --git a/build_tools/make_tree b/build_tools/make_tree
new file mode 100755
index 0000000..3ec5a6d
--- /dev/null
+++ b/build_tools/make_tree
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+echo "<?xml version=\"1.0\"?>"
+echo
+echo "<menu name=\"Zaptel Module Selection\">"
+cat zaptel.xml
+cat firmware/firmware.xml
+echo "</menu>"
diff --git a/build_tools/make_version b/build_tools/make_version
new file mode 100755
index 0000000..d710ffa
--- /dev/null
+++ b/build_tools/make_version
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+if [ -f ${1}/.version ]; then
+ cat ${1}.version
+elif [ -f ${1}/.svnrevision ]; then
+ echo SVN-`cat ${1}/.svnbranch`-r`cat ${1}/.svnrevision`
+elif [ -d .svn ]; then
+ PARTS=`LANG=C svn info ${1} | grep URL | awk '{print $2;}' | sed -e s:^.*/svn/zaptel/:: | sed -e 's:/: :g'`
+ BRANCH=0
+ TEAM=0
+
+ REV=`svnversion -c ${1} | cut -d: -f2`
+
+ if [ "${PARTS}" = "trunk" ]
+ then
+ echo SVN-'trunk'-r${REV}
+ exit 0
+ fi
+
+ for PART in $PARTS
+ do
+ if [ ${BRANCH} != 0 ]
+ then
+ RESULT="${RESULT}-${PART}"
+ break
+ fi
+
+ if [ ${TEAM} != 0 ]
+ then
+ RESULT="${RESULT}-${PART}"
+ continue
+ fi
+
+ if [ "${PART}" = "branches" ]
+ then
+ BRANCH=1
+ RESULT="branch"
+ continue
+ fi
+
+ if [ "${PART}" = "tags" ]
+ then
+ BRANCH=1
+ RESULT="tag"
+ continue
+ fi
+
+ if [ "${PART}" = "team" ]
+ then
+ TEAM=1
+ continue
+ fi
+ done
+
+ echo SVN-${RESULT##-}-r${REV}
+fi
diff --git a/build_tools/make_version_h b/build_tools/make_version_h
new file mode 100755
index 0000000..01d9c31
--- /dev/null
+++ b/build_tools/make_version_h
@@ -0,0 +1,9 @@
+#!/bin/sh
+cat << END
+/*
+ * version.h
+ * Automatically generated
+ */
+#define ZAPTEL_VERSION "${ZAPTELVERSION}"
+
+END
diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in
new file mode 100644
index 0000000..1c26316
--- /dev/null
+++ b/build_tools/menuselect-deps.in
@@ -0,0 +1 @@
+LIBNEWT=@PBX_LIBNEWT@
diff --git a/build_tools/test_kernel_git b/build_tools/test_kernel_git
new file mode 100755
index 0000000..59c196d
--- /dev/null
+++ b/build_tools/test_kernel_git
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+set -e
+
+GIT_URL=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
+CONF_FILE=build_tools/git_test.conf
+
+usage() {
+ me=`basename $0`
+ echo "$me: test building Zaptel vs. kernel from git"
+ echo "Usage:"
+ echo " $me checkout <kerneldir> Pull a kernel version into <kerneldir>"
+ echo " $me update Update (pull) the kernel tree."
+ echo " $me setver <kernel_ver> Set the kernel version"
+ echo " $me test Test-build"
+ echo ""
+ echo " $me versions [pattern] List available versions."
+}
+
+# Set a variable in $CONF_FILE
+# The format of CONF_FILE is assumed to be:
+# VAR=value
+# in shell syntax. "value" may be quoted.
+# "value should not contain a '|' character.
+set_var() {
+ var="$1"
+ val="$2"
+ if grep -q "^$var=" $CONF_FILE 2>/dev/null; then
+ sed -i -e "s|^$var=.*|$var=\"$val\"|" $CONF_FILE
+ else
+ echo "$var=\"$val\"" >>$CONF_FILE
+ fi
+}
+
+if [ -r "$CONF_FILE" ]; then . "$CONF_FILE"; fi
+
+if echo "$CONF_FILE" | grep -qv '^/'; then
+ # make CONF_FILE an absolute path:
+ CONF_FILE="$PWD/$CONF_FILE"
+fi
+
+command="$1"
+
+case "$command" in
+ checkout)
+ kernel_dir="$2"
+ cd "$kernel_dir"
+ git clone $GIT_URL
+ set_var kernel_dir "$kernel_dir/linux-2.6"
+ ;;
+ update)
+ cd "$kernel_dir"
+ git pull
+ ;;
+ versions)
+ cd "$kernel_dir"
+ git tag -l $2 | cut -c2-
+ ;;
+ setver)
+ kernel_ver="$2"
+ tag="v$kernel_ver"
+ cd "$kernel_dir"
+ git-reset --hard "$tag"
+ make defconfig prepare
+ set_var kernel_ver "$kernel_ver"
+ ;;
+ test)
+ # you can pass extra parameters to the make command in
+ # two ways:
+ # 1. Set th value of MAKE_PARAMS in git_test.conf .
+ # 2. Any extra command-line parameter.
+ shift
+ make KSRC="$kernel_dir" KVERS=$kernel_ver $MAKE_PARAMS "$@"
+ ;;
+ *)
+ echo "$0: no such command $command. Aborting."
+ usage
+ exit 1
+ ;;
+esac
diff --git a/build_tools/uninstall-modules b/build_tools/uninstall-modules
new file mode 100755
index 0000000..a654c21
--- /dev/null
+++ b/build_tools/uninstall-modules
@@ -0,0 +1,41 @@
+#!/bin/sh
+# uninstall-modules
+#
+# Remove all the modules passed in on the command line from the modules
+# directory. This script is called by the makefile.
+
+KERNEL_MODULES_DIR=$1
+shift
+MODULES="$*"
+
+usage() {
+ echo "$0: Used to delete kernel modules from the modules directory."
+ echo ""
+ echo "Usage:"
+ echo " $0 MODULES_BASE_DIR mod1 [mod2 [...]]"
+ echo ""
+ echo " MODULES_BASE_DIR - typically /lib/modules/KVERS"
+ echo " modN - (optionally partial) module name to remove."
+}
+
+if [ -z "$KERNEL_MODULES_DIR" ]; then
+ echo "Missing kernel module directory."
+ usage
+ exit 1;
+fi
+
+if [ -z "$MODULES" ]; then
+ echo "Missing one or more modules to delete."
+ usage
+ exit 1;
+fi
+for mod in $MODULES; do
+ BASE=`basename $mod`
+ for file in `cat $KERNEL_MODULES_DIR/modules.dep | cut -d : -f 1 | grep "$BASE$"`; do
+ if [ -e "$file" ]; then
+ #echo "Deleting $file."
+ rm -f $file
+ fi
+ done
+done
+exit 0
diff --git a/build_tools/zaptel_svn_tarball b/build_tools/zaptel_svn_tarball
new file mode 100755
index 0000000..38a6ce8
--- /dev/null
+++ b/build_tools/zaptel_svn_tarball
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+# upload_zaptel: upload a zaptel tarball to updates.xorcom.com
+#
+
+set -e
+
+BRANCH_NAME=1.4
+REV=HEAD
+ZAPTEL_BASE=http://svn.digium.com/svn/zaptel
+TARBALLS_DIR=$PWD
+
+me=`basename $0`
+
+say() {
+ echo "$me: $@"
+}
+
+usage() {
+ echo >&2 "$0: Generate snapshot from Zaptel SVN"
+ echo >&2 ' ($Id$)'
+ echo >&2 ""
+ echo >&2 "$0 [-r REV] [-2] [-s]"
+ echo >&2 "$0 <-h | --help>: This message"
+ echo >&2 ""
+ echo >&2 "Options:"
+ echo >&2 " -2 --zap12: Use Asterisk 1.2. Implies -u."
+ echo >&2 " -r --rev REV: extract xpp-zaptel from this revision ($REV)."
+ echo >&2 " -s --show: Just show versions. Do nothing"
+
+}
+
+opt_showonly=no
+
+options=`getopt -o 2hr:s --long zap12,help,rev:,revision:,show -- "$@"`
+if [ $? != 0 ] ; then echo >&2 "Terminating..." ; exit 1 ; fi
+
+# Note the quotes around `$TEMP': they are essential!
+eval set -- "$options"
+
+while true ; do
+ case "$1" in
+ -2|--zap12) BRANCH_NAME=1.2;;
+ -s|--show) opt_showonly=yes ;;
+ -r|--rev|--revision) REV="$2"; shift ;;
+ -h|--help) usage; exit 0;;
+ --) shift ; break ;;
+ esac
+ shift;
+done
+
+BRANCH=branches/$BRANCH_NAME
+ZAPTEL_URL=$ZAPTEL_BASE/$BRANCH
+
+set -e
+
+# Get the name of the "previous version" for this release.
+# The idea is to look at the latest tag for that branhch. Tags are
+# global, and hence we filter tag names by branch name.
+#
+# Note: this strips any minor version number.
+# e.g: if last releast was 1.4.5.1, this will still return 1.4.5 . Here
+# we rely on the fact that the revision number will be added.
+zap_ver=`svn ls -r $REV $ZAPTEL_BASE/tags | grep "^$BRANCH_NAME" \
+ | sed -e "s/\($BRANCH_NAME\.[0-9]\+\)[/.-].*/\1/" \
+ | sort -nu -t . -k 3 | tail -n 1`
+
+real_rev=`svn info -r $REV $ZAPTEL_URL \
+ | awk '/^Last Changed Rev: /{print $4}'`
+
+ver_full="$zap_ver.9.svn.$real_rev"
+tar_name="zaptel-$ver_full"
+tar_ball_full="$TARBALLS_DIR/$tar_name.tar.gz"
+
+say "Version: $ver_full (ver: $zap_ver, rev: $real_rev)"
+say "Tarball: $tar_ball_full"
+
+if [ "$opt_showonly" = 'yes' ]; then
+ exit 0;
+fi
+
+ZAP_CHECKOUT_DIR=`mktemp -d zaptel_checkout_dir_XXXXXX`
+
+# Package a tarball from the subversion, using 'make dist':
+svn export -q -r $REV $ZAPTEL_URL $ZAP_CHECKOUT_DIR/$tar_name
+echo "$ver_full" >$ZAP_CHECKOUT_DIR/$tar_name/.version
+tar cz -C $ZAP_CHECKOUT_DIR -f $tar_ball_full $tar_name
+
+rm -rf $ZAP_CHECKOUT_DIR
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..bda6cd0
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,132 @@
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.59)
+
+m4_define([ZAP_VERSION],
+ m4_bpatsubst(m4_esyscmd([build_tools/make_version .]),
+ [\([0-9.]*\)\(\w\|\W\)*],
+ [\1]))
+AC_INIT(zaptel, ZAP_VERSION, www.asterisk.org)
+
+# check existence of the package
+AC_CONFIG_SRCDIR([kernel/zaptel-base.c])
+
+AC_COPYRIGHT("Zaptel")
+AC_REVISION($Revision$)
+
+ac_default_prefix=/usr
+if test ${sysconfdir} = '${prefix}/etc'; then
+ sysconfdir=/etc
+fi
+if test ${mandir} = '${prefix}/man'; then
+ mandir=/usr/share/man
+fi
+
+if test ${localstatedir} = '${prefix}/var'; then
+ localstatedir=/var
+fi
+
+# This needs to be before any macros that use the C compiler
+AC_GNU_SOURCE
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AST_CHECK_GNU_MAKE
+
+test_obj=conftest.o
+AC_COMPILE_IFELSE(AC_LANG_SOURCE(),[
+ BDFNAME=`LANG=C objdump -f $test_obj | grep -e "$test_obj:" | sed "s/.*file format \(.*\)/\1/"`
+ BDFARCH=`LANG=C objdump -f $test_obj | grep -e "architecture:" | sed "s/.*ture: \(.*\),.*/\1/"`
+],[])
+AC_SUBST(BDFNAME)
+AC_SUBST(BDFARCH)
+
+# Set the default value of HOSTCC from CC if --host was not provided:
+HOSTCC=${HOSTCC:=${CC}}
+AC_SUBST(HOSTCC)
+
+AC_PATH_PROG([GREP], [grep], :)
+AC_PATH_PROG([SHELL], [sh], :)
+AC_PATH_PROG([LN], [ln], :)
+
+AC_PATH_PROG([WGET], [wget], :)
+if test "${WGET}" != ":" ; then
+ DOWNLOAD=${WGET}
+else
+ AC_PATH_PROG([FETCH], [fetch], [:])
+ DOWNLOAD=${FETCH}
+fi
+AC_SUBST(DOWNLOAD)
+
+AC_LANG(C)
+
+AST_EXT_LIB([curses], [initscr], [curses.h], [CURSES], [curses], [])
+AST_EXT_LIB([ncurses], [initscr], [curses.h], [NCURSES], [ncurses], [])
+AST_EXT_LIB([newt], [newtBell], [newt.h], [NEWT], [newt])
+AST_EXT_LIB([usb], [usb_init], [usb.h], [USB], [libusb])
+
+AC_ARG_WITH(selinux,
+ [AS_HELP_STRING([--with-selinux],
+ [enable (with) / disable (without) SELinux])],
+ [USE_SELINUX=$withval],
+ [ if test ! -x /usr/sbin/sestatus; then
+ USE_SELINUX=no;
+ elif /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"; then
+ USE_SELINUX=yes
+ fi
+ ]
+)
+
+
+AC_SUBST(USE_SELINUX)
+
+# for asciidoc before ver. 7, the backend must be stated explicitly:
+ASCIIDOC='asciidoc'
+asciidoc_ver=`asciidoc --version 2>&1 | awk '/^asciidoc /{print $2}' | cut -d. -f 1 | head -n 1`
+if test "$asciidoc_ver" != '' && test $asciidoc_ver -lt 7; then
+ ASCIIDOC="asciidoc -b xhtml"
+fi
+AC_SUBST(ASCIIDOC)
+
+AC_ARG_WITH(ppp,
+ [AS_HELP_STRING([--with-ppp=PATH],[Use ppp support from PATH])],
+ [],
+ [with_ppp=check]
+ )
+# somebody will fix that
+default_ppp_path=/usr
+
+case "$with_ppp" in
+ yes|check) ppp_path="$default_ppp_path";;
+ no) ppp_path='' ;;
+ *) ppp_path="$with_ppp" ;;
+esac
+
+level_file="$ppp_path/include/pppd/patchlevel.h"
+PPP_VERSION=
+if test "$ppp_path" != '' && test -r "$level_file"; then
+ PPPD_VERSION=`awk -F '"' '/VERSION/ { print $$2; }' $level_file`
+fi
+
+case "$with_ppp" in
+ check|no) :;;
+ *)
+ # If we asked explicitly for ppp support
+ if test "$PPPD_VERSION" = ''; then
+ # but have not detected it
+ AC_MSG_ERROR(failed to find pppd/patchlevel.h: no ppp support.)
+ fi
+ ;;
+esac
+
+AC_SUBST(PPPD_VERSION)
+
+AC_CONFIG_FILES([build_tools/menuselect-deps makeopts build_tools/make_firmware_object])
+AC_OUTPUT
+chmod a+x build_tools/make_firmware_object
+
+AC_MSG_NOTICE(*** Zaptel build successfully configured ***)
+