diff --git a/.cvsignore b/.cvsignore
index a8765e0b403bf6b39d3df74619feb8c772a11eb0..0a5270f7190cff6d43cd2f66a0744614fdc42f65 100755
--- a/.cvsignore
+++ b/.cvsignore
@@ -17,4 +17,4 @@ update.out
 .tags-sources
 tags
 TAGS
-*.os
+vercomp
diff --git a/Makefile b/Makefile
index 01017847e57f62ef0be2303d6de526a22d3f4897..ca429fbfa62515d3a93a55c8b1b139b5e2f1b435 100755
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,7 @@ OPTIONS=
 # CROSS_COMPILE_BIN=/opt/montavista/pro/devkit/arm/xscale_be/bin/
 # CROSS_COMPILE_TARGET=/opt/montavista/pro/devkit/arm/xscale_be/target
 CC=$(CROSS_COMPILE)gcc
+HOST_CC=gcc
 # CROSS_ARCH=Linux
 # CROSS_PROC=arm
 # SUB_PROC=xscale # or maverick
@@ -259,20 +260,10 @@ LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/usr/local
 endif
 LIBS+=-lssl
 
-#FLEXVER_GT_2_5_31=$(shell ./vercomp.sh flex \>= 2.5.31)
-#BISONVER=$(shell bison --version | grep \^bison | egrep -o '[0-9]+\.[-0-9.]+[a-z]?' )
-#BISONVERGE_85=$(shell ./vercomp.sh bison \>= 1.85 )
-
-ifeq (${FLEXVER_GT_2_5_31},true)
-FLEXOBJS=ast_expr2.o ast_expr2f.o
-else
-FLEXOBJS=ast_expr.o
-endif
-
 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
 	translate.o file.o say.o pbx.o cli.o md5.o term.o \
 	ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
-	cdr.o tdd.o acl.o rtp.o manager.o asterisk.o ${FLEXOBJS}  \
+	cdr.o tdd.o acl.o rtp.o manager.o asterisk.o \
 	dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
 	astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
 	utils.o config_old.o plc.o jitterbuf.o dnsmgr.o
@@ -336,38 +327,54 @@ ifneq ($(wildcard .tags-depend),)
 include .tags-depend
 endif
 
-.PHONY: _version
+.PHONY: _version ast_expr
 
 _version: 
 	if [ -d CVS ] && [ ! -f .version ]; then echo $(ASTERISKVERSION) > .version; fi 
 
 .version: _version
 
+vercomp: vercomp.c
+	$(HOST_CC) -o $@ $<
+
+ast_expr: vercomp
+	$(MAKE) ast_expr.a
+
+ifeq ($(MAKECMDGOALS),ast_expr.a)
+FLEXVER_GT_2_5_31=$(shell ./vercomp flex \>= 2.5.31)
+BISONVER=$(shell bison --version | grep \^bison | sed 's/.* \([0-9]\+\.[-0-9.]\+[a-z]\?\)/\1/' )
+BISONVER_GE_1_85=$(shell ./vercomp bison \>= 1.85 )
+endif
+
+ifeq ($(FLEXVER_GT_2_5_31),true)
+FLEXOBJS=ast_expr2.o ast_expr2f.o
+else
+FLEXOBJS=ast_expr.o
+endif
+
+ast_expr.a: $(FLEXOBJS)
+	@rm -f $@
+	ar r $@ $(FLEXOBJS)
+	ranlib $@
+
 .y.c:
-#	@if (($(BISONVERGE_85) = false)); then \
-#		echo ================================================================================= ;\
-#		echo NOTE: you may have trouble if you do not have bison-1.85 or higher installed! ;\
-#		echo NOTE: you can pick up a copy at: http://ftp.gnu.org/ or its mirrors ;\
-#		echo NOTE: You Have: $(BISONVER) ;\
-#		echo ================================================================================; \
-#	else \
-#		echo EXCELLENT-- You have Bison version $(BISONVER), this should work just fine...;\
-#	fi
+	@if (($(BISONVER_GE_1_85) = false)); then \
+		echo ================================================================================= ;\
+		echo NOTE: You may have trouble if you do not have bison-1.85 or higher installed! ;\
+		echo NOTE: You can pick up a copy at: http://ftp.gnu.org/ or its mirrors ;\
+		echo NOTE: You have: $(BISONVER) ;\
+		echo ================================================================================; \
+	fi
 	bison -v -d --name-prefix=ast_yy $< -o $@
 
-ast_expr.o: ast_expr.c
-#	@echo NOTE:
-#	@echo NOTE:
-#	@echo NOTE: Using older version of ast_expr. To use the newer version,
-#	@echo NOTE: Upgrade to flex 2.5.31 or higher, which can be found at http://
-#	@echo NOTE:  http://sourceforge.net/project/showfiles.php?group_id=72099
-#	@echo NOTE:
-#	@echo NOTE:
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) ast_expr.c
-
-ast_expr2.o: ast_expr2.c
+ast_expr.o:: ast_expr.c
+	@echo ================================================================================= ;\
+	echo NOTE: Using older version of expression parser. To use the newer version, ;\
+	echo NOTE: upgrade to flex 2.5.31 or higher, which can be found at ;\
+	echo NOTE: http://sourceforge.net/project/showfiles.php?group_id=72099 ;\
+	echo ================================================================================= ;\
 
-ast_expr2f.o: ast_expr2f.c
+ast_expr.o:: ast_expr.c
 
 ast_expr2f.c: ast_expr2.fl
 	flex ast_expr2.fl
@@ -421,8 +428,8 @@ stdtime/libtime.a: FORCE
 		exit 1; \
 	fi
 
-asterisk: editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
-	$(CC) $(DEBUG) -o asterisk $(ASTLINK) $(OBJS) $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
+asterisk: editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS) ast_expr
+	$(CC) $(DEBUG) -o asterisk $(ASTLINK) $(OBJS) ast_expr.a $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
 
 muted: muted.o
 	$(CC) -o muted muted.o
@@ -434,7 +441,9 @@ clean:
 	for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
 	rm -f *.o *.so asterisk .depend
 	rm -f build.h 
-	rm -f ast_expr.c
+	rm -f ast_expr.c ast_expr.h ast_expr.output
+	rm -f ast_expr2.c ast_expr2f.c ast_expr2.h ast_expr2.output
+	rm -f ast_expr.a vercomp
 	rm -f .version
 	rm -f .tags-depend .tags-sources tags TAGS
 	@if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
diff --git a/vercomp.c b/vercomp.c
new file mode 100755
index 0000000000000000000000000000000000000000..f28e42f52ede37257276d7799cfd702b9c2ec907
--- /dev/null
+++ b/vercomp.c
@@ -0,0 +1,349 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * A simple program version comparison tool.
+ * 
+ * Copyright (C) 2005, 'murf'.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+/* vercomp.c
+   args: <program> <comparison> <version>
+
+	where:
+
+   program = path to program (bison or flex)
+   comparison = ">", "<", "<=", ">=", "="  -- depending on shell, you may have to use backslash escapes
+   version = a version compare against, say 1.875, or 2.5.4, or whatever.
+
+*/
+
+#include <stdio.h>
+#include <string.h>
+
+char *program_version[5];
+char *arg_version[5];
+
+void get_program_version_string(char *command, char *output)
+{
+	char cbuf[8000];
+	char pbuf[8000];
+	char zbuf[8000];
+	char *res;
+	FILE *p1;
+
+	zbuf[0] = 0;
+	
+	sprintf( cbuf, "%s --version", command );
+	p1 = popen(cbuf, "r");
+	if( !p1 )
+	{
+		fprintf(stderr,"vercomp: Could not execute the command: %s\n", command);
+		exit(125);
+	}
+	/* the first line is the magic one */
+	res = fgets(zbuf, 8000, p1);
+	/* clear the trailing blank */
+	if( zbuf[strlen(zbuf)-1] == '\n' )
+		zbuf[strlen(zbuf)-1] = 0;
+	/* the rest is cruft, just empty the input stream */
+	while( res )
+	{
+		res = fgets(pbuf, 8000, p1);
+	}
+	/* close the stream. Hopefully, we have what we need */
+	pclose(p1);
+	/* all we want is the last "word"-- so find the last blank, and grab everything after that */
+
+	res = strrchr(zbuf,' ');
+	if( !res )
+	{
+		fprintf(stderr,"Something is wrong with the version string: %s\n", zbuf);
+		exit(124);
+	}
+	strcpy(output,res+1);
+}
+
+
+void extract_version(char *ver_string, char **where)
+{
+	int i=0;
+	char *p=ver_string;
+	
+	while( p && *p )
+	{
+		where[i++] = p;
+		p = strchr(p,'.');
+		if( p )
+		{
+			*p= 0;
+			p++;
+		}
+	}
+}
+
+void compare_versions(char *compare_func)
+{
+	int i;
+	
+	for(i=0;i<5;i++)
+	{
+		/* start out at the beginning, then go to the end */
+		if( program_version[i] && arg_version[i] && *program_version[i] && *arg_version[i] )
+		{
+			
+			if( strlen(program_version[i]) == strspn(program_version[i],"0123456789")
+				&& strlen(arg_version[i]) == strspn(arg_version[i],"0123456789") )
+			{
+				/* just pure numbers -- do a numeric compare */
+				int pv = atoi(program_version[i]);
+				int av = atoi(arg_version[i]);
+				
+				if( pv < av )
+				{
+					if( !strcmp(compare_func,"=") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, ">") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, "<") )
+					{
+						printf("true\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, ">=") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, "<=") )
+					{
+						printf("true\n");
+						exit(0);
+					}
+				}
+				else if( pv > av )
+				{
+					if( !strcmp(compare_func,"=") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, ">") )
+					{
+						printf("true\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, "<") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, ">=") )
+					{
+						printf("true\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, "<=") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+				}
+			}
+			else
+			{
+				/* other junk thrown in -- do string compare */
+				int res = strcmp(program_version[i], arg_version[i]);
+				if( res < 0 ) /* prog is less than arg */
+				{
+					if( !strcmp(compare_func,"=") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, ">") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, "<") )
+					{
+						printf("true\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, ">=") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, "<=") )
+					{
+						printf("true\n");
+						exit(0);
+					}
+				}
+				else if( res > 0 ) /* prog is greater than arg */
+				{
+					if( !strcmp(compare_func,"=") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, ">") )
+					{
+						printf("true\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, "<") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, ">=") )
+					{
+						printf("true\n");
+						exit(0);
+					}
+					else if( !strcmp(compare_func, "<=") )
+					{
+						printf("false\n");
+						exit(0);
+					}
+				}
+			}
+		}
+		else if( program_version[i] && *program_version[i] )
+		{
+			if( !strcmp(compare_func,"=") )
+			{
+				printf("false\n");
+				exit(0);
+			}
+			else if( !strcmp(compare_func, ">") )
+			{
+				printf("true\n");
+				exit(0);
+			}
+			else if( !strcmp(compare_func, "<") )
+			{
+				printf("false\n");
+				exit(0);
+			}
+			else if( !strcmp(compare_func, ">=") )
+			{
+				printf("true\n");
+				exit(0);
+			}
+			else if( !strcmp(compare_func, "<=") )
+			{
+				printf("false\n");
+				exit(0);
+			}
+			
+		}
+		else if( arg_version[i] && *arg_version[i] )
+		{
+			if( !strcmp(compare_func,"=") )
+			{
+				printf("false\n");
+				exit(0);
+			}
+			else if( !strcmp(compare_func, ">") )
+			{
+				printf("false\n");
+				exit(0);
+			}
+			else if( !strcmp(compare_func, "<") )
+			{
+				printf("true\n");
+				exit(0);
+			}
+			else if( !strcmp(compare_func, ">=") )
+			{
+				printf("false\n");
+				exit(0);
+			}
+			else if( !strcmp(compare_func, "<=") )
+			{
+				printf("true\n");
+				exit(0);
+			}
+		}
+		else
+			break;
+	}
+	if( !strcmp(compare_func,"=") )
+	{
+		printf("true\n");
+		exit(0);
+	}
+	else if( !strcmp(compare_func, ">") )
+	{
+		printf("false\n");
+		exit(0);
+	}
+	else if( !strcmp(compare_func, "<") )
+	{
+		printf("false\n");
+		exit(0);
+	}
+	else if( !strcmp(compare_func, ">=") )
+	{
+		printf("true\n");
+		exit(0);
+	}
+	else if( !strcmp(compare_func, "<=") )
+	{
+		printf("true\n");
+		exit(0);
+	}
+}
+
+void usage(void)
+{
+	printf("Usage: <program-path> <comparison> <version>\n\
+\n\
+	where:\n\
+\n\
+   program-path = path to program (bison or flex)\n\
+   comparison = '>', '<', '<=', '>=', '='  -- depending on shell, you may have to use backslash escapes\n\
+   version = a version compare against, say 1.875, or 2.5.4, or whatever.\n\n");
+}
+
+
+int main(int argc, char **argv)
+{
+	char program_version_string[8000];
+	
+	/* before starting, check args and make sure all is OK */
+	if( argc < 4 || argc > 4 )
+	{
+		usage();
+		exit(-256);
+	}
+	if ( strcmp(argv[2],"=") && strcmp(argv[2],">") && strcmp(argv[2],"<") && strcmp(argv[2],">=") && strcmp(argv[2],"<=") )
+	{
+		fprintf(stderr,"vercomp: ILLEGAL input Comparison value: %s\n\n", argv[2]);
+		usage();
+		exit(-256);
+	}
+		 
+	/* first, extract a version from the command line arg */
+	extract_version(argv[3], arg_version);
+
+	/* next, extract a version from the command line */
+	get_program_version_string(argv[1], program_version_string);
+	extract_version(program_version_string, program_version);
+	
+	/* next compare and return result */
+	compare_versions(argv[2]);
+	/* the above func shouldn't return */
+}
diff --git a/vercomp.sh b/vercomp.sh
deleted file mode 100755
index 8ab64c7149bf752478b94704061d1e2d658a3a4b..0000000000000000000000000000000000000000
--- a/vercomp.sh
+++ /dev/null
@@ -1,163 +0,0 @@
-#! /bin/bash
-
-### flex just outputs a single line:
-
-## flex version 2.5.4
-
-
-### but bison is a bit more wordy
-
-## bison (GNU Bison) 1.875c
-## Written by Robert Corbett and Richard Stallman.
-## 
-## Copyright (C) 2003 Free Software Foundation, Inc.
-## This is free software; see the source for copying conditions.  There is NO
-## warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-### based on this, the version number of the program:
-###   a. in the first line of output
-###   b. is the last "word" of that line
-
-program=$1
-comparefunc=$2
-argver=$3
-
-progver1=`$program --version | head -1`
-
-[[ $progver1 =~ '([^ ]+$)'  ]]
-
-progver=$BASH_REMATCH
-
-progver2=$progver
-numprogverlist=0
-
-while [[ $progver2 =~ '^([^.]+)\.(.*)' ]]; do
-	progver2=${BASH_REMATCH[2]}
-	progverlist[$numprogverlist]=${BASH_REMATCH[1]}
-	progverlist[$(( ${numprogverlist}+1 ))]=${BASH_REMATCH[2]}
-
-##	echo ${BASH_REMATCH[0]}
-##	echo ${BASH_REMATCH[1]}
-##	echo ${BASH_REMATCH[2]}
-  	(( numprogverlist=$(( $numprogverlist+1 )) ))
-
-done
-	(( numprogverlist=$(( $numprogverlist+1 )) ))
-  	
-##	echo number of elements = $numprogverlist
-##	echo element 0 = ${progverlist[0]}
-##	echo element 1 = ${progverlist[1]}
-##	echo element 2 = ${progverlist[2]}
-
-argver2=$argver
-numargverlist=0
-
-while [[ $argver2 =~ '^([^.]+)\.(.*)' ]]; do
-	argver2=${BASH_REMATCH[2]}
-	argverlist[$numargverlist]=${BASH_REMATCH[1]}
-	argverlist[$(( ${numargverlist}+1 ))]=${BASH_REMATCH[2]}
-
-##	echo ${BASH_REMATCH[0]}
-##	echo ${BASH_REMATCH[1]}
-##	echo ${BASH_REMATCH[2]}
-  	(( numargverlist=$(( $numargverlist+1 )) ))
-
-done
-	(( numargverlist=$(( $numargverlist+1 )) ))
-  	
-##	echo number of argver elements = $numargverlist
-##	echo element 0 = ${argverlist[0]}
-##	echo element 1 = ${argverlist[1]}
-##	echo element 2 = ${argverlist[2]}
-
-if (( $numprogverlist < $numargverlist )); then
-	for (( i=$numprogverlist ; $i < $numargverlist ; i=$i + 1 )) ; do
-##		echo setting progverlist "[" $i "]" to 0
-		(( progverlist[$i]='0' ))
-		(( numprogverlist=${numprogverlist}+1 ))
-	done
-elif (( $numargverlist < $numprogverlist )); then
-	for (( i=$numargverlist ; $i < $numprogverlist ; i=$i + 1 )) ; do
-##		echo setting argverlist "[" $i "]" to 0
-		(( argverlist[$i]='0' ))
-		(( numargverlist=${numargverlist}+1 ))
-	done
-fi
-
-## echo numarg=$numargverlist   numprog=$numprogverlist
-## echo arg0: ${argverlist[0]}
-## echo arg1: ${argverlist[1]}
-## echo arg2: ${argverlist[2]}
-## echo prog0: ${progverlist[0]}
-## echo prog1: ${progverlist[1]}
-## echo prog2: ${progverlist[2]}
-
-## the main comparison loop 
-
-for (( i=0 ; $i < $numargverlist ; i=$i + 1 )) ; do
-##	echo i= $i
-
-	if [[ ${progverlist[$i]} =~ '^[0-9]+$' &&  ${argverlist[$i]} =~ '^[0-9]+$' ]] ; then  ## nothing but numbers
-		if (( ${progverlist[$i]} != ${argverlist[$i]} )); then
-			if [[ ${progverlist[$i]}  -lt ${argverlist[$i]} ]]; then
-				if [[ $comparefunc == "=" ]]; then
-					echo "false"
-					exit 0;
-				elif [[ $comparefunc == "<" || $comparefunc == "<=" ]]; then
-					echo "true"
-					exit 0;
-				elif [[ $comparefunc == ">" || $comparefunc == ">=" ]]; then
-					echo "false"
-					exit 0;
-				fi
-			elif [[ ${progverlist[$i]} -gt ${argverlist[$i]} ]]; then
-				if [[ $comparefunc == "=" ]]; then
-					echo "false"
-					exit 0;
-				elif [[ $comparefunc == "<" || $comparefunc == "<=" ]]; then
-					echo "false"
-					exit 0;
-				elif [[ $comparefunc == ">" || $comparefunc == ">=" ]]; then
-					echo "true"
-					exit 0;
-				fi
-			fi
-		fi
-	else  ## something besides just numbers
-		if [[ ${progverlist[$i]} != ${argverlist[$i]} ]]; then
-			if [[ ${progverlist[$i]} < ${argverlist[$i]} ]]; then
-				if [[ $comparefunc == "=" ]]; then
-					echo "false"
-					exit 0;
-				elif [[ $comparefunc == "<" || $comparefunc == "<=" ]]; then
-					echo "true"
-					exit 0;
-				elif [[ $comparefunc == ">" || $comparefunc == ">=" ]]; then
-					echo "false"
-					exit 0;
-				fi
-			elif [[ ${progverlist[$i]} > ${argverlist[$i]} ]]; then
-				if [[ $comparefunc == "=" ]]; then
-					echo "false"
-					exit 0;
-				elif [[ $comparefunc == "<" || $comparefunc == "<=" ]]; then
-					echo "false"
-					exit 0;
-				elif [[ $comparefunc == ">" || $comparefunc == ">=" ]]; then
-					echo "true"
-					exit 0;
-				fi
-			fi
-		fi
-	fi
-done
-
-if [[ $comparefunc == "=" ]]; then
-	echo "true"
-elif [[ $comparefunc == "<=" || $comparefunc == ">=" ]]; then
-	echo "true"
-else
-	echo "false"
-fi
-
-exit 0;