Index: Makefile
--- Makefile.orig	2008-01-23 10:13:34 +0100
+++ Makefile	2008-03-22 11:15:36 +0100
@@ -45,7 +45,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)
@@ -60,7 +60,7 @@
 	CFLAGS+=-DASTERISK_VERSION=0
 endif
 
-LIBS+=-lm -lespeak -lsndfile -lsamplerate
+LIBS+=-lespeak -lsndfile -lsamplerate -lstdc++ -lm
 
 all: $(APPS)
 
@@ -74,7 +74,7 @@
 	$(CC) -pipe $(INCLUDE) $(CFLAGS) -c -o app_espeak.o app_espeak.c
 
 app_espeak.so: app_espeak.o
-	$(CC) -shared -Xlinker -x -o $@ $< $(LIBS)
+	$(CC) $(LDFLAGS) -shared -Xlinker -x -o $@ $< $(LIBS)
 
 install: all
 	@if [ -d $(ASTERISKMODDIR) ]; then \
Index: app_espeak.c
--- app_espeak.c.orig	2008-01-29 15:32:21 +0100
+++ app_espeak.c	2008-03-22 11:15:19 +0100
@@ -41,10 +41,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 <asterisk/lock.h>
 #include <asterisk/file.h>
@@ -58,7 +61,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <espeak/speak_lib.h>
+#include <espeak.hh>
 
 #include <sndfile.h>
 #include <samplerate.h>
@@ -128,6 +131,9 @@
     char wavFilename[27];
     int speed = 120; /* Speed of speech in words per minute; default is 170wpm */
     const char *voice;
+#if ASTERISK_VERSION >= 6
+    struct ast_flags config_flags = { 0 };
+#endif
 
     /* For wave file creation */
     static unsigned char wave_hdr[44] = {
@@ -160,7 +166,9 @@
 #endif
 
     /* Config file stuff */
-#if ASTERISK_VERSION >= 2
+#if ASTERISK_VERSION >= 6
+    cfg = ast_config_load(ESPEAK_CONFIG, config_flags);
+#elif ASTERISK_VERSION >= 2
     cfg = ast_config_load(ESPEAK_CONFIG);
 #else
     cfg = ast_load(ESPEAK_CONFIG);
@@ -521,7 +529,7 @@
     return res;
 }
 
-#if ASTERISK_VERSION == 4
+#if ASTERISK_VERSION >= 4
 static int unload_module(void)
 {
     int res;
