Index: Makefile
--- Makefile.orig	2010-06-10 22:35:06.000000000 +0200
+++ Makefile	2010-07-24 11:16:19.000000000 +0200
@@ -126,40 +126,18 @@
 
 # Define standard directories for various platforms
 # These apply if they are not redefined in asterisk.conf 
-ifeq ($(OSARCH),SunOS)
-  ASTETCDIR=/var/etc/asterisk
-  ASTLIBDIR=/opt/asterisk/lib
-  ASTVARLIBDIR=/var/opt/asterisk
-  ASTDBDIR=$(ASTVARLIBDIR)
-  ASTKEYDIR=$(ASTVARLIBDIR)
-  ASTSPOOLDIR=/var/spool/asterisk
-  ASTLOGDIR=/var/log/asterisk
-  ASTHEADERDIR=/opt/asterisk/include
-  ASTSBINDIR=/opt/asterisk/sbin
-  ASTVARRUNDIR=/var/run/asterisk
-  ASTMANDIR=/opt/asterisk/man
-else
   ASTETCDIR=$(sysconfdir)/asterisk
   ASTLIBDIR=$(libdir)/asterisk
   ASTHEADERDIR=$(includedir)/asterisk
   ASTSBINDIR=$(sbindir)
-  ASTSPOOLDIR=$(localstatedir)/spool/asterisk
-  ASTLOGDIR=$(localstatedir)/log/asterisk
-  ASTVARRUNDIR=$(localstatedir)/run/asterisk
+  ASTSPOOLDIR=$(localstatedir)/spool
+  ASTLOGDIR=$(localstatedir)/log
+  ASTVARRUNDIR=$(localstatedir)/run
   ASTMANDIR=$(mandir)
-ifneq ($(findstring BSD,$(OSARCH)),)
-  ASTVARLIBDIR=$(prefix)/share/asterisk
-  ASTVARRUNDIR=$(localstatedir)/run/asterisk
-  ASTDBDIR=$(localstatedir)/db/asterisk
-else
-  ASTVARLIBDIR=$(localstatedir)/lib/asterisk
-  ASTDBDIR=$(ASTVARLIBDIR)
-endif
+  ASTVARLIBDIR=$(localstatedir)/lib
+  ASTDBDIR=$(localstatedir)/db
   ASTKEYDIR=$(ASTVARLIBDIR)
-endif
-ifeq ($(ASTDATADIR),)
   ASTDATADIR:=$(ASTVARLIBDIR)
-endif
 
 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
 # when starting Asterisk
@@ -259,12 +237,6 @@
   _ASTCFLAGS+=-fsigned-char
 endif
 
-ifeq ($(OSARCH),FreeBSD)
-  # -V is understood by BSD Make, not by GNU make.
-  BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
-  _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
-endif
-
 ifeq ($(OSARCH),NetBSD)
   _ASTCFLAGS+=-pthread -I/usr/pkg/include
 endif
@@ -567,8 +539,7 @@
 	fi
 	mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation
 	mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation/thirdparty
-	mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
-	mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
+	mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr
 	mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
 	mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
 	mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
Index: apps/app_backticks.c
--- apps/app_backticks.c.orig	2010-07-24 11:12:31.000000000 +0200
+++ apps/app_backticks.c	2010-07-24 11:12:31.000000000 +0200
@@ -0,0 +1,129 @@
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.53 $")
+
+#include <stdio.h> 
+#include <asterisk/file.h>
+#include <asterisk/logger.h>
+#include <asterisk/channel.h>
+#include <asterisk/pbx.h>
+#include <asterisk/module.h>
+#include <asterisk/lock.h>
+#include <asterisk/app.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+static char *app      = "BackTicks";
+static char *synopsis = "Execute a shell command and save the result as a variable.";
+static char *desc     = "  Backticks(<VARNAME>|<command>)\n\n"
+                        "Be sure to include a full path to the command!\n";
+
+static char *do_backticks(char *command, char *buf, size_t len) 
+{
+    int fds[2], pid = 0;
+    char *ret = NULL;
+
+    memset(buf, 0, len);
+    if (pipe(fds)) {    
+        ast_log(LOG_WARNING, "Pipe/Exec failed\n");
+    } else {
+        pid = fork();
+        if (pid < 0) {
+            ast_log(LOG_WARNING, "Fork failed\n");
+            close(fds[0]);
+            close(fds[1]);
+        } else if (pid) {
+            /* parent */
+            close(fds[1]);
+            read(fds[0], buf, len);
+            close(fds[0]);
+            ret = buf;
+        } else {
+            /* child */
+            char *argv[255] = {0};
+            int argc = 0;
+            char *p;
+            char *mycmd = ast_strdupa(command);
+            close(fds[0]);
+            dup2(fds[1], STDOUT_FILENO);
+            argv[argc++] = mycmd;
+            do {
+                if ((p = strchr(mycmd, ' '))) {
+                    *p = '\0';
+                    mycmd = ++p;
+                    argv[argc++] = mycmd;
+                }
+            } while (p != NULL);
+            close(fds[1]);          
+            execv(argv[0], argv); 
+            ast_log(LOG_ERROR, "exec of %s failed\n", argv[0]);
+            exit(0);
+        }
+    }
+    return ret;
+}
+
+static int backticks_exec(struct ast_channel *chan, void *data)
+{
+    int res = 0;
+    const char *usage = "Usage: Backticks(<VARNAME>|<command>)";
+    char buf[1024], *argv[2], *mydata;
+    int argc = 0;
+    
+    if (!data) {
+        ast_log(LOG_WARNING, "%s\n", usage);
+        return -1;
+    }
+    ast_autoservice_start(chan);
+    if (!(mydata = ast_strdupa(data))) {
+        ast_log(LOG_ERROR, "Memory Error!\n");
+        res = -1;
+    } else {
+        if((argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]))) < 2) {
+            ast_log(LOG_WARNING, "%s\n", usage);
+            res = -1;
+        }
+        if (do_backticks(argv[1], buf, sizeof(buf)))
+            pbx_builtin_setvar_helper(chan, argv[0], buf);
+        else {
+            ast_log(LOG_WARNING, "No Data!\n");
+            res = -1;
+        }
+    }
+    ast_autoservice_stop(chan);
+    return res;
+}
+
+static int function_backticks(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+    if (!do_backticks(data, buf, len)) {
+        ast_log(LOG_WARNING, "No Data!\n");
+        return -1;
+    }
+    return 0;
+}
+
+static struct ast_custom_function backticks_function = {
+    .name     = "BACKTICKS", 
+    .desc     = "Executes a shell command and evaluates to the result.", 
+    .syntax   = "BACKTICKS(<command>)", 
+    .synopsis = "Executes a shell command.", 
+    .read     = function_backticks
+};
+
+static int unload_module(void)
+{
+    ast_custom_function_unregister(&backticks_function);
+    return ast_unregister_application(app);
+}
+
+static int load_module(void)
+{
+    ast_custom_function_register(&backticks_function);
+    return ast_register_application(app, backticks_exec, synopsis, desc);
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "BACKTICKS() dialplan function");
+
Index: apps/app_meetme.c
--- apps/app_meetme.c.orig	2010-06-23 23:15:53.000000000 +0200
+++ apps/app_meetme.c	2010-07-24 11:12:31.000000000 +0200
@@ -522,6 +522,7 @@
 	CONFFLAG_DURATION_LIMIT = (1 << 30),
 	/*! Do not write any audio to this channel until the state is up. */
 	CONFFLAG_NO_AUDIO_UNTIL_UP = (1 << 31),
+	CONFFLAG_USERNAME = (1 << 31),
 };
 
 enum {
@@ -531,6 +532,7 @@
 	OPT_ARG_DURATION_LIMIT = 3,
 	OPT_ARG_MOH_CLASS = 4,
 	OPT_ARG_ARRAY_SIZE = 5,
+	OPT_ARG_USERNAME = 6,
 };
 
 AST_APP_OPTIONS(meetme_opts, BEGIN_OPTIONS
@@ -563,6 +565,7 @@
 	AST_APP_OPTION('1', CONFFLAG_NOONLYPERSON ),
  	AST_APP_OPTION_ARG('S', CONFFLAG_DURATION_STOP, OPT_ARG_DURATION_STOP),
 	AST_APP_OPTION_ARG('L', CONFFLAG_DURATION_LIMIT, OPT_ARG_DURATION_LIMIT),
+	AST_APP_OPTION_ARG('n', CONFFLAG_USERNAME, OPT_ARG_USERNAME),
 END_OPTIONS );
 
 static const char *app = "MeetMe";
@@ -2243,6 +2246,12 @@
 	if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) {
 		char destdir[PATH_MAX];
 
+ 	    if (   (confflags & CONFFLAG_USERNAME)
+ 		&& !ast_strlen_zero(optargs[OPT_ARG_USERNAME]) 
+ 		&& ast_fileexists(optargs[OPT_ARG_USERNAME], NULL, NULL))
+ 		snprintf(destdir, sizeof(destdir), "%s", optargs[OPT_ARG_USERNAME]);
+ 	    else {
+
 		snprintf(destdir, sizeof(destdir), "%s/meetme", ast_config_AST_SPOOL_DIR);
 
 		if (ast_mkdir(destdir, 0777) != 0) {
@@ -2259,6 +2268,7 @@
 			res = ast_record_review(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, NULL);
 		if (res == -1)
 			goto outrun;
+	    }
 	}
 
 	ast_mutex_lock(&conf->playlock);
Index: build_tools/make_defaults_h
--- build_tools/make_defaults_h.orig	2008-01-24 23:58:10.000000000 +0100
+++ build_tools/make_defaults_h	2010-07-24 11:12:31.000000000 +0200
@@ -17,7 +17,7 @@
 #define DEFAULT_PID        "${INSTALL_PATH}${ASTVARRUNDIR}/asterisk.pid"
 
 #define DEFAULT_VAR_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}"
-#define DEFAULT_DB         "${INSTALL_PATH}${ASTDBDIR}/astdb"
+#define DEFAULT_DB         "${INSTALL_PATH}${ASTDBDIR}/asterisk.db"
 
 #define DEFAULT_DATA_DIR   "${INSTALL_PATH}${ASTDATADIR}"
 #define DEFAULT_KEY_DIR    "${INSTALL_PATH}${ASTDATADIR}/keys"
Index: cdr/cdr_custom.c
--- cdr/cdr_custom.c.orig	2008-11-20 18:48:58.000000000 +0100
+++ cdr/cdr_custom.c	2010-07-24 11:12:31.000000000 +0200
@@ -83,7 +83,7 @@
 					ast_log(LOG_WARNING, "Format string too long, will be truncated, at line %d\n", var->lineno);
 				ast_copy_string(format, var->value, sizeof(format) - 1);
 				strcat(format,"\n");
-				snprintf(master, sizeof(master),"%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name);
+				snprintf(master, sizeof(master),"%s/cdr/%s", ast_config_AST_LOG_DIR, var->name);
 				if (var->next) {
 					ast_log(LOG_NOTICE, "Sorry, only one mapping is supported at this time, mapping '%s' will be ignored at line %d.\n", var->next->name, var->next->lineno);
 					break;
Index: cdr/cdr_sqlite3_custom.c
--- cdr/cdr_sqlite3_custom.c.orig	2010-04-13 18:38:41.000000000 +0200
+++ cdr/cdr_sqlite3_custom.c	2010-07-24 11:12:31.000000000 +0200
@@ -300,7 +300,7 @@
 	}
 
 	/* is the database there? */
-	snprintf(filename, sizeof(filename), "%s/master.db", ast_config_AST_LOG_DIR);
+	snprintf(filename, sizeof(filename), "%s/cdr/master.db", ast_config_AST_LOG_DIR);
 	res = sqlite3_open(filename, &db);
 	if (res != SQLITE_OK) {
 		ast_log(LOG_ERROR, "Could not open database %s.\n", filename);
Index: chan_capi-1.1.5/Makefile
--- chan_capi-1.1.5/Makefile.orig	2010-04-06 19:33:25.000000000 +0200
+++ chan_capi-1.1.5/Makefile	2010-07-24 11:12:31.000000000 +0200
@@ -100,6 +100,9 @@
 CFLAGS+=-O2
 CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
 CFLAGS+=$(shell if uname -m | grep -q "ppc\|arm\|s390"; then echo "-fsigned-char"; fi)
+ifeq (${USE_OWN_LIBCAPI},yes)
+CFLAGS+=-DUSE_OWN_LIBCAPI
+endif
 
 LIBS=-ldl -lpthread -lm
 CC=gcc
Index: chan_capi-1.1.5/chan_capi20.h
--- chan_capi-1.1.5/chan_capi20.h.orig	2005-09-20 20:33:40.000000000 +0200
+++ chan_capi-1.1.5/chan_capi20.h	2010-07-24 11:12:31.000000000 +0200
@@ -8,6 +8,8 @@
 
 #undef CAPI_OS_HINT
 
+#ifndef USE_OWN_LIBCAPI
+
 #if (defined(__FreeBSD__) || defined(__OpenBSD__) || \
      defined(__NetBSD__)  || defined(__APPLE__))
 
@@ -29,6 +31,8 @@
 #include <capiutils.h>
 #endif /* BSD */
 
+#endif
+
 #ifndef HEADER_CID
 #define HEADER_CID(x) ((x)->adr.adrNCCI)
 #endif
Index: chan_capi-1.1.5/chan_capi_utils.c
--- chan_capi-1.1.5/chan_capi_utils.c.orig	2010-04-06 19:33:25.000000000 +0200
+++ chan_capi-1.1.5/chan_capi_utils.c	2010-07-24 11:12:31.000000000 +0200
@@ -1087,6 +1087,9 @@
 {
 	MESSAGE_EXCHANGE_ERROR error;
 	int waitcount = 50;
+#ifndef CAPI_MANUFACTURER_LEN
+#define CAPI_MANUFACTURER_LEN 64
+#endif
 	unsigned char manbuf[CAPI_MANUFACTURER_LEN];
 	_cmsg CMSG;
 
Index: chan_capi-1.1.5/libcapi20/capi20.c
--- chan_capi-1.1.5/libcapi20/capi20.c.orig	2010-04-06 19:33:25.000000000 +0200
+++ chan_capi-1.1.5/libcapi20/capi20.c	2010-07-24 11:12:31.000000000 +0200
@@ -19,8 +19,10 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <assert.h>
+#ifdef __linux__
 #define _LINUX_LIST_H
 #include <linux/capi.h>
+#endif
  
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -48,17 +50,23 @@
 
 #define SEND_BUFSIZ		(128+2048)
 
+#if 0
 static char capidevname[] = "/dev/capi20";
 static char capidevnamenew[] = "/dev/isdn/capi20";
+#endif
 
 static int                  capi_fd = -1;
+#if 0
 static capi_ioctl_struct    ioctl_data;
+#endif
 
 static int remote_capi;
+#if 0
 static char *globalconfigfilename = "/etc/capi20.conf";
 static char *userconfigfilename = ".capi20rc";
 static unsigned short int port;
 static char hostname[1024];
+#endif
 static int tracelevel;
 static char *tracefile;
 
@@ -77,17 +85,21 @@
 #define RCAPI_AUTH_USER_REQ                     CAPICMD(0xff, 0x00)
 #define RCAPI_AUTH_USER_CONF                    CAPICMD(0xff, 0x01)
 
+#if 0
 static char *skip_whitespace(char *s)
 {
 	while (*s && isspace(*s)) s++;
 		return s;
 }
+#endif
 
+#if 0
 static char *skip_nonwhitespace(char *s)
 {
 	while (*s && !isspace(*s)) s++;
 		return s;
 } 
+#endif
 
 static unsigned char get_byte(unsigned char **p)
 {
@@ -95,10 +107,12 @@
 	return((unsigned char)*(*p - 1));
 }
  
+#if 0
 static unsigned short get_word(unsigned char **p)
 {
 	return(get_byte(p) | (get_byte(p) << 8));
 }
+#endif
 
 static unsigned short get_netword(unsigned char **p)
 {
@@ -144,6 +158,7 @@
  * read config file
  */
 
+#if 0
 static int read_config(void)
 {
 	FILE *fp = NULL;
@@ -197,11 +212,13 @@
 	fclose(fp);
 	return(1);
 }
+#endif
 
 /*
  *	socket function
  */
 
+#if 0
 static int open_socket(void)
 {
 	int fd;
@@ -225,6 +242,7 @@
 	close(fd);
 	return(-1);
 }
+#endif
 
 static int socket_read(int fd, unsigned char *buf, int l)
 {
@@ -328,6 +346,8 @@
 	if (likely(capi_fd >= 0))
 		return CapiNoError;
 
+#if 0
+
 	/*----- open managment link -----*/
 	if (read_config() && (remote_capi)) {
 		capi_fd = open_socket();
@@ -347,6 +367,8 @@
 	if (ioctl(capi_fd, CAPI_INSTALLED, 0) == 0)
 		return CapiNoError;
 
+#endif
+
 	return CapiRegNotInstalled;
 }
 
@@ -421,6 +443,7 @@
 	unsigned char *bufferstart;
 };
 
+#if 0
 static struct applinfo *alloc_buffers(
 	unsigned MaxB3Connection,
 	unsigned MaxB3Blks,
@@ -459,6 +482,7 @@
 	ap->lastfree->next = 0;
 	return ap;
 }
+#endif
 
 static void free_buffers(struct applinfo *ap)
 {
@@ -576,14 +600,17 @@
 	unsigned MaxSizeB3,
 	unsigned *ApplID)
 {
+#if 0
 	int applid = 0;
 	char buf[PATH_MAX];
 	int i, fd = -1;
 
     *ApplID = 0;
+#endif
 
     if (capi20_isinstalled() != CapiNoError)
        return CapiRegNotInstalled;
+#if 0
 	if ((!remote_capi) || ((remote_capi) && ((fd = open_socket()) < 0))) {
 	    if ((fd = open(capidevname, O_RDWR|O_NONBLOCK, 0666)) < 0 && 
 		     (errno == ENOENT)) {
@@ -621,6 +648,8 @@
 			close(fd);
 			return(errcode);
 		}
+    }
+#if 0
 	} else if ((applid = ioctl(fd, CAPI_REGISTER, &ioctl_data)) < 0) {
 		if (errno == EIO) {
 			if (ioctl(fd, CAPI_GET_ERRCODE, &ioctl_data) < 0) {
@@ -666,6 +695,7 @@
 		    applid = alloc_applid(fd);
 		} // end old driver compatibility
 	}
+#endif
 	if (remember_applid(applid, fd) < 0) {
 		close(fd);
 		return CapiRegOSResourceErr;
@@ -676,6 +706,7 @@
 		return CapiRegOSResourceErr;
 	}
 	*ApplID = applid;
+#endif
 	return CapiNoError;
 }
 
@@ -784,11 +815,15 @@
 	                ret = CapiIllAppNr;
 	                break;
 	            case EIO:
+#if 0
 	                if (ioctl(fd, CAPI_GET_ERRCODE, &ioctl_data) < 0) {
+#endif
 	                    ret = CapiMsgOSResourceErr;
+#if 0
 	                } else {
 						ret = (unsigned)ioctl_data.errcode;
 					}
+#endif
 	                break;
 	          default:
 	                ret = CapiMsgOSResourceErr;
@@ -842,7 +877,7 @@
 				rcvbuf[15] = (data >> 24) & 0xff;
 			} else {
 				u_int64_t data;
-				ulong radr = (ulong)rcvbuf;
+				unsigned long radr = (unsigned long)rcvbuf;
 				if (CAPIMSG_LEN(rcvbuf) < 30) {
 					/*
 					 * grr, 64bit arch, but no data64 included,
@@ -899,6 +934,9 @@
 {
 	if (capi20_isinstalled() != CapiNoError)
 		return 0;
+#ifndef CAPI_MANUFACTURER_LEN
+#define CAPI_MANUFACTURER_LEN 64
+#endif
 
 	if (remote_capi) {
 		unsigned char buf[100];
@@ -911,15 +949,19 @@
 		return Buf;
 	}
 
+#if 0
     ioctl_data.contr = Ctrl;
 
 	if (ioctl(capi_fd, CAPI_GET_MANUFACTURER, &ioctl_data) < 0)
+#endif
 		return 0;
 
+#if 0
 	memcpy(Buf, ioctl_data.manufacturer, CAPI_MANUFACTURER_LEN);
 	Buf[CAPI_MANUFACTURER_LEN-1] = 0;
 
 	return Buf;
+#endif
 }
 
 unsigned char *
@@ -934,16 +976,20 @@
 		set_rcapicmd_header(&p, 14, RCAPI_GET_VERSION_REQ, Ctrl);
 		if(!(remote_command(capi_fd, buf, 14, RCAPI_GET_VERSION_CONF)))
 			return 0;
-		memcpy(Buf, buf + 1, sizeof(capi_version));
+		memcpy(Buf, buf + 1, 128 /* sizeof(capi_version) */);
 		return Buf;
 	}
 
+#if 0
 	ioctl_data.contr = Ctrl;
 	if (ioctl(capi_fd, CAPI_GET_VERSION, &ioctl_data) < 0) {
+#endif
 		return 0;
+#if 0
 	}
 	memcpy(Buf, &ioctl_data.version, sizeof(capi_version));
 	return Buf;
+#endif
 }
 
 unsigned char * 
@@ -952,6 +998,10 @@
 	if (capi20_isinstalled() != CapiNoError)
 		return 0;
 
+#ifndef CAPI_SERIAL_LEN
+#define CAPI_SERIAL_LEN 8
+#endif
+
 	if (remote_capi) {
 		unsigned char buf[100];
 		unsigned char *p = buf;
@@ -963,15 +1013,19 @@
 		return Buf;
 	}
 
+#if 0
 	ioctl_data.contr = Ctrl;
 
 	if (ioctl(capi_fd, CAPI_GET_SERIAL, &ioctl_data) < 0)
+#endif
 		return 0;
 
+#if 0
 	memcpy(Buf, &ioctl_data.serial, CAPI_SERIAL_LEN);
 	Buf[CAPI_SERIAL_LEN-1] = 0;
 
 	return Buf;
+#endif
 }
 
 unsigned
@@ -993,7 +1047,7 @@
 			unsigned short* tmp = (unsigned short*)buf;
 
 			if(*tmp == CapiNoError) {
-				memcpy(Buf, buf + 2, (Ctrl) ? sizeof(struct capi_profile) : 2);
+				memcpy(Buf, buf + 2, (Ctrl) ? 224 /* sizeof(struct capi_profile) */ : 2);
 			}
 
 			fret = *tmp; 
@@ -1002,6 +1056,9 @@
 		return (fret);
 	}
 
+#if 1
+    return CapiMsgOSResourceErr;
+#else
 	ioctl_data.contr = Ctrl;
 
 	if (ioctl(capi_fd, CAPI_GET_PROFILE, &ioctl_data) < 0) {
@@ -1018,6 +1075,7 @@
 			sizeof(ioctl_data.profile.ncontroller));
 	}
 	return CapiNoError;
+#endif
 }
 /*
  * functions added to the CAPI2.0 spec
Index: chan_capi-1.1.5/libcapi20/convert.c
--- chan_capi-1.1.5/libcapi20/convert.c.orig	2009-07-23 16:11:08.000000000 +0200
+++ chan_capi-1.1.5/libcapi20/convert.c	2010-07-24 11:12:31.000000000 +0200
@@ -11,7 +11,14 @@
 #include <stddef.h>
 #include <time.h>
 #include <ctype.h>
+#ifdef __FreeBSD__
+#include <sys/endian.h>
+#define bswap_16 bswap16
+#define bswap_32 bswap32
+#define bswap_64 bswap64
+#else
 #include <byteswap.h>
+#endif
 
 #include "capi20.h"
 
Index: channels/console_video.h
--- channels/console_video.h.orig	2008-06-30 17:45:15.000000000 +0200
+++ channels/console_video.h	2010-07-24 11:12:31.000000000 +0200
@@ -28,10 +28,7 @@
 		"console {device}"
 #else
 
-#include <ffmpeg/avcodec.h>
-#ifndef OLD_FFMPEG
-#include <ffmpeg/swscale.h>     /* requires a recent ffmpeg */
-#endif
+#include <libavcoded/avcodec.h>
 
 #define CONSOLE_VIDEO_CMDS			\
 	"console {videodevice|videocodec"	\
Index: configure
--- configure.orig	2010-06-24 01:40:16.000000000 +0200
+++ configure	2010-07-24 11:14:22.000000000 +0200
@@ -4530,11 +4530,6 @@
 	# note- does not work on FreeBSD
 
 case "${host_os}" in
-     freebsd*)
-
-     CPPFLAGS=-I/usr/local/include
-     LDFLAGS=-L/usr/local/lib
-     ;;
      openbsd*)
 
      if test ${prefix} = '/usr/local' || test ${prefix} = 'NONE'; then
Index: main/Makefile
--- main/Makefile.orig	2010-06-25 20:58:37.000000000 +0200
+++ main/Makefile	2010-07-24 11:12:31.000000000 +0200
@@ -78,10 +78,7 @@
 endif
 
 ifeq ($(OSARCH),FreeBSD)
-  # -V is understood by BSD Make, not by GNU make.
-  BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
-  AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
-  AST_LIBS+=-lcrypto
+  AST_LIBS+=-lpthread -lcrypto
 endif
 
 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
Index: main/file.c
--- main/file.c.orig	2010-03-25 17:26:13.000000000 +0100
+++ main/file.c	2010-07-24 11:12:31.000000000 +0200
@@ -254,7 +254,7 @@
 	char *fn = NULL;
 
 	if (!strcmp(ext, "wav49"))
-		ext = "WAV";
+		ext = "wav";
 
 	if (filename[0] == '/') {
 		if (asprintf(&fn, "%s.%s", filename, ext) < 0) {
Index: main/tcptls.c
--- main/tcptls.c.orig	2010-03-20 18:33:03.000000000 +0100
+++ main/tcptls.c	2010-07-24 11:12:31.000000000 +0200
@@ -325,6 +325,7 @@
 	if (!ast_strlen_zero(cfg->cafile) || !ast_strlen_zero(cfg->capath)) {
 		if (SSL_CTX_load_verify_locations(cfg->ssl_ctx, S_OR(cfg->cafile, NULL), S_OR(cfg->capath,NULL)) == 0)
 			ast_verb(0, "SSL CA file(%s)/path(%s) error\n", cfg->cafile, cfg->capath);
+        SSL_CTX_set_client_CA_list(cfg->ssl_ctx, S_OR(cfg->cafile, NULL));
 	}
 
 	ast_verb(0, "SSL certificate ok\n");
Index: menuselect-tree
--- menuselect-tree.orig	2010-07-22 21:20:17.000000000 +0200
+++ menuselect-tree	2010-07-24 11:12:31.000000000 +0200
@@ -153,6 +153,8 @@
 </member>
 <member name="app_system" displayname="Generic System() application" remove_on_change="apps/app_system.o apps/app_system.so">
 </member>
+<member name="app_backticks" displayname="Generic Backticks() application" remove_on_change="apps/app_backticks.o apps/app_backticks.so">
+</member>
 <member name="app_talkdetect" displayname="Playback with Talk Detection" remove_on_change="apps/app_talkdetect.o apps/app_talkdetect.so">
 </member>
 <member name="app_test" displayname="Interface Test Application" remove_on_change="apps/app_test.o apps/app_test.so">
@@ -693,9 +695,9 @@
 		<member name="CORE-SOUNDS-EN-ULAW" displayname="English, mu-Law format">
 		</member>
 		<member name="CORE-SOUNDS-EN-ALAW" displayname="English, a-Law format">
+			<defaultenabled>yes</defaultenabled>
 		</member>
 		<member name="CORE-SOUNDS-EN-GSM" displayname="English, GSM format" >
-			<defaultenabled>yes</defaultenabled>
 		</member>
 		<member name="CORE-SOUNDS-EN-G729" displayname="English, G.729 format">
 		</member>
@@ -771,6 +773,7 @@
 		<member name="EXTRA-SOUNDS-EN-ULAW" displayname="English, mu-Law format">
 		</member>
 		<member name="EXTRA-SOUNDS-EN-ALAW" displayname="English, a-Law format">
+			<defaultenabled>yes</defaultenabled>
 		</member>
 		<member name="EXTRA-SOUNDS-EN-GSM" displayname="English, GSM format" >
 		</member>
Index: res/res_http_post.c
--- res/res_http_post.c.orig	2009-10-27 18:12:09.000000000 +0100
+++ res/res_http_post.c	2010-07-24 11:12:31.000000000 +0200
@@ -122,14 +122,8 @@
 		ast_log(LOG_WARNING, "Got unexpected GMIME_IS_MESSAGE_PARTIAL\n");
 		return;
 	} else if (GMIME_IS_MULTIPART(part)) {
-		GList *l;
-		
-		ast_log(LOG_WARNING, "Got unexpected GMIME_IS_MULTIPART, trying to process subparts\n");
-		l = GMIME_MULTIPART(part)->subparts;
-		while (l) {
-			process_message_callback(l->data, cbinfo);
-			l = l->next;
-		}
+  		ast_log(LOG_WARNING, "Got unexpected GMIME_IS_MULTIPART, trying to process subparts\n");
+		g_mime_multipart_foreach(GMIME_MULTIPART(part), process_message_callback, cbinfo);
 	} else if (GMIME_IS_PART(part)) {
 		const char *filename;
 
Index: sounds/sounds.xml
--- sounds/sounds.xml.orig	2009-08-18 22:31:40.000000000 +0200
+++ sounds/sounds.xml	2010-07-24 11:12:31.000000000 +0200
@@ -4,9 +4,9 @@
 		<member name="CORE-SOUNDS-EN-ULAW" displayname="English, mu-Law format">
 		</member>
 		<member name="CORE-SOUNDS-EN-ALAW" displayname="English, a-Law format">
+			<defaultenabled>yes</defaultenabled>
 		</member>
 		<member name="CORE-SOUNDS-EN-GSM" displayname="English, GSM format" >
-			<defaultenabled>yes</defaultenabled>
 		</member>
 		<member name="CORE-SOUNDS-EN-G729" displayname="English, G.729 format">
 		</member>
@@ -82,6 +82,7 @@
 		<member name="EXTRA-SOUNDS-EN-ULAW" displayname="English, mu-Law format">
 		</member>
 		<member name="EXTRA-SOUNDS-EN-ALAW" displayname="English, a-Law format">
+			<defaultenabled>yes</defaultenabled>
 		</member>
 		<member name="EXTRA-SOUNDS-EN-GSM" displayname="English, GSM format" >
 		</member>
