Index: Makefile
--- Makefile.orig	2007-01-11 20:07:14 +0100
+++ Makefile	2008-03-22 11:26:25 +0100
@@ -39,7 +39,7 @@
 OPTIMIZE=-O6
 
 #Include debug symbols in the executables (-g)
-DEBUG=-g 
+DEBUG= 
 
 CFLAGS+=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE
 CFLAGS+=$(OPTIMIZE)
@@ -54,7 +54,7 @@
 	CFLAGS+=-DASTERISK_VERSION=0
 endif
 
-LIBS+=-lm -lflite -lflite_cmulex -lflite_usenglish -lflite_cmu_us_kal
+LIBS+=-lflite_cmu_us_kal -lflite_cmulex -lflite_usenglish -lflite -lm
 
 all: $(APPS)
 
@@ -68,7 +68,7 @@
 	$(CC) -pipe $(INCLUDE) $(CFLAGS) -c -o app_flite.o app_flite.c
 
 app_flite.so: app_flite.o
-	$(CC) -shared -Xlinker -x -o $@ $< $(LIBS)
+	$(CC) $(LDFLAGS) -shared -Xlinker -x -o $@ $< $(LIBS)
 
 install: all
 	@if [ -d $(ASTERISKMODDIR) ]; then \
Index: app_flite.c
--- app_flite.c.orig	2007-01-11 20:07:14 +0100
+++ app_flite.c	2008-03-22 11:25:47 +0100
@@ -38,10 +38,13 @@
 		0 == Asterisk 1.0.x
 		2 == Asterisk 1.2.x
 		4 == Asterisk 1.4.x
+		6 == Asterisk 1.6.x
 	 */
-	#define ASTERISK_VERSION 4
+	#define ASTERISK_VERSION 6
 #endif
 
+#include <asterisk.h>
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -76,7 +79,7 @@
 "the user, allowing any given interrupt keys to immediately terminate\n"
 "and return.\n";
 
-#if ASTERISK_VERSION != 4
+#if ASTERISK_VERSION < 4
 STANDARD_LOCAL_USER;
 
 LOCAL_USER_DECL;
@@ -108,6 +111,9 @@
 	char filename[27];
 	char wavFilename[27];
 	cst_voice *v;
+#if ASTERISK_VERSION >= 6
+    struct ast_flags config_flags = { 0 };
+#endif
 
 	if (ast_strlen_zero(data))
 	{
@@ -115,14 +121,16 @@
 		return -1;
 	}
 
-#if ASTERISK_VERSION == 4
+#if ASTERISK_VERSION >= 4
 	u = ast_module_user_add(chan);
 #else
 	LOCAL_USER_ADD(u);
 #endif
 
 	/* Config file stuff */
-#if ASTERISK_VERSION >= 2
+#if ASTERISK_VERSION >= 6
+	cfg = ast_config_load(FLITE_CONFIG, config_flags);
+#elif ASTERISK_VERSION >= 2
 	cfg = ast_config_load(FLITE_CONFIG);
 #else
 	cfg = ast_load(FLITE_CONFIG);
@@ -210,7 +218,7 @@
 					ast_log(LOG_WARNING, "ast_streamfile failed on %s for Flite\n", chan->name);
 				}
 
-#if ASTERISK_VERSION == 4
+#if ASTERISK_VERSION >= 4
 				ast_module_user_remove(u);
 #else
 				LOCAL_USER_REMOVE(u);
@@ -263,7 +271,7 @@
 	sprintf(cmd, "rm -f %s*", filename);
 	system(cmd);
 
-#if ASTERISK_VERSION == 4
+#if ASTERISK_VERSION >= 4
 	ast_module_user_remove(u);
 #else
 	LOCAL_USER_REMOVE(u);
@@ -271,7 +279,7 @@
 	return res;
 }
 
-#if ASTERISK_VERSION == 4
+#if ASTERISK_VERSION >= 4
 static int unload_module(void)
 {
 	int res;
