diff --git a/apps/Makefile b/apps/Makefile
index 2fdde40b407026f93ad7739a6e488f1ad3cc5ebb..a48477abe2488272dda3c1ba2bbee99f0506cdc2 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -35,9 +35,12 @@ clean: clean-depend
 	$(CC) $(SOLINK) -o $@ $<
 
 app_rpt.so: app_rpt.o
-	$(CC) $(SOLINK) -o $@ $< $(ZAPTEL_LIB)
+	$(CC) $(SOLINK) -o $@ $< $(TONEZONE_LIB)
 
 app_rpt.o: app_rpt.c
+	$(CC) -c -o $@ $(CFLAGS) $(TONEZONE_INCLUDE) $(ZAPTEL_INCLUDE) $<
+
+app_flash.o app_meetme.o app_page.o app_zapbarge.o app_zapras.o app_zapscan.o: %.o: %.c
 	$(CC) -c -o $@ $(CFLAGS) $(ZAPTEL_INCLUDE) $<
 
 install: all
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index 7ea1e147b03af52f5585a589e2909b50a5926a29..c18fc20715e01d1063feda02168b0310d966de0a 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -118,6 +118,7 @@
 
 /*** MODULEINFO
 	<depend>zaptel</depend>
+	<depend>tonezone</depend>
 	<defaultenabled>no</defaultenabled>
  ***/
 
diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in
index df89532c6e8ef2423f3828f22a7ee688182561f9..968e16dc39daca91f6bedf628792c21e1fa5c0a7 100644
--- a/build_tools/menuselect-deps.in
+++ b/build_tools/menuselect-deps.in
@@ -22,7 +22,8 @@ UNIXODBC=@PBX_LIBUNIXODBC@
 VPBAPI=@PBX_LIBvpb@
 WIN32=@OSISWIN32@
 ZLIB=@PBX_LIBZLIB@
-ZAPTEL=@PBX_LIBZAPTEL@
+TONEZONE=@PBX_LIBTONEZONE@
+ZAPTEL=@PBX_ZAPTEL@
 LIBGSM=@PBX_LIBgsm@
 IKSEMEL=@PBX_LIBIKSEMEL@
 IXJUSER=@PBX_IXJUSER@
diff --git a/channels/Makefile b/channels/Makefile
index a231ded1f53b55d3598a28ab81d8dbb2270eca6f..c98af29d0dadb7db689a2dff9ad5e5a3973a98f0 100644
--- a/channels/Makefile
+++ b/channels/Makefile
@@ -113,13 +113,13 @@ chan_oss.so: chan_oss.o
 	$(CC) $(SOLINK) -o $@ chan_oss.o $(OSSAUDIO_LIB)
 
 chan_iax2.so: chan_iax2.o iax2-parser.o iax2-provision.o
-	$(CC) $(SOLINK) -o $@ $< iax2-parser.o iax2-provision.o
+	$(CC) $(SOLINK) -o $@ $^
 
 chan_zap.so: chan_zap.o
-	$(CC) $(SOLINK) -o $@ $< $(PRI_LIB) $(ZAPTEL_LIB)
+	$(CC) $(SOLINK) -o $@ $< $(PRI_LIB) $(TONEZONE_LIB)
 
 chan_zap.o: chan_zap.c
-	$(CC) -c -o $@ $(CFLAGS) $(ZAPTEL_INCLUDE) $<
+	$(CC) -c -o $@ $(CFLAGS) $(TONEZONE_INCLUDE) $(ZAPTEL_INCLUDE) $<
 
 chan_alsa.so: chan_alsa.o
 	$(CC) $(SOLINK) -o $@ $< $(ASOUND_LIB)
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 2f8e767f8e077d9c99a1edca150604e9a1991a53..47599e4d97ca01453ba47c60193bc2394af7558a 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -39,6 +39,7 @@
 
 /*** MODULEINFO
 	<depend>zaptel</depend>
+	<depend>tonezone</depend>
  ***/
 
 #include "asterisk.h"
diff --git a/codecs/Makefile b/codecs/Makefile
index d6e304be204ce816453ef74692b9871b8a829709..25eb4c46cf2de2803c34144e2a9126d4ad08acea 100644
--- a/codecs/Makefile
+++ b/codecs/Makefile
@@ -92,6 +92,9 @@ codec_speex.so: codec_speex.o
 codec_lpc10.so: codec_lpc10.o $(LIBLPC10)
 	$(CC) $(SOLINK) -o $@ $< $(LIBLPC10) -lm
 
+codec_zap.o: codec_zap.c
+	$(CC) -c -o $@ $(CFLAGS) $(ZAPTEL_INCLUDE) $<
+
 %.so : %.o
 	$(CC) $(SOLINK) -o $@ $<
 
diff --git a/configure b/configure
index 9a311b0f26d578598abd52cf606f625e344bdac0..9e5d49674e1caa0987da9beee3f0f66e0cb4225e 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 35439 .
+# From configure.ac Revision: 35607 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59e.
 #
@@ -755,9 +755,11 @@ EDITLINE_LIBS
 OSS_LIB
 OSS_INCLUDE
 PBX_LIBOSS
-ZAPTEL_LIB
+TONEZONE_LIB
+TONEZONE_INCLUDE
+PBX_LIBTONEZONE
 ZAPTEL_INCLUDE
-PBX_LIBZAPTEL
+PBX_ZAPTEL
 gsm_LIB
 gsm_INCLUDE
 PBX_LIBgsm
@@ -1410,7 +1412,8 @@ Optional Packages:
   --with-vorbis=PATH      use Vorbis files in PATH
   --with-z=PATH           use zlib files in PATH
   --with-ossaudio=PATH    use Open Sound System files in PATH
-  --with-tonezone=PATH    use Zaptel files in PATH
+  --with-tonezone=PATH    use tonezone files in PATH
+  --with-zaptel=PATH      use Zaptel files in PATH
   --with-gsm=PATH         use libgsm files in PATH, or 'internal'
   --with-pq=PATH          use PostgreSQL files in PATH
   --with-vpb=PATH         use vpb files in PATH
@@ -16249,25 +16252,25 @@ if test "${with_tonezone+set}" = set; then
   withval=$with_tonezone;
 case ${withval} in
      n|no)
-     USE_ZAPTEL=no
+     USE_TONEZONE=no
      ;;
      y|ye|yes)
-     ZAPTEL_MANDATORY="yes"
+     TONEZONE_MANDATORY="yes"
      ;;
      *)
-     ZAPTEL_DIR="${withval}"
-     ZAPTEL_MANDATORY="yes"
+     TONEZONE_DIR="${withval}"
+     TONEZONE_MANDATORY="yes"
      ;;
 esac
 
 fi
 
 
-PBX_LIBZAPTEL=0
+PBX_LIBTONEZONE=0
 
-if test "${USE_ZAPTEL}" != "no"; then
+if test "${USE_TONEZONE}" != "no"; then
    pbxlibdir=""
-   if test "x${ZAPTEL_DIR}" != "x"; then
+   if test "x${TONEZONE_DIR}" != "x"; then
       pbxlibdir="-L${tonezone_DIR}/lib"
    fi
    { echo "$as_me:$LINENO: checking for tone_zone_find in -ltonezone" >&5
@@ -16348,23 +16351,23 @@ fi
 { echo "$as_me:$LINENO: result: $ac_cv_lib_tonezone_tone_zone_find" >&5
 echo "${ECHO_T}$ac_cv_lib_tonezone_tone_zone_find" >&6; }
 if test $ac_cv_lib_tonezone_tone_zone_find = yes; then
-  AST_ZAPTEL_FOUND=yes
+  AST_TONEZONE_FOUND=yes
 else
-  AST_ZAPTEL_FOUND=no
+  AST_TONEZONE_FOUND=no
 fi
 
 
-   if test "${AST_ZAPTEL_FOUND}" = "yes"; then
-      ZAPTEL_LIB="-ltonezone "
-      ZAPTEL_HEADER_FOUND="1"
-      if test "x${ZAPTEL_DIR}" != "x"; then
-         ZAPTEL_LIB="${pbxlibdir} ${ZAPTEL_LIB}"
-	 ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
-	 if test "xlinux/zaptel.h" != "x" ; then
-	    as_ac_Header=`echo "ac_cv_header_${ZAPTEL_DIR}/include/linux/zaptel.h" | $as_tr_sh`
+   if test "${AST_TONEZONE_FOUND}" = "yes"; then
+      TONEZONE_LIB="-ltonezone "
+      TONEZONE_HEADER_FOUND="1"
+      if test "x${TONEZONE_DIR}" != "x"; then
+         TONEZONE_LIB="${pbxlibdir} ${TONEZONE_LIB}"
+	 TONEZONE_INCLUDE="-I${TONEZONE_DIR}/include"
+	 if test "xtonezone.h" != "x" ; then
+	    as_ac_Header=`echo "ac_cv_header_${TONEZONE_DIR}/include/tonezone.h" | $as_tr_sh`
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for ${ZAPTEL_DIR}/include/linux/zaptel.h" >&5
-echo $ECHO_N "checking for ${ZAPTEL_DIR}/include/linux/zaptel.h... $ECHO_C" >&6; }
+  { echo "$as_me:$LINENO: checking for ${TONEZONE_DIR}/include/tonezone.h" >&5
+echo $ECHO_N "checking for ${TONEZONE_DIR}/include/tonezone.h... $ECHO_C" >&6; }
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 fi
@@ -16373,8 +16376,8 @@ ac_res=`eval echo '${'$as_ac_Header'}'`
 echo "${ECHO_T}$ac_res" >&6; }
 else
   # Is the header compilable?
-{ echo "$as_me:$LINENO: checking ${ZAPTEL_DIR}/include/linux/zaptel.h usability" >&5
-echo $ECHO_N "checking ${ZAPTEL_DIR}/include/linux/zaptel.h usability... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking ${TONEZONE_DIR}/include/tonezone.h usability" >&5
+echo $ECHO_N "checking ${TONEZONE_DIR}/include/tonezone.h usability... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -16382,7 +16385,7 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-#include <${ZAPTEL_DIR}/include/linux/zaptel.h>
+#include <${TONEZONE_DIR}/include/tonezone.h>
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -16431,15 +16434,15 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 echo "${ECHO_T}$ac_header_compiler" >&6; }
 
 # Is the header present?
-{ echo "$as_me:$LINENO: checking ${ZAPTEL_DIR}/include/linux/zaptel.h presence" >&5
-echo $ECHO_N "checking ${ZAPTEL_DIR}/include/linux/zaptel.h presence... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking ${TONEZONE_DIR}/include/tonezone.h presence" >&5
+echo $ECHO_N "checking ${TONEZONE_DIR}/include/tonezone.h presence... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <${ZAPTEL_DIR}/include/linux/zaptel.h>
+#include <${TONEZONE_DIR}/include/tonezone.h>
 _ACEOF
 if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
@@ -16479,30 +16482,30 @@ echo "${ECHO_T}$ac_header_preproc" >&6; }
 # So?  What about this header?
 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
   yes:no: )
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: proceeding with the compiler's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: proceeding with the compiler's result" >&2;}
     ac_header_preproc=yes
     ;;
   no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/linux/zaptel.h: in the future, the compiler will take precedence" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: in the future, the compiler will take precedence" >&2;}
 
     ;;
 esac
-{ echo "$as_me:$LINENO: checking for ${ZAPTEL_DIR}/include/linux/zaptel.h" >&5
-echo $ECHO_N "checking for ${ZAPTEL_DIR}/include/linux/zaptel.h... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking for ${TONEZONE_DIR}/include/tonezone.h" >&5
+echo $ECHO_N "checking for ${TONEZONE_DIR}/include/tonezone.h... $ECHO_C" >&6; }
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -16514,27 +16517,27 @@ echo "${ECHO_T}$ac_res" >&6; }
 
 fi
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  ZAPTEL_HEADER_FOUND=1
+  TONEZONE_HEADER_FOUND=1
 else
-  ZAPTEL_HEADER_FOUND=0
+  TONEZONE_HEADER_FOUND=0
 fi
 
 
 	 fi
       else
-	 if test "xlinux/zaptel.h" != "x" ; then
-            if test "${ac_cv_header_linux_zaptel_h+set}" = set; then
-  { echo "$as_me:$LINENO: checking for linux/zaptel.h" >&5
-echo $ECHO_N "checking for linux/zaptel.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_linux_zaptel_h+set}" = set; then
+	 if test "xtonezone.h" != "x" ; then
+            if test "${ac_cv_header_tonezone_h+set}" = set; then
+  { echo "$as_me:$LINENO: checking for tonezone.h" >&5
+echo $ECHO_N "checking for tonezone.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_tonezone_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_linux_zaptel_h" >&5
-echo "${ECHO_T}$ac_cv_header_linux_zaptel_h" >&6; }
+{ echo "$as_me:$LINENO: result: $ac_cv_header_tonezone_h" >&5
+echo "${ECHO_T}$ac_cv_header_tonezone_h" >&6; }
 else
   # Is the header compilable?
-{ echo "$as_me:$LINENO: checking linux/zaptel.h usability" >&5
-echo $ECHO_N "checking linux/zaptel.h usability... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking tonezone.h usability" >&5
+echo $ECHO_N "checking tonezone.h usability... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -16542,7 +16545,7 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-#include <linux/zaptel.h>
+#include <tonezone.h>
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -16591,15 +16594,15 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 echo "${ECHO_T}$ac_header_compiler" >&6; }
 
 # Is the header present?
-{ echo "$as_me:$LINENO: checking linux/zaptel.h presence" >&5
-echo $ECHO_N "checking linux/zaptel.h presence... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking tonezone.h presence" >&5
+echo $ECHO_N "checking tonezone.h presence... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <linux/zaptel.h>
+#include <tonezone.h>
 _ACEOF
 if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
@@ -16639,72 +16642,72 @@ echo "${ECHO_T}$ac_header_preproc" >&6; }
 # So?  What about this header?
 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
   yes:no: )
-    { echo "$as_me:$LINENO: WARNING: linux/zaptel.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: linux/zaptel.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: linux/zaptel.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: linux/zaptel.h: proceeding with the compiler's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: tonezone.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: tonezone.h: proceeding with the compiler's result" >&2;}
     ac_header_preproc=yes
     ;;
   no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: linux/zaptel.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: linux/zaptel.h: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: linux/zaptel.h:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: linux/zaptel.h:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: linux/zaptel.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: linux/zaptel.h: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: linux/zaptel.h:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: linux/zaptel.h:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: linux/zaptel.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: linux/zaptel.h: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: linux/zaptel.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: linux/zaptel.h: in the future, the compiler will take precedence" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: tonezone.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: tonezone.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: tonezone.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: tonezone.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: tonezone.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: tonezone.h: in the future, the compiler will take precedence" >&2;}
 
     ;;
 esac
-{ echo "$as_me:$LINENO: checking for linux/zaptel.h" >&5
-echo $ECHO_N "checking for linux/zaptel.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_linux_zaptel_h+set}" = set; then
+{ echo "$as_me:$LINENO: checking for tonezone.h" >&5
+echo $ECHO_N "checking for tonezone.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_tonezone_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_cv_header_linux_zaptel_h=$ac_header_preproc
+  ac_cv_header_tonezone_h=$ac_header_preproc
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_linux_zaptel_h" >&5
-echo "${ECHO_T}$ac_cv_header_linux_zaptel_h" >&6; }
+{ echo "$as_me:$LINENO: result: $ac_cv_header_tonezone_h" >&5
+echo "${ECHO_T}$ac_cv_header_tonezone_h" >&6; }
 
 fi
-if test $ac_cv_header_linux_zaptel_h = yes; then
-  ZAPTEL_HEADER_FOUND=1
+if test $ac_cv_header_tonezone_h = yes; then
+  TONEZONE_HEADER_FOUND=1
 else
-  ZAPTEL_HEADER_FOUND=0
+  TONEZONE_HEADER_FOUND=0
 fi
 
 
 	 fi
       fi
-      if test "x${ZAPTEL_HEADER_FOUND}" = "x0" ; then
-         if test ! -z "${ZAPTEL_MANDATORY}" ;
+      if test "x${TONEZONE_HEADER_FOUND}" = "x0" ; then
+         if test ! -z "${TONEZONE_MANDATORY}" ;
          then
             echo " ***"
             echo " *** It appears that you do not have the tonezone development package installed."
-            echo " *** Please install it to include Zaptel support, or re-run configure"
+            echo " *** Please install it to include tonezone support, or re-run configure"
             echo " *** without explicitly specifying --with-tonezone"
             exit 1
          fi
-         ZAPTEL_LIB=""
-         ZAPTEL_INCLUDE=""
-         PBX_LIBZAPTEL=0
+         TONEZONE_LIB=""
+         TONEZONE_INCLUDE=""
+         PBX_LIBTONEZONE=0
       else
-         PBX_LIBZAPTEL=1
+         PBX_LIBTONEZONE=1
 
 cat >>confdefs.h <<_ACEOF
-#define HAVE_ZAPTEL 1
+#define HAVE_TONEZONE 1
 _ACEOF
 
       fi
-   elif test ! -z "${ZAPTEL_MANDATORY}";
+   elif test ! -z "${TONEZONE_MANDATORY}";
    then
       echo "***"
-      echo "*** The Zaptel installation on this system appears to be broken."
+      echo "*** The tonezone installation on this system appears to be broken."
       echo "*** Either correct the installation, or run configure"
       echo "*** without explicity specifying --with-tonezone"
       exit 1
@@ -16722,25 +16725,25 @@ if test "${with_tonezone+set}" = set; then
   withval=$with_tonezone;
 case ${withval} in
      n|no)
-     USE_ZAPTEL=no
+     USE_TONEZONE=no
      ;;
      y|ye|yes)
-     ZAPTEL_MANDATORY="yes"
+     TONEZONE_MANDATORY="yes"
      ;;
      *)
-     ZAPTEL_DIR="${withval}"
-     ZAPTEL_MANDATORY="yes"
+     TONEZONE_DIR="${withval}"
+     TONEZONE_MANDATORY="yes"
      ;;
 esac
 
 fi
 
 
-PBX_LIBZAPTEL=0
+PBX_LIBTONEZONE=0
 
-if test "${USE_ZAPTEL}" != "no"; then
+if test "${USE_TONEZONE}" != "no"; then
    pbxlibdir=""
-   if test "x${ZAPTEL_DIR}" != "x"; then
+   if test "x${TONEZONE_DIR}" != "x"; then
       pbxlibdir="-L${tonezone_DIR}/lib"
    fi
    { echo "$as_me:$LINENO: checking for tone_zone_find in -ltonezone" >&5
@@ -16821,23 +16824,23 @@ fi
 { echo "$as_me:$LINENO: result: $ac_cv_lib_tonezone_tone_zone_find" >&5
 echo "${ECHO_T}$ac_cv_lib_tonezone_tone_zone_find" >&6; }
 if test $ac_cv_lib_tonezone_tone_zone_find = yes; then
-  AST_ZAPTEL_FOUND=yes
+  AST_TONEZONE_FOUND=yes
 else
-  AST_ZAPTEL_FOUND=no
+  AST_TONEZONE_FOUND=no
 fi
 
 
-   if test "${AST_ZAPTEL_FOUND}" = "yes"; then
-      ZAPTEL_LIB="-ltonezone -lm"
-      ZAPTEL_HEADER_FOUND="1"
-      if test "x${ZAPTEL_DIR}" != "x"; then
-         ZAPTEL_LIB="${pbxlibdir} ${ZAPTEL_LIB}"
-	 ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
-	 if test "xzaptel.h" != "x" ; then
-	    as_ac_Header=`echo "ac_cv_header_${ZAPTEL_DIR}/include/zaptel.h" | $as_tr_sh`
+   if test "${AST_TONEZONE_FOUND}" = "yes"; then
+      TONEZONE_LIB="-ltonezone -lm"
+      TONEZONE_HEADER_FOUND="1"
+      if test "x${TONEZONE_DIR}" != "x"; then
+         TONEZONE_LIB="${pbxlibdir} ${TONEZONE_LIB}"
+	 TONEZONE_INCLUDE="-I${TONEZONE_DIR}/include"
+	 if test "xtonezone.h" != "x" ; then
+	    as_ac_Header=`echo "ac_cv_header_${TONEZONE_DIR}/include/tonezone.h" | $as_tr_sh`
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for ${ZAPTEL_DIR}/include/zaptel.h" >&5
-echo $ECHO_N "checking for ${ZAPTEL_DIR}/include/zaptel.h... $ECHO_C" >&6; }
+  { echo "$as_me:$LINENO: checking for ${TONEZONE_DIR}/include/tonezone.h" >&5
+echo $ECHO_N "checking for ${TONEZONE_DIR}/include/tonezone.h... $ECHO_C" >&6; }
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 fi
@@ -16846,8 +16849,8 @@ ac_res=`eval echo '${'$as_ac_Header'}'`
 echo "${ECHO_T}$ac_res" >&6; }
 else
   # Is the header compilable?
-{ echo "$as_me:$LINENO: checking ${ZAPTEL_DIR}/include/zaptel.h usability" >&5
-echo $ECHO_N "checking ${ZAPTEL_DIR}/include/zaptel.h usability... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking ${TONEZONE_DIR}/include/tonezone.h usability" >&5
+echo $ECHO_N "checking ${TONEZONE_DIR}/include/tonezone.h usability... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -16855,7 +16858,7 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-#include <${ZAPTEL_DIR}/include/zaptel.h>
+#include <${TONEZONE_DIR}/include/tonezone.h>
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -16904,15 +16907,15 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 echo "${ECHO_T}$ac_header_compiler" >&6; }
 
 # Is the header present?
-{ echo "$as_me:$LINENO: checking ${ZAPTEL_DIR}/include/zaptel.h presence" >&5
-echo $ECHO_N "checking ${ZAPTEL_DIR}/include/zaptel.h presence... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking ${TONEZONE_DIR}/include/tonezone.h presence" >&5
+echo $ECHO_N "checking ${TONEZONE_DIR}/include/tonezone.h presence... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <${ZAPTEL_DIR}/include/zaptel.h>
+#include <${TONEZONE_DIR}/include/tonezone.h>
 _ACEOF
 if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
@@ -16952,30 +16955,30 @@ echo "${ECHO_T}$ac_header_preproc" >&6; }
 # So?  What about this header?
 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
   yes:no: )
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: proceeding with the compiler's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: proceeding with the compiler's result" >&2;}
     ac_header_preproc=yes
     ;;
   no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/zaptel.h:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/zaptel.h:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/zaptel.h:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/zaptel.h:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: ${ZAPTEL_DIR}/include/zaptel.h: in the future, the compiler will take precedence" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${TONEZONE_DIR}/include/tonezone.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: ${TONEZONE_DIR}/include/tonezone.h: in the future, the compiler will take precedence" >&2;}
 
     ;;
 esac
-{ echo "$as_me:$LINENO: checking for ${ZAPTEL_DIR}/include/zaptel.h" >&5
-echo $ECHO_N "checking for ${ZAPTEL_DIR}/include/zaptel.h... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking for ${TONEZONE_DIR}/include/tonezone.h" >&5
+echo $ECHO_N "checking for ${TONEZONE_DIR}/include/tonezone.h... $ECHO_C" >&6; }
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -16987,27 +16990,27 @@ echo "${ECHO_T}$ac_res" >&6; }
 
 fi
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  ZAPTEL_HEADER_FOUND=1
+  TONEZONE_HEADER_FOUND=1
 else
-  ZAPTEL_HEADER_FOUND=0
+  TONEZONE_HEADER_FOUND=0
 fi
 
 
 	 fi
       else
-	 if test "xzaptel.h" != "x" ; then
-            if test "${ac_cv_header_zaptel_h+set}" = set; then
-  { echo "$as_me:$LINENO: checking for zaptel.h" >&5
-echo $ECHO_N "checking for zaptel.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_zaptel_h+set}" = set; then
+	 if test "xtonezone.h" != "x" ; then
+            if test "${ac_cv_header_tonezone_h+set}" = set; then
+  { echo "$as_me:$LINENO: checking for tonezone.h" >&5
+echo $ECHO_N "checking for tonezone.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_tonezone_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_zaptel_h" >&5
-echo "${ECHO_T}$ac_cv_header_zaptel_h" >&6; }
+{ echo "$as_me:$LINENO: result: $ac_cv_header_tonezone_h" >&5
+echo "${ECHO_T}$ac_cv_header_tonezone_h" >&6; }
 else
   # Is the header compilable?
-{ echo "$as_me:$LINENO: checking zaptel.h usability" >&5
-echo $ECHO_N "checking zaptel.h usability... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking tonezone.h usability" >&5
+echo $ECHO_N "checking tonezone.h usability... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -17015,7 +17018,7 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-#include <zaptel.h>
+#include <tonezone.h>
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -17064,15 +17067,15 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 echo "${ECHO_T}$ac_header_compiler" >&6; }
 
 # Is the header present?
-{ echo "$as_me:$LINENO: checking zaptel.h presence" >&5
-echo $ECHO_N "checking zaptel.h presence... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking tonezone.h presence" >&5
+echo $ECHO_N "checking tonezone.h presence... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <zaptel.h>
+#include <tonezone.h>
 _ACEOF
 if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
@@ -17112,72 +17115,72 @@ echo "${ECHO_T}$ac_header_preproc" >&6; }
 # So?  What about this header?
 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
   yes:no: )
-    { echo "$as_me:$LINENO: WARNING: zaptel.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: zaptel.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zaptel.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: zaptel.h: proceeding with the compiler's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: tonezone.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: tonezone.h: proceeding with the compiler's result" >&2;}
     ac_header_preproc=yes
     ;;
   no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: zaptel.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: zaptel.h: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zaptel.h:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: zaptel.h:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zaptel.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: zaptel.h: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zaptel.h:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: zaptel.h:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zaptel.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: zaptel.h: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zaptel.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: zaptel.h: in the future, the compiler will take precedence" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: tonezone.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: tonezone.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: tonezone.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: tonezone.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: tonezone.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tonezone.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: tonezone.h: in the future, the compiler will take precedence" >&2;}
 
     ;;
 esac
-{ echo "$as_me:$LINENO: checking for zaptel.h" >&5
-echo $ECHO_N "checking for zaptel.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_zaptel_h+set}" = set; then
+{ echo "$as_me:$LINENO: checking for tonezone.h" >&5
+echo $ECHO_N "checking for tonezone.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_tonezone_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_cv_header_zaptel_h=$ac_header_preproc
+  ac_cv_header_tonezone_h=$ac_header_preproc
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_zaptel_h" >&5
-echo "${ECHO_T}$ac_cv_header_zaptel_h" >&6; }
+{ echo "$as_me:$LINENO: result: $ac_cv_header_tonezone_h" >&5
+echo "${ECHO_T}$ac_cv_header_tonezone_h" >&6; }
 
 fi
-if test $ac_cv_header_zaptel_h = yes; then
-  ZAPTEL_HEADER_FOUND=1
+if test $ac_cv_header_tonezone_h = yes; then
+  TONEZONE_HEADER_FOUND=1
 else
-  ZAPTEL_HEADER_FOUND=0
+  TONEZONE_HEADER_FOUND=0
 fi
 
 
 	 fi
       fi
-      if test "x${ZAPTEL_HEADER_FOUND}" = "x0" ; then
-         if test ! -z "${ZAPTEL_MANDATORY}" ;
+      if test "x${TONEZONE_HEADER_FOUND}" = "x0" ; then
+         if test ! -z "${TONEZONE_MANDATORY}" ;
          then
             echo " ***"
             echo " *** It appears that you do not have the tonezone development package installed."
-            echo " *** Please install it to include Zaptel support, or re-run configure"
+            echo " *** Please install it to include tonezone support, or re-run configure"
             echo " *** without explicitly specifying --with-tonezone"
             exit 1
          fi
-         ZAPTEL_LIB=""
-         ZAPTEL_INCLUDE=""
-         PBX_LIBZAPTEL=0
+         TONEZONE_LIB=""
+         TONEZONE_INCLUDE=""
+         PBX_LIBTONEZONE=0
       else
-         PBX_LIBZAPTEL=1
+         PBX_LIBTONEZONE=1
 
 cat >>confdefs.h <<_ACEOF
-#define HAVE_ZAPTEL 1
+#define HAVE_TONEZONE 1
 _ACEOF
 
       fi
-   elif test ! -z "${ZAPTEL_MANDATORY}";
+   elif test ! -z "${TONEZONE_MANDATORY}";
    then
       echo "***"
-      echo "*** The Zaptel installation on this system appears to be broken."
+      echo "*** The tonezone installation on this system appears to be broken."
       echo "*** Either correct the installation, or run configure"
       echo "*** without explicity specifying --with-tonezone"
       exit 1
@@ -17189,6 +17192,129 @@ fi
 
 fi
 
+
+# Check whether --with-zaptel was given.
+if test "${with_zaptel+set}" = set; then
+  withval=$with_zaptel;
+case ${withval} in
+     n|no)
+     USE_ZAPTEL=no
+     ;;
+     y|ye|yes)
+     ZAPTEL_MANDATORY=yes
+     ;;
+     *)
+     ZAPTEL_DIR="${withval}"
+     ZAPTEL_MANDATORY=yes
+     ;;
+esac
+
+fi
+
+
+PBX_ZAPTEL=0
+if test "${USE_ZAPTEL}" != "no"; then
+   echo -n "checking for usability of zaptel.h... "
+   if test "${PBX_OSTYPE}" = "Linux" ; then
+      zapheader=linux/zaptel.h
+   else
+      zapheader=zaptel.h
+   fi
+   saved_cppflags="${CPPFLAGS}"
+   if test "x${ZAPTEL_DIR}" != "x"; then
+      CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
+   fi
+   cat >conftest.$ac_ext <<_ACEOF
+
+	/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <${zapheader}>
+int
+main ()
+{
+struct zt_transcode_header test;
+  ;
+  return 0;
+}
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  	{ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+		ac_cv_zaptel_h="yes"
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+		{ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+		ac_cv_zaptel_h="no"
+
+
+fi
+
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+   CPPFLAGS="${saved_cppflags}"
+   if test "${ac_cv_zaptel_h}" = "yes"; then
+	if test "${ZAPTEL_DIR}" != ""; then
+	   ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
+
+	fi
+	PBX_ZAPTEL=1
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ZAPTEL 1
+_ACEOF
+
+   elif test ! -z "${ZAPTEL_MANDATORY}";
+   then
+      echo "***"
+      echo "*** The Zaptel installation on this system appears to be broken."
+      echo "*** Either correct the installation, or run configure"
+      echo "*** including --without-zaptel."
+      exit 1
+   fi
+fi
+
+
+
 GSM_INTERNAL="yes"
 GSM_SYSTEM="yes"
 
@@ -18038,9 +18164,9 @@ if test "${with_vpb+set}" = set; then
 case ${withval} in
      n|no)
      USE_VPB=no
-     VPB_MANDATORY="yes"
      ;;
      y|ye|yes)
+     VPB_MANDATORY="yes"
      ;;
      *)
      VPB_DIR="${withval}"
@@ -18163,9 +18289,9 @@ if test "${with_qt+set}" = set; then
 case ${withval} in
      n|no)
      USE_QT=no
-     QT_MANDATORY="yes"
      ;;
      y|ye|yes)
+     QT_MANDATORY="yes"
      ;;
      *)
      QT_DIR="${withval}"
@@ -18467,9 +18593,9 @@ if test "${with_kde+set}" = set; then
 case ${withval} in
      n|no)
      USE_KDE=no
-     KDE_MANDATORY="yes"
      ;;
      y|ye|yes)
+     KDE_MANDATORY="yes"
      ;;
      *)
      KDE_DIR="${withval}"
@@ -27297,9 +27423,11 @@ EDITLINE_LIBS!$EDITLINE_LIBS$ac_delim
 OSS_LIB!$OSS_LIB$ac_delim
 OSS_INCLUDE!$OSS_INCLUDE$ac_delim
 PBX_LIBOSS!$PBX_LIBOSS$ac_delim
-ZAPTEL_LIB!$ZAPTEL_LIB$ac_delim
+TONEZONE_LIB!$TONEZONE_LIB$ac_delim
+TONEZONE_INCLUDE!$TONEZONE_INCLUDE$ac_delim
+PBX_LIBTONEZONE!$PBX_LIBTONEZONE$ac_delim
 ZAPTEL_INCLUDE!$ZAPTEL_INCLUDE$ac_delim
-PBX_LIBZAPTEL!$PBX_LIBZAPTEL$ac_delim
+PBX_ZAPTEL!$PBX_ZAPTEL$ac_delim
 gsm_LIB!$gsm_LIB$ac_delim
 gsm_INCLUDE!$gsm_INCLUDE$ac_delim
 PBX_LIBgsm!$PBX_LIBgsm$ac_delim
@@ -27336,8 +27464,6 @@ PBX_CURL!$PBX_CURL$ac_delim
 CURLLIBS!$CURLLIBS$ac_delim
 ALLOCA!$ALLOCA$ac_delim
 LIBOBJS!$LIBOBJS$ac_delim
-POW_LIB!$POW_LIB$ac_delim
-LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -27376,6 +27502,51 @@ CEOF$ac_eof
 _ACEOF
 
 
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  cat >conf$$subs.sed <<_ACEOF
+POW_LIB!$POW_LIB$ac_delim
+LTLIBOBJS!$LTLIBOBJS$ac_delim
+_ACEOF
+
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 2; then
+    break
+  elif $ac_last_try; then
+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+  ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-3.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
+_ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+:end
+s/|#_!!_#|//g
+CEOF$ac_eof
+_ACEOF
+
+
 # VPATH may cause trouble with some makes, so we remove $(srcdir),
 # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
 # trailing colons and then remove the whole line if VPATH becomes empty
@@ -27619,7 +27790,7 @@ s&@abs_builddir@&$ac_abs_builddir&;t t
 s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
 s&@INSTALL@&$ac_INSTALL&;t t
 $ac_datarootdir_hack
-" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" | sed 's/|#_!!_#|//g' >$tmp/out
+" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" | sed -f "$tmp/subs-3.sed" >$tmp/out
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
   { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
@@ -27799,4 +27970,3 @@ if test "x${crossCompile}" = xYes; then
    echo " Cross Compilation = YES"
    echo " Target            = ${host}"
 fi
-
diff --git a/configure.ac b/configure.ac
index ef64bc536c90a0328d166331d42a16b7e2b97ec1..e28aef4fc68f71eca9270434fd4b60c2534350f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -249,11 +249,71 @@ fi
 AC_SUBST([PBX_LIBOSS])
 
 if test "${PBX_OSTYPE}" = "Linux" ; then
-  AST_EXT_LIB([tonezone], [tone_zone_find], [linux/zaptel.h], [ZAPTEL], [Zaptel])
+  AST_EXT_LIB([tonezone], [tone_zone_find], [tonezone.h], [TONEZONE], [tonezone])
 else
-  AST_EXT_LIB([tonezone], [tone_zone_find], [zaptel.h], [ZAPTEL], [Zaptel], [-lm])
+  AST_EXT_LIB([tonezone], [tone_zone_find], [tonezone.h], [TONEZONE], [tonezone], [-lm])
 fi
 
+AC_ARG_WITH([zaptel], AC_HELP_STRING([--with-zaptel=PATH], [use Zaptel files in PATH]), [
+case ${withval} in
+     n|no)
+     USE_ZAPTEL=no
+     ;;
+     y|ye|yes)
+     ZAPTEL_MANDATORY=yes
+     ;;
+     *)
+     ZAPTEL_DIR="${withval}"
+     ZAPTEL_MANDATORY=yes
+     ;;
+esac
+])
+
+PBX_ZAPTEL=0
+if test "${USE_ZAPTEL}" != "no"; then
+   echo -n "checking for usability of zaptel.h... "
+   if test "${PBX_OSTYPE}" = "Linux" ; then
+      zapheader=linux/zaptel.h
+   else
+      zapheader=zaptel.h
+   fi
+   saved_cppflags="${CPPFLAGS}"
+   if test "x${ZAPTEL_DIR}" != "x"; then
+      CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
+   fi
+   AC_COMPILE_IFELSE(
+	[
+	AC_LANG_PROGRAM(
+	[#include <${zapheader}>],
+	[struct zt_transcode_header test;])
+	],
+	[	AC_MSG_RESULT(yes) 
+		ac_cv_zaptel_h="yes" 
+	],
+	[	AC_MSG_RESULT(no) 
+		ac_cv_zaptel_h="no" 
+	]
+	)
+   CPPFLAGS="${saved_cppflags}"
+   if test "${ac_cv_zaptel_h}" = "yes"; then
+	if test "${ZAPTEL_DIR}" != ""; then
+	   ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
+	   AC_SUBST([ZAPTEL_INCLUDE])
+	fi
+	PBX_ZAPTEL=1
+	AC_DEFINE([HAVE_ZAPTEL], 1, [Define if your system has the Zaptel headers.])
+   elif test ! -z "${ZAPTEL_MANDATORY}"; 
+   then
+      echo "***"
+      echo "*** The Zaptel installation on this system appears to be broken."
+      echo "*** Either correct the installation, or run configure"
+      echo "*** including --without-zaptel."
+      exit 1
+   fi
+fi
+
+AC_SUBST([PBX_ZAPTEL])
+
 GSM_INTERNAL="yes"
 GSM_SYSTEM="yes"
 AC_ARG_WITH([gsm], AC_HELP_STRING([--with-gsm=PATH], [use libgsm files in PATH, or 'internal']), [
@@ -394,9 +454,9 @@ AC_ARG_WITH([vpb], AC_HELP_STRING([--with-vpb=PATH],[use vpb files in PATH]),[
 case ${withval} in
      n|no)
      USE_VPB=no
-     VPB_MANDATORY="yes"
      ;;
      y|ye|yes)
+     VPB_MANDATORY="yes"
      ;;
      *)
      VPB_DIR="${withval}"
@@ -454,9 +514,9 @@ AC_ARG_WITH([qt], AC_HELP_STRING([--with-qt=PATH],[use Qt files in PATH]),[
 case ${withval} in
      n|no)
      USE_QT=no
-     QT_MANDATORY="yes"
      ;;
      y|ye|yes)
+     QT_MANDATORY="yes"
      ;;
      *)
      QT_DIR="${withval}"
@@ -540,9 +600,9 @@ AC_ARG_WITH([kde], AC_HELP_STRING([--with-kde=PATH],[use KDE files in PATH]),[
 case ${withval} in
      n|no)
      USE_KDE=no
-     KDE_MANDATORY="yes"
      ;;
      y|ye|yes)
+     KDE_MANDATORY="yes"
      ;;
      *)
      KDE_DIR="${withval}"
@@ -776,4 +836,3 @@ if test "x${crossCompile}" = xYes; then
    echo " Cross Compilation = YES"
    echo " Target            = ${host}"
 fi
-
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index 3e11ac04f52d2504c95e0082d93a1d25dfbf4eb3..a0cf4bc9ea952c2eec72515c1c5096b721248c8d 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -388,6 +388,9 @@
 /* Define to indicate the Term Info library */
 #undef HAVE_TINFO
 
+/* Define to indicate the tonezone library */
+#undef HAVE_TONEZONE
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
@@ -427,7 +430,7 @@
 /* Define to 1 if `vfork' works. */
 #undef HAVE_WORKING_VFORK
 
-/* Define to indicate the Zaptel library */
+/* Define if your system has the Zaptel headers. */
 #undef HAVE_ZAPTEL
 
 /* Define to indicate the zlib library */
diff --git a/makeopts.in b/makeopts.in
index 9eb409d79ff185ab871b503a90dc904c81821a97..28da92e85a86b77d891f69c3f839ef50015bbd5a 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -56,7 +56,9 @@ OSSAUDIO_INCLUDE=@OSS_INCLUDE@
 SPEEX_LIB=@SPEEX_LIB@
 SPEEX_INCLUDE=@SPEEX_INCLUDE@
 
-ZAPTEL_LIB=@ZAPTEL_LIB@
+TONEZONE_LIB=@TONEZONE_LIB@
+TONEZONE_INCLUDE=@TONEZONE_INCLUDE@
+
 ZAPTEL_INCLUDE=@ZAPTEL_INCLUDE@
 
 VPB_LIB=@VPB_LIB@