diff --git a/configure b/configure
index 6e109c8ac5d4a13d55b7ad6da9e6cf845cd7e99c..6d30e2be6bcd40d634a033677420875533a91118 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 241938 .
+# From configure.ac Revision: 242521 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for asterisk 1.6.
 #
@@ -7662,6 +7662,47 @@ fi
 fi
 
 
+{ echo "$as_me:$LINENO: checking for bison that supports parse-param" >&5
+echo $ECHO_N "checking for bison that supports parse-param... $ECHO_C" >&6; }
+if test "${ac_cv_path_BISON2+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	if test "x$BISON" != "x:" ; then
+		# Create a temporary directory $tmp in $TMPDIR (default /tmp).
+		# Use mktemp if possible; otherwise fall back on mkdir,
+		# with $RANDOM to make collisions less likely.
+		: ${TMPDIR=/tmp}
+		{
+		  tmp=`
+		    (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
+		  ` &&
+		  test -n "$tmp" && test -d "$tmp"
+		} || {
+		  tmp=$TMPDIR/foo$$-$RANDOM
+		  (umask 077 && mkdir "$tmp")
+		} || exit $?
+		cat >$tmp/test.y <<__EOL__
+%parse-param {struct parse_io *parseio}
+%%
+file : { \$\$ = parseio->pval = 1; }
+	;
+%%
+__EOL__
+		${BISON} -o ${tmp}/test.tab.c ${tmp}/test.y >/dev/null 2>&1
+		if test -e "${tmp}/test.tab.c"; then
+			ac_cv_path_BISON2=${BISON}
+		fi
+		rm -rf ${tmp}
+	fi
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_BISON2" >&5
+echo "${ECHO_T}$ac_cv_path_BISON2" >&6; }
+if test "x${ac_cv_path_BISON2}" = "x" ; then
+	BISON=:
+fi
+
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}soxmix", so it can be a program name with args.
 set dummy ${ac_tool_prefix}soxmix; ac_word=$2
diff --git a/configure.ac b/configure.ac
index 6ac4f7b5e05cfef4a2b721ec4b749244343a9017..2bd29f806c97e208750cccc5512708edaf79b519 100644
--- a/configure.ac
+++ b/configure.ac
@@ -210,6 +210,39 @@ fi
 fi
 AC_SUBST(DOWNLOAD)
 
+AC_CACHE_CHECK([for bison that supports parse-param], [ac_cv_path_BISON2], [
+	if test "x$BISON" != "x:" ; then
+		# Create a temporary directory $tmp in $TMPDIR (default /tmp).
+		# Use mktemp if possible; otherwise fall back on mkdir,
+		# with $RANDOM to make collisions less likely.
+		: ${TMPDIR=/tmp}
+		{
+		  tmp=`
+		    (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
+		  ` &&
+		  test -n "$tmp" && test -d "$tmp"
+		} || {
+		  tmp=$TMPDIR/foo$$-$RANDOM
+		  (umask 077 && mkdir "$tmp")
+		} || exit $?
+		cat >$tmp/test.y <<__EOL__
+%parse-param {struct parse_io *parseio}
+%%
+file : { \$\$ = parseio->pval = 1; }
+	;
+%%
+__EOL__
+		${BISON} -o ${tmp}/test.tab.c ${tmp}/test.y >/dev/null 2>&1
+		if test -e "${tmp}/test.tab.c"; then
+			ac_cv_path_BISON2=${BISON}
+		fi
+		rm -rf ${tmp}
+	fi
+	])
+if test "x${ac_cv_path_BISON2}" = "x" ; then
+	BISON=:
+fi
+
 AC_CHECK_TOOL([SOXMIX], [soxmix], [:])
 if test "${SOXMIX}" != ":" ; then
 	AC_DEFINE([HAVE_SOXMIX], 1, [Define to 1 if your system has soxmix application.])
diff --git a/main/Makefile b/main/Makefile
index 9d75208da734c49725e7aa9caa8ac535d4bd422d..98b142889cffe06df4bfe42120a9be3280b96595 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -101,7 +101,7 @@ editline/libedit.a: CHECK_SUBDIR
 db1-ast/libdb1.a: CHECK_SUBDIR
 	_ASTCFLAGS="$(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS) -Wno-strict-aliasing" $(MAKE) -C db1-ast libdb1.a
 
-ifneq ($(BISON),:)
+ifneq ($(and $(findstring bison,$(BISON)),$(findstring flex,$(FLEX))),)
 ast_expr2.c ast_expr2.h: ast_expr2.y
 else
 ast_expr2.c ast_expr2.h:
@@ -109,7 +109,7 @@ endif
 	$(ECHO_PREFIX) echo "   [BISON] $< -> $@"
 	$(CMD_PREFIX) $(BISON) -o $@ -d --name-prefix=ast_yy ast_expr2.y
 
-ifneq ($(FLEX),:)
+ifneq ($(and $(findstring bison,$(BISON)),$(findstring flex,$(FLEX))),)
 ast_expr2f.c: ast_expr2.fl
 else
 ast_expr2f.c:
diff --git a/res/Makefile b/res/Makefile
index b842dec789c94b71eb95a34c33aa90f5367b6203..b8e33be14a5406dfd69f60b07b984d64fa424ec9 100644
--- a/res/Makefile
+++ b/res/Makefile
@@ -45,7 +45,7 @@ $(if $(filter res_snmp,$(EMBEDDED_MODS)),modules.link,res_snmp.so): snmp/agent.o
 
 $(if $(filter res_ael_share,$(EMBEDDED_MODS)),modules.link,res_ael_share.so): ael/ael_lex.o ael/ael.tab.o ael/pval.o
 
-ifneq ($(FLEX),:)
+ifneq ($(and $(findstring bison,$(BISON)),$(findstring flex,$(FLEX))),)
 ael/ael_lex.c: ael/ael.flex
 else
 ael/ael_lex.c:
@@ -54,7 +54,7 @@ endif
 	$(CMD_PREFIX) (cd ael; $(FLEX) ael.flex; sed -e "/begin standard C headers/i#include \"asterisk.h\"" ael_lex.c > zz; mv zz ael_lex.c)
 	$(CMD_PREFIX) (cd ael; sed 's@#if __STDC_VERSION__ >= 199901L@#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L@' ael_lex.c > zz; mv zz ael_lex.c)
 
-ifneq ($(BISON),:)
+ifneq ($(and $(findstring bison,$(BISON)),$(findstring flex,$(FLEX))),)
 ael/ael.tab.c ael/ael.tab.h: ael/ael.y
 else
 ael/ael.tab.c ael/ael.tab.h: