+ [],
+ [with_asterisk="check"])
+
+AS_IF([test "x$with_asterisk" != xno],
+ [AC_CHECK_HEADERS([asterisk/compiler.h],
+ [with_asterisk="yes"],
+ [if test "x$with_asterisk" != xcheck ; then
+ AC_MSG_FAILURE(
+ [--with-asterisk was given, but test for header-file asterisk/compiler.h failed])
+ fi
+ ])
+ ])
+
+if test "x$with_asterisk" = "xyes"; then
+ dnl detect whether asterisk/indications.h defines ast_tone_zone_sound (1.6.2
+ dnl and later), ind_tone_zone_sound (1.6.0) or tone_zone_sound (1.4)
+ ast_tone_zone_sound=
+ apc_test_result=
+ ast_1_8_or_higher=
+
+ AC_CHECK_TYPE([struct ast_tone_zone_sound],
+ [ast_tone_zone_sound=ast_tone_zone_sound], [], [
+#include <asterisk.h>
+#include <asterisk/linkedlists.h>
+#include <asterisk/indications.h>])
+
+ AS_IF([test "x$ast_tone_zone_sound" = "x"],
+ [AC_CHECK_TYPE([struct ind_tone_zone_sound],
+ [ast_tone_zone_sound=ind_tone_zone_sound], [], [
+#include <asterisk.h>
+#include <asterisk/linkedlists.h>
+#include <asterisk/indications.h>])])
+ AS_IF([test "x$ast_tone_zone_sound" = "x"],
+ [AC_CHECK_TYPE([struct tone_zone_sound],
+ [ast_tone_zone_sound=tone_zone_sound], [], [
+#include <asterisk.h>
+#include <asterisk/indications.h>])])
+
+ if test "x$ast_tone_zone_sound" = "x"; then
+ AC_MSG_FAILURE([No ast_tone_zone_sound, confused...])
+ fi
+
+
+ AC_CHECK_TYPE([struct ast_party_caller],
+ [apc_test_result=yes], [], [
+#include <asterisk.h>
+#include <asterisk/channel.h>])
+
+ if test "x$apc_test_result" = "xyes"; then
+ ast_1_8_or_higher="-DAST_1_8_OR_HIGHER"
+ fi
+
+ AST_CFLAGS="-Dast_tone_zone_sound=$ast_tone_zone_sound $ast_1_8_or_higher"
+
+ AC_SUBST([AST_CFLAGS])
+fi
+
+AM_CONDITIONAL(ENABLE_ASTERISK_CHANNEL_DRIVER, test "x$with_asterisk" == "xyes" )