Index: Makefile
--- Makefile.orig	2006-09-06 22:09:10 +0200
+++ Makefile	2006-10-22 14:07:55 +0200
@@ -47,14 +47,14 @@
 #K6OPT  = -DK6OPT
 
 #Tell gcc to optimize the code
-OPTIMIZE+=-O6
+#OPTIMIZE+=-O6
 endif
 
 #Overwite config files on "make samples"
 OVERWRITE=y
 
 #Include debug and macro symbols in the executables (-g) and profiling info (-pg)
-DEBUG=-g3 #-pg
+#DEBUG=-g3 #-pg
 
 #Set NOCRYPTO to yes if you do not want to have crypto support or 
 #dependencies
@@ -110,35 +110,19 @@
 # Don't use together with -DBUSYDETECT_TONEONLY
 BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
 
-ifneq ($(OSARCH),SunOS)
-  ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
-  ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
-  ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
-  ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
-  ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
-  ASTHEADERDIR=$(INSTALL_PREFIX)/usr/include/asterisk
-  ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
-  ASTBINDIR=$(INSTALL_PREFIX)/usr/bin
-  ASTSBINDIR=$(INSTALL_PREFIX)/usr/sbin
-  ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
-  ASTMANDIR=$(INSTALL_PREFIX)/usr/share/man
-  MODULES_DIR=$(ASTLIBDIR)/modules
-  AGI_DIR=$(ASTVARLIBDIR)/agi-bin
-else
-  ASTLIBDIR=$(INSTALL_PREFIX)/opt/asterisk/lib
-  ASTVARLIBDIR=$(INSTALL_PREFIX)/var/opt/asterisk/lib
-  ASTETCDIR=$(INSTALL_PREFIX)/etc/opt/asterisk
-  ASTSPOOLDIR=$(INSTALL_PREFIX)/var/opt/asterisk/spool
-  ASTLOGDIR=$(INSTALL_PREFIX)/var/opt/asterisk/log
-  ASTHEADERDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/include/asterisk
-  ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
-  ASTBINDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/bin
-  ASTSBINDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/sbin
-  ASTVARRUNDIR=$(INSTALL_PREFIX)/var/opt/asterisk/run
-  ASTMANDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/share/man
-  MODULES_DIR=$(ASTLIBDIR)/modules
-  AGI_DIR=$(ASTVARLIBDIR)/agi-bin
-endif
+ASTLIBDIR=$(INSTALL_PREFIX)/lib/asterisk
+ASTVARLIBDIR=$(INSTALL_PREFIX)/share/asterisk
+ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
+ASTSPOOLDIR=$(INSTALL_PREFIX)/var/asterisk/spool
+ASTLOGDIR=$(INSTALL_PREFIX)/var/asterisk/log
+ASTHEADERDIR=$(INSTALL_PREFIX)/include/asterisk
+ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
+ASTBINDIR=$(INSTALL_PREFIX)/bin
+ASTSBINDIR=$(INSTALL_PREFIX)/sbin
+ASTVARRUNDIR=$(INSTALL_PREFIX)/var/asterisk/run
+ASTMANDIR=$(INSTALL_PREFIX)/man
+MODULES_DIR=$(ASTLIBDIR)/modules
+AGI_DIR=$(ASTLIBDIR)/agi-bin
 
 ASTCFLAGS=
 
@@ -218,21 +202,29 @@
 ID=id
 
 ifeq ($(OSARCH),SunOS)
-  GREP=/usr/xpg4/bin/grep
-  M4=/usr/local/bin/m4
-  ID=/usr/xpg4/bin/id
-  LN=/usr/xpg4/bin/ln
-  INSTALL=ginstall
+  GREP=$(shell if [ -f /usr/xpg4/bin/grep ]; then echo /usr/xpg4/bin/grep; else echo grep; fi)
+  ID=$(shell if [ -f /usr/xpg4/bin/id ]; then echo /usr/xpg4/bin/grep; else echo id; fi)
+  LN=$(shell if [ -f /usr/xpg4/bin/ln ]; then echo /usr/xpg4/bin/grep; else echo ln; fi)
+  INSTALL=$(INSTALL_PREFIX)/lib/openpkg/shtool install -c
 endif
 
 INCLUDE+=-Iinclude -I../include
 ASTCFLAGS+=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
+ASTCFLAGS+=-Wno-sign-compare  -Wno-pointer-sign
 ASTCFLAGS+=$(OPTIMIZE)
 ASTOBJ=-o asterisk
 
 ifeq ($(findstring BSD,$(OSARCH)),BSD)
   PROC=$(shell uname -m)
-  ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
+endif
+
+ASTCFLAGS+=-I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)/lib
+
+ifndef WITHOUT_ZAPTEL
+ifeq ($(OSARCH),FreeBSD)
+ASTCFLAGS+=-I/usr/local/include
+LIBS+=-L/usr/local/lib
+endif
 endif
 
 ifneq ($(PROC),ultrasparc)
@@ -252,29 +244,9 @@
 endif
 
 ifeq ($(OSARCH),FreeBSD)
-  BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
-  ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
-  LIBS+=$(shell if test  $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
-  ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/spandsp),)
-    ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/spandsp
-  endif
+  CFLAGS+=-pthread
+  LIBS+=-pthread
   MPG123TARG=freebsd
-
-  # XXX FreeBSD paths
-  PREFIX?=/usr/local
-  ASTLIBDIR=$(INSTALL_PREFIX)$(PREFIX)/lib/asterisk
-  ASTVARLIBDIR=$(INSTALL_PREFIX)$(PREFIX)/share/asterisk
-  ASTETCDIR=$(INSTALL_PREFIX)$(PREFIX)/etc/asterisk
-  ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
-  ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
-  ASTHEADERDIR=$(INSTALL_PREFIX)$(PREFIX)/include/asterisk
-  ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
-  ASTBINDIR=$(INSTALL_PREFIX)$(PREFIX)/bin
-  ASTSBINDIR=$(INSTALL_PREFIX)$(PREFIX)/sbin
-  ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
-  ASTMANDIR=$(INSTALL_PREFIX)$(PREFIX)/man
-  # XXX end FreeBSD paths
-
 endif # FreeBSD
 
 ifeq ($(OSARCH),NetBSD)
@@ -289,7 +261,7 @@
 
 ifeq ($(OSARCH),SunOS)
   ASTCFLAGS+=-Wcast-align -DSOLARIS
-  INCLUDE+=-Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/opt/ssl/include -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
+  INCLUDE+=-Iinclude/solaris-compat
   ifeq ($(OSCPU),sun4u)
     OPTIMIZE+=-mcpu=v9 -mcpu=ultrasparc
   endif
@@ -341,9 +313,9 @@
 ASTCFLAGS+= $(MALLOC_DEBUG)
 ASTCFLAGS+= $(BUSYDETECT)
 ASTCFLAGS+= $(OPTIONS)
-ifneq ($(findstring dont-optimize,$(MAKECMDGOALS)),dont-optimize)
-ASTCFLAGS+= -fomit-frame-pointer 
-endif
+#ifneq ($(findstring dont-optimize,$(MAKECMDGOALS)),dont-optimize)
+#ASTCFLAGS+= -fomit-frame-pointer 
+#endif
 SUBDIRS=res channels pbx apps codecs formats agi cdr funcs utils stdtime
 
 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
@@ -702,31 +674,6 @@
 	fi
 
 install: all datafiles bininstall install-subdirs
-	@if [ -x /usr/sbin/asterisk-post-install ]; then \
-		/usr/sbin/asterisk-post-install $(DESTDIR) . ; \
-	fi
-	@echo " +---- Asterisk Installation Complete -------+"  
-	@echo " +                                           +"
-	@echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
-	@echo " +                                           +"
-	@echo " + Asterisk has successfully been installed. +"  
-	@echo " + If you would like to install the sample   +"  
-	@echo " + configuration files (overwriting any      +"
-	@echo " + existing config files), run:              +"  
-	@echo " +                                           +"
-	@echo " +               $(MAKE) samples                +"
-	@echo " +                                           +"
-	@echo " +-----------------  or ---------------------+"
-	@echo " +                                           +"
-	@echo " + You can go ahead and install the asterisk +"
-	@echo " + program documentation now or later run:   +"
-	@echo " +                                           +"
-	@echo " +              $(MAKE) progdocs                +"
-	@echo " +                                           +"
-	@echo " + **Note** This requires that you have      +"
-	@echo " + doxygen installed on your local system    +"
-	@echo " +-------------------------------------------+"
-	@$(MAKE) -s oldmodcheck
 
 upgrade: all bininstall
 
Index: agi/Makefile
--- agi/Makefile.orig	2006-03-28 22:22:05 +0200
+++ agi/Makefile	2006-10-22 14:07:55 +0200
@@ -20,9 +20,7 @@
   LIBS=-lsocket -lnsl ../strcompat.o
 endif
 
-ifeq ($(findstring BSD,${OSARCH}),BSD)
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
-endif
+CFLAGS+=-I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)/lib
 
 all: depend $(AGIS)
 
Index: app_conference/Makefile
--- app_conference/Makefile.orig	2005-10-27 19:53:35 +0200
+++ app_conference/Makefile	2006-10-22 14:07:55 +0200
@@ -20,10 +20,10 @@
 INSTALL_PREFIX := /opt/horizon
 INSTALL_MODULES_DIR := $(INSTALL_PREFIX)/lib/asterisk/modules
 
-ASTERISK_INCLUDE_DIR := $(HOME)/local/asterisk/asterisk/include
+ASTERISK_INCLUDE_DIR := ../include
 
 # turn app_conference debugging on or off ( 0 == OFF, 1 == ON )
-APP_CONFERENCE_DEBUG := 1
+APP_CONFERENCE_DEBUG := 0
 
 # 0 = OFF 1 = astdsp 2 = speex
 SILDET := 2
@@ -44,22 +44,23 @@
 CC = gcc
 
 INCLUDE = -I$(ASTERISK_INCLUDE_DIR) 
-LIBS = -ldl -lpthread -lm
-DEBUG := -g 
+LIBS = -lpthread -lm
+DEBUG :=
 
 CFLAGS = -pipe -Wall -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE
+CFLAGS += -fPIC
 #CFLAGS += -O2
 #CFLAGS += -O3 -march=pentium3 -msse -mfpmath=sse,387 -ffast-math 
 # PERF: below is 10% faster than -O2 or -O3 alone.
 #CFLAGS += -O3 -ffast-math -funroll-loops
 # below is another 5% faster or so.
-CFLAGS += -O3 -ffast-math -funroll-all-loops -fprefetch-loop-arrays -fsingle-precision-constant
+#CFLAGS += -O3 -ffast-math -funroll-all-loops -fprefetch-loop-arrays -fsingle-precision-constant
 
 # this is fun for PPC
 #CFLAGS += -mcpu=7450 -faltivec -mabi=altivec -mdynamic-no-pic
 
 # this is fun for x86
-CFLAGS += -march=pentium3 -msse -mfpmath=sse,387
+#CFLAGS += -march=pentium3 -msse -mfpmath=sse,387
 
 
 # adding -msse -mfpmath=sse has little effect.
@@ -72,13 +73,19 @@
 CFLAGS += -DAPP_CONFERENCE_DEBUG
 endif
 
+OSARCH=$(shell uname -s)
+ifeq ($(OSARCH),SunOS)
+  CFLAGS+=-DSOLARIS -I$(ASTERISK_INCLUDE_DIR)/solaris-compat
+endif
+
 #
 # additional flag values for silence detection
 #
 
 ifeq ($(SILDET), 2)
-OBJS += libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o
-CFLAGS += -Ilibspeex -DSILDET=2
+CFLAGS += -DSILDET=2
+CFLAGS += -I$(INSTALL_PREFIX)/include/speex -I$(INSTALL_PREFIX)/include
+LIBS += -L$(INSTALL_PREFIX)/lib -lspeex -lm
 endif
 
 ifeq ($(SILDET), 1)
@@ -102,14 +109,13 @@
 	rm -f *.so *.o $(OBJS)
 
 app_conference.so : $(OBJS)
-	$(CC) -pg -shared -Xlinker -x -o $@ $(OBJS)
+	$(CC) -shared -Xlinker -x -o $@ $(OBJS) $(LIBS)
 
 vad_test: vad_test.o libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o
 	$(CC) $(PROFILE) -o $@ $^ -lm
 
 install: all
 	for x in $(SHAREDOS); do $(INSTALL) -m 755 $$x $(INSTALL_MODULES_DIR) ; done
-	/var/horizon/mojo/lib/horizoncmd restart asterisk
 
 # config: all
 # 	cp conf.conf /etc/asterisk/
Index: app_conference/app_conference.h
--- app_conference/app_conference.h.orig	2005-12-16 23:31:58 +0100
+++ app_conference/app_conference.h	2006-10-22 14:07:55 +0200
@@ -33,6 +33,7 @@
 #include <asterisk/channel.h>
 #include <asterisk/file.h>
 #include <asterisk/cli.h>
+#include <asterisk/utils.h>
 
 /* standard includes */
 #include <stdlib.h>
@@ -40,10 +41,9 @@
 #include <string.h>
 #include <math.h>
 
-#include <pthread.h>
-
 #if (SILDET == 2)
-#include "libspeex/speex_preprocess.h"
+#include <speex/speex.h>
+#include <speex/speex_preprocess.h>
 #endif
 
 //
Index: app_conference/conference.c
--- app_conference/conference.c.orig	2005-10-27 19:53:35 +0200
+++ app_conference/conference.c	2006-10-22 14:07:55 +0200
@@ -568,7 +568,6 @@
 	conf->memberlist = NULL ;
 
 	conf->membercount = 0 ;
-	conf->conference_thread = -1 ;
 
 	conf->debug_flag = 0 ;
 
@@ -618,7 +617,7 @@
 	// acquire conference mutexes
 	ast_mutex_lock( &conf->lock ) ;
 	
-	if ( pthread_create( &conf->conference_thread, NULL, (void*)conference_exec, conf ) == 0 ) 
+	if ( ast_pthread_create( &conf->conference_thread, NULL, (void*)conference_exec, conf ) == 0 ) 
 	{
 		// detach the thread so it doesn't leak
 		pthread_detach( conf->conference_thread ) ;
@@ -632,8 +631,6 @@
 	{
 		ast_log( LOG_ERROR, "unable to start conference thread for conference %s\n", conf->name ) ;
 		
-		conf->conference_thread = -1 ;
-
 		// release conference mutexes
 		ast_mutex_unlock( &conf->lock ) ;
 
Index: apps/Makefile
--- apps/Makefile.orig	2006-04-30 15:38:22 +0200
+++ apps/Makefile	2006-10-22 14:07:55 +0200
@@ -54,16 +54,11 @@
 APPS+=app_osplookup.so
 endif
 
-ifeq ($(findstring BSD,${OSARCH}),BSD)
-CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
-endif
+CFLAGS+=-I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)/lib
 
-CURLLIBS=$(shell $(CROSS_COMPILE_BIN)curl-config --libs)
-ifneq ($(shell if [[ 0x`$(CROSS_COMPILE_BIN)curl-config --vernum` -ge 0x70907 ]]; then echo "OK" ; fi),)
-  ifneq (${CURLLIBS},)
-    APPS+=app_curl.so
-  endif 
-endif
+CFLAGS+=$(shell $(INSTALL_PREFIX)/bin/curl-config --cflags)
+CURLLIBS=$(shell $(INSTALL_PREFIX)/bin/curl-config --libs)
+APPS+=app_curl.so
 
 ifeq (${OSARCH},CYGWIN)
 CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
Index: asterisk-addons-1.2.5/Makefile
--- asterisk-addons-1.2.5/Makefile.orig	2005-12-02 00:14:28 +0100
+++ asterisk-addons-1.2.5/Makefile	2006-10-22 14:07:55 +0200
@@ -27,17 +27,9 @@
 #
 # MySQL stuff...  Autoconf anyone??
 #
-MODS+=$(shell if [ -d /usr/local/mysql/include ] || [ -d /usr/include/mysql ] || [ -d /usr/local/include/mysql ] || [ -d /opt/mysql/include ]; then echo "cdr_addon_mysql.so app_addon_sql_mysql.so res_config_mysql.so"; fi)
-CFLAGS+=$(shell if [ -d /usr/local/mysql/include ]; then echo "-I/usr/local/mysql/include"; fi)
-CFLAGS+=$(shell if [ -d /usr/include/mysql ]; then echo "-I/usr/include/mysql"; fi)
-CFLAGS+=$(shell if [ -d /usr/local/include/mysql ]; then echo "-I/usr/local/include/mysql"; fi)
-CFLAGS+=$(shell if [ -d /opt/mysql/include/mysql ]; then echo "-I/opt/mysql/include/mysql"; fi)
-MLFLAGS=
-MLFLAGS+=$(shell if [ -d /usr/lib/mysql ]; then echo "-L/usr/lib/mysql"; fi)
-MLFLAGS+=$(shell if [ -d /usr/lib64/mysql ]; then echo "-L/usr/lib64/mysql"; fi)
-MLFLAGS+=$(shell if [ -d /usr/local/mysql/lib ]; then echo "-L/usr/local/mysql/lib"; fi)
-MLFLAGS+=$(shell if [ -d /usr/local/lib/mysql ]; then echo "-L/usr/local/lib/mysql"; fi)
-MLFLAGS+=$(shell if [ -d /opt/mysql/lib/mysql ]; then echo "-L/opt/mysql/lib/mysql"; fi)
+CFLAGS+=-I$(INSTALL_PREFIX)/include
+MFLAGS+=-L$(INSTALL_PREFIX)/lib
+MODS+=cdr_addon_mysql.so app_addon_sql_mysql.so res_config_mysql.so
 
 OSARCH=$(shell uname -s)
 
Index: asterisk-sounds-1.2.1/Makefile
--- asterisk-sounds-1.2.1/Makefile.orig	2005-12-02 00:20:51 +0100
+++ asterisk-sounds-1.2.1/Makefile	2006-10-22 14:07:55 +0200
@@ -66,7 +66,7 @@
 	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/ha
 	for x in sounds/letters/*.gsm; do \
 		if grep -q "^%`basename $$x`%" sounds-extra.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
@@ -74,7 +74,7 @@
 	done
 	for x in sounds/phonetic/*.gsm; do \
 		if grep -q "^%`basename $$x`%" sounds-extra.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
@@ -82,7 +82,7 @@
 	done
 	for x in sounds/silence/*.gsm; do \
 		if grep -q "^%`basename $$x`%" sounds-extra.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/silence ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/silence ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
@@ -90,7 +90,7 @@
 	done
 	for x in sounds/wx/*.gsm; do \
 		if grep -q "^%`basename $$x`%" sounds-extra.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/wx ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/wx ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
@@ -98,7 +98,7 @@
 	done
 	for x in sounds/ha/*.gsm; do \
 		if grep -q "^%`basename $$x`%" sounds-extra.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/ha ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/ha ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
@@ -106,7 +106,7 @@
 	done
 	for x in sounds/*.gsm; do \
 		if grep -q "^%`basename $$x`%" sounds-extra.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
Index: asterisk.c
--- asterisk.c.orig	2006-09-26 22:49:21 +0200
+++ asterisk.c	2006-10-22 14:07:55 +0200
@@ -1902,9 +1902,9 @@
 		} else if (!strcasecmp(v->name, "astspooldir")) {
 			ast_copy_string(ast_config_AST_SPOOL_DIR, v->value, sizeof(ast_config_AST_SPOOL_DIR));
 			snprintf(ast_config_AST_MONITOR_DIR, sizeof(ast_config_AST_MONITOR_DIR) - 1, "%s/monitor", v->value);
+			snprintf(ast_config_AST_DB, sizeof(ast_config_AST_DB), "%s/astdb", v->value);
 		} else if (!strcasecmp(v->name, "astvarlibdir")) {
 			ast_copy_string(ast_config_AST_VAR_DIR, v->value, sizeof(ast_config_AST_VAR_DIR));
-			snprintf(ast_config_AST_DB, sizeof(ast_config_AST_DB), "%s/astdb", v->value);
 			snprintf(ast_config_AST_KEY_DIR, sizeof(ast_config_AST_KEY_DIR), "%s/keys", v->value);
 		} else if (!strcasecmp(v->name, "astlogdir")) {
 			ast_copy_string(ast_config_AST_LOG_DIR, v->value, sizeof(ast_config_AST_LOG_DIR));
Index: build_tools/make_build_h
--- build_tools/make_build_h.orig	2006-03-03 18:13:37 +0100
+++ build_tools/make_build_h	2006-10-22 14:07:55 +0200
@@ -4,7 +4,11 @@
 MACHINE=`uname -m`
 OS=`uname -s`
 if [ `uname -s` = "SunOS" ]; then
+  if [ -f /usr/xpg4/bin/id ]; then
   USER=`/usr/xpg4/bin/id -un`
+  else
+  USER=`/usr/bin/id -un`
+  fi
 else
   USER=`id -un`
 fi
Index: build_tools/make_defaults_h
--- build_tools/make_defaults_h.orig	2005-06-20 19:26:08 +0200
+++ build_tools/make_defaults_h	2006-10-22 14:07:55 +0200
@@ -14,7 +14,7 @@
 #define AST_LOG_DIR    "${INSTALL_PATH}${ASTLOGDIR}"
 #define AST_AGI_DIR    "${INSTALL_PATH}${AGI_DIR}"
 #define AST_KEY_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}/keys"
-#define AST_DB         "${INSTALL_PATH}${ASTVARLIBDIR}/astdb"
+#define AST_DB         "${INSTALL_PATH}${ASTSPOOLDIR}/astdb"
 #define AST_TMP_DIR    "${INSTALL_PATH}${ASTSPOOLDIR}/tmp"
 
 #define AST_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"
Index: cdr/Makefile
--- cdr/Makefile.orig	2006-09-21 18:18:19 +0200
+++ cdr/Makefile	2006-10-22 14:07:55 +0200
@@ -20,10 +20,8 @@
 CFLAGS+=-fPIC
 endif
 
-ifeq ($(findstring BSD,${OSARCH}),BSD)
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include
-  SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
-endif
+CFLAGS+=-I$(INSTALL_PREFIX)/include
+SOLINK+=-L$(INSTALL_PREFIX)/lib
 
 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
 #This works for even old (2.96) versions of gcc and provides a small boost either way.
Index: chan_capi_1_6_1/Makefile
--- chan_capi_1_6_1/Makefile.orig	2006-06-21 17:06:35 +0200
+++ chan_capi_1_6_1/Makefile	2006-10-22 14:10:15 +0200
@@ -10,38 +10,14 @@
 
 INSTALL_PREFIX=
 
-ASTERISK_HEADER_DIR=$(INSTALL_PREFIX)/usr/include
+ASTERISK_HEADER_DIR=../include
 
-ifeq (${OSNAME},FreeBSD)
-ASTERISK_HEADER_DIR=$(INSTALL_PREFIX)/usr/local/include
-endif
-
-ifeq (${OSNAME},NetBSD)
-ASTERISK_HEADER_DIR=$(INSTALL_PREFIX)/usr/pkg/include
-endif
-
-ASTERISKVERSION=$(shell if [ -f .version ]; then cat .version; else if [ -d CVS ]; then if [ -f CVS/Tag ] ; then echo "CVS-`sed 's/^T//g' CVS/Tag`-`date +"%D-%T"`"; else echo "CVS-HEAD-`date +"%D-%T"`"; fi; fi; fi)
-
-MODULES_DIR=$(INSTALL_PREFIX)/usr/lib/asterisk/modules
-
-ifeq (${OSNAME},FreeBSD)
-MODULES_DIR=$(INSTALL_PREFIX)/usr/local/lib/asterisk/modules
-endif
+ASTERISKVERSION=$(shell if [ -f ../.version ]; then cat ../.version; else if [ -d CVS ]; then if [ -f CVS/Tag ] ; then echo "CVS-`sed 's/^T//g' CVS/Tag`-`date +"%D-%T"`"; else echo "CVS-HEAD-`date +"%D-%T"`"; fi; fi; fi)
 
-ifeq (${OSNAME},NetBSD)
-MODULES_DIR=$(INSTALL_PREFIX)/usr/pkg/lib/asterisk/modules
-endif
+MODULES_DIR=$(INSTALL_PREFIX)/lib/asterisk/modules
 
 CONFIG_DIR=$(INSTALL_PREFIX)/etc/asterisk
 
-ifeq (${OSNAME},FreeBSD)
-CONFIG_DIR=$(INSTALL_PREFIX)/usr/local/etc/asterisk
-endif
-
-ifeq (${OSNAME},NetBSD)
-CONFIG_DIR=$(INSTALL_PREFIX)/usr/pkg/etc/asterisk
-endif
-
 PROC=$(shell uname -m)
 
 DEBUG=-g #-pg
@@ -56,7 +32,7 @@
 endif
 CFLAGS=-pipe -fPIC -Wall -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE
 CFLAGS+=$(OPTIMIZE)
-CFLAGS+=-O6
+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; then echo "-fsigned-char"; fi)
 CFLAGS+=-Wformat
Index: channels/Makefile
--- channels/Makefile.orig	2006-08-17 23:57:19 +0200
+++ channels/Makefile	2006-10-22 14:07:55 +0200
@@ -21,9 +21,7 @@
 #CHANNEL_LIBS+=chan_modem.so chan_modem_aopen.so chan_modem_bestdata.so
 endif
 
-ifeq ($(findstring BSD,${OSARCH}),BSD)
- CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
-endif
+CFLAGS+=-I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)/lib
 
 ifeq (${OSARCH},OpenBSD)
   PTLIB=-lpt_OpenBSD_x86_r
Index: channels/chan_h323.c
--- channels/chan_h323.c.orig	2006-08-30 20:59:44 +0200
+++ channels/chan_h323.c	2006-10-22 14:07:55 +0200
@@ -31,6 +31,7 @@
  * \ingroup channel_drivers
  */
 
+#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/signal.h>
 #include <sys/param.h>
Index: channels/chan_iax2.c
--- channels/chan_iax2.c.orig	2006-10-13 18:18:08 +0200
+++ channels/chan_iax2.c	2006-10-22 14:07:55 +0200
@@ -2607,7 +2607,7 @@
 	struct ast_variable *var;
 	struct ast_variable *tmp;
 	struct iax2_peer *peer=NULL;
-	time_t regseconds, nowtime;
+	time_t regseconds = 0, nowtime;
 	int dynamic=0;
 
 	if (peername)
@@ -2648,8 +2648,10 @@
 				break;
 			} 
 		} else if (!strcasecmp(tmp->name, "regseconds")) {
-			if (sscanf(tmp->value, "%ld", (time_t *)&regseconds) != 1)
-				regseconds = 0;
+			long s;
+			if (sscanf(tmp->value, "%ld", &s) != 1)
+				s = 0;
+			regseconds = s;
 		} else if (!strcasecmp(tmp->name, "ipaddr")) {
 			inet_aton(tmp->value, &(peer->addr.sin_addr));
 		} else if (!strcasecmp(tmp->name, "port")) {
Index: channels/chan_sip.c
--- channels/chan_sip.c.orig	2006-10-17 22:37:17 +0200
+++ channels/chan_sip.c	2006-10-22 14:07:55 +0200
@@ -12298,7 +12298,7 @@
 	int obproxyfound=0;
 	int found=0;
 	int format=0;		/* Ama flags */
-	time_t regseconds;
+	time_t regseconds = 0;
 	char *varname = NULL, *varval = NULL;
 	struct ast_variable *tmpvar = NULL;
 	struct ast_flags peerflags = {(0)};
@@ -12381,8 +12381,10 @@
 		}
 
 		if (realtime && !strcasecmp(v->name, "regseconds")) {
-			if (sscanf(v->value, "%ld", (time_t *)&regseconds) != 1)
-				regseconds = 0;
+			long s;
+			if (sscanf(v->value, "%ld", &s) != 1)
+				s = 0;
+			regseconds = (time_t)s;
 		} else if (realtime && !strcasecmp(v->name, "ipaddr") && !ast_strlen_zero(v->value) ) {
 			inet_aton(v->value, &(peer->addr.sin_addr));
 		} else if (realtime && !strcasecmp(v->name, "name"))
Index: channels/chan_skinny.c
--- channels/chan_skinny.c.orig	2006-10-17 19:50:36 +0200
+++ channels/chan_skinny.c	2006-10-22 14:07:55 +0200
@@ -99,7 +99,7 @@
 #define htolel(x) (x)
 #define htoles(x) (x)
 #else
-#if defined(SOLARIS) || defined(__Darwin__) || defined(__NetBSD__)
+#if defined(SOLARIS) || defined(__Darwin__) || defined(__NetBSD__) || defined(__FreeBSD__)
 #define __bswap_16(x) \
      ((((x) & 0xff00) >> 8) | \
       (((x) & 0x00ff) << 8))
Index: codecs/Makefile
--- codecs/Makefile.orig	2005-11-29 19:24:39 +0100
+++ codecs/Makefile	2006-10-22 14:07:55 +0200
@@ -28,45 +28,16 @@
   LIBG723B=g723.1b/libg723b.a
 endif
 
-UI_SPEEX=$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/speex.h)
-UIS_SPEEX=$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/speex/speex.h)
-ULI_SPEEX=$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/speex.h)
-ULIS_SPEEX=$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/speex/speex.h)
-ifneq (${UI_SPEEX},)
-  MODSPEEX=codec_speex.so
-  LIBSPEEX+=-lspeex -lm
-endif
-ifneq (${UIS_SPEEX},)
-  MODSPEEX=codec_speex.so
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/speex
-  LIBSPEEX+=-lspeex -lm
-endif
-ifneq (${ULI_SPEEX},)
-  MODSPEEX=codec_speex.so
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include
-  LIBSPEEX=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
-  LIBSPEEX+=-lspeex -lm
-endif
-ifneq (${ULIS_SPEEX},)
-  MODSPEEX=codec_speex.so
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/speex
-  LIBSPEEX=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
-  LIBSPEEX+=-lspeex -lm
-endif
-
-ifneq ($(wildcard ilbc/iLBC_decode.h),)
-  MODILBC=codec_ilbc.so
-  LIBILBC=ilbc/libilbc.a
-endif
+MODSPEEX=codec_speex.so
+CFLAGS+=-I$(INSTALL_PREFIX)/include/speex
+LIBSPEEX+=-L$(INSTALL_PREFIX)/lib -lspeex -lm
 
 
 LIBGSM=gsm/lib/libgsm.a
 LIBGSMT=gsm/lib/libgsm.a
 LIBLPC10=lpc10/liblpc10.a
 
-ifeq ($(findstring BSD,${OSARCH}),BSD)
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
-endif
+CFLAGS+=-I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)/lib
 
 CODECS+=$(MODG723) $(MODSPEEX) $(MODILBC) codec_gsm.so codec_lpc10.so  \
         codec_adpcm.so codec_ulaw.so codec_alaw.so codec_a_mu.so \
Index: codecs/gsm/src/short_term.c
--- codecs/gsm/src/short_term.c.orig	2005-11-29 19:24:39 +0100
+++ codecs/gsm/src/short_term.c	2006-10-22 14:07:55 +0200
@@ -373,7 +373,6 @@
 	word		* LARpp_j_1	= S->LARpp[ S->j ^= 1 ];
 
 	word		LARp[8];
-int i;
 #undef	FILTER
 #if 	defined(FAST) && defined(USE_FLOAT_MUL)
 # 	define	FILTER 	(* (S->fast			\
Index: codecs/lpc10/analys.c
--- codecs/lpc10/analys.c.orig	2005-11-29 19:24:39 +0100
+++ codecs/lpc10/analys.c	2006-10-22 14:07:55 +0200
@@ -32,7 +32,7 @@
 
 #include "f2c.h"
 
-#ifdef P_R_O_T_O_T_Y_P_E_S
+#if 1
 extern int analys_(real *speech, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_encoder_state *st);
 /* comlen contrl_ 12 */
 /*:ref: preemp_ 14 5 6 6 4 6 6 */
Index: dns.c
--- dns.c.orig	2005-11-29 19:24:39 +0100
+++ dns.c	2006-10-22 14:07:55 +0200
@@ -194,9 +194,7 @@
 	int res, ret = -1;
 
 #ifdef HAS_RES_NINIT
-#ifdef MAKE_VALGRIND_HAPPY
 	memset(&dnsstate, 0, sizeof(dnsstate));
-#endif	
 	res_ninit(&dnsstate);
 	res = res_nsearch(&dnsstate, dname, class, type, (unsigned char *)answer, sizeof(answer));
 #else
Index: formats/Makefile
--- formats/Makefile.orig	2005-11-29 19:24:39 +0100
+++ formats/Makefile	2006-10-22 14:07:55 +0200
@@ -29,9 +29,7 @@
   FORMAT_LIBS+=format_ogg_vorbis.so
 endif
 
-ifeq ($(findstring BSD,${OSARCH}),BSD)
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
-endif
+CFLAGS+=-I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)/lib
 
 GSMLIB=../codecs/gsm/lib/libgsm.a
 
Index: formats/msgsm.h
--- formats/msgsm.h.orig	2005-11-29 19:24:39 +0100
+++ formats/msgsm.h	2006-10-22 14:07:55 +0200
@@ -562,6 +562,7 @@
                         xmc[46] = sr & 0x7;  sr >>= 3;
                         xmc[47] = sr & 0x7;  sr >>= 3;
                         sr = *c++;
+                        /* FIXME: 48? */
                         xmc[49] = sr & 0x7;  sr >>= 3;
                         sr |= (uword)*c++ << 2;
                         xmc[50] = sr & 0x7;  sr >>= 3;
Index: frame.c
--- frame.c.orig	2006-09-28 20:00:30 +0200
+++ frame.c	2006-10-22 14:07:55 +0200
@@ -1055,7 +1055,7 @@
 {
 	switch(buf & TYPE_MASK) {
 	case TYPE_DONTSEND:
-		return 0;
+		return 2;
 		break;
 	case TYPE_SILENCE:
 		return 4;
Index: funcs/Makefile
--- funcs/Makefile.orig	2005-11-29 19:24:39 +0100
+++ funcs/Makefile	2006-10-22 14:07:55 +0200
@@ -40,9 +40,7 @@
 CFLAGS+=-fPIC
 endif
 
-ifeq ($(findstring BSD,${OSARCH}),BSD)
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
-endif
+CFLAGS+=-I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)/lib
 
 all: $(FUNCS)
 
Index: funcs/func_strings.c
--- funcs/func_strings.c.orig	2006-03-21 18:45:56 +0100
+++ funcs/func_strings.c	2006-10-22 14:07:55 +0200
@@ -169,7 +169,7 @@
 		epochi = tv.tv_sec;
 	}
 
-	ast_localtime(&epochi, &time, timezone);
+	{ time_t t = (time_t)epochi; ast_localtime(&t, &time, timezone); }
 
 	if (!format) {
 		format = "%c";
Index: pbx/Makefile
--- pbx/Makefile.orig	2005-11-29 19:24:39 +0100
+++ pbx/Makefile	2006-10-22 14:07:55 +0200
@@ -14,9 +14,7 @@
 PBX_LIBS=pbx_config.so pbx_spool.so pbx_dundi.so pbx_loopback.so pbx_realtime.so \
          pbx_ael.so
 
-ifeq ($(findstring BSD,${OSARCH}),BSD)
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
-endif
+CFLAGS+=-I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)/lib
 
 # Add GTK console if appropriate
 #PBX_LIBS+=$(shell $(CROSS_COMPILE_BIN)gtk-config --cflags >/dev/null 2>/dev/null && echo "pbx_gtkconsole.so")
Index: res/Makefile
--- res/Makefile.orig	2005-11-29 19:24:39 +0100
+++ res/Makefile	2006-10-22 14:07:55 +0200
@@ -36,10 +36,8 @@
   endif
 endif
 
-ifeq ($(findstring BSD,${OSARCH}),BSD)
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include
-  SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
-endif
+CFLAGS+=-I$(INSTALL_PREFIX)/include
+SOLINK+=-L$(INSTALL_PREFIX)/lib
 
 ifeq (${OSARCH},CYGWIN)
 CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
Index: res/res_features.c
--- res/res_features.c.orig	2006-09-28 20:00:30 +0200
+++ res/res_features.c	2006-10-22 14:07:55 +0200
@@ -505,13 +505,13 @@
 		if (touch_monitor) {
 			len = strlen(touch_monitor) + 50;
 			args = alloca(len);
-			snprintf(args, len, "%s|auto-%ld-%s|m", (touch_format) ? touch_format : "wav", time(NULL), touch_monitor);
+			snprintf(args, len, "%s|auto-%ld-%s|m", (touch_format) ? touch_format : "wav", (long)time(NULL), touch_monitor);
 		} else {
 			caller_chan_id = ast_strdupa(caller_chan->cid.cid_num ? caller_chan->cid.cid_num : caller_chan->name);
 			callee_chan_id = ast_strdupa(callee_chan->cid.cid_num ? callee_chan->cid.cid_num : callee_chan->name);
 			len = strlen(caller_chan_id) + strlen(callee_chan_id) + 50;
 			args = alloca(len);
-			snprintf(args, len, "%s|auto-%ld-%s-%s|m", (touch_format) ? touch_format : "wav", time(NULL), caller_chan_id, callee_chan_id);
+			snprintf(args, len, "%s|auto-%ld-%s-%s|m", (touch_format) ? touch_format : "wav", (long)time(NULL), caller_chan_id, callee_chan_id);
 		}
 
 		for( x = 0; x < strlen(args); x++)
Index: rtp.c
--- rtp.c.orig	2006-09-01 19:35:06 +0200
+++ rtp.c	2006-10-22 14:07:55 +0200
@@ -962,8 +962,10 @@
 		rtp->us.sin_port = htons(x);
 		rtp->us.sin_addr = addr;
 		/* If there's rtcp, initialize it as well. */
-		if (rtp->rtcp)
+		if (rtp->rtcp) {
 			rtp->rtcp->us.sin_port = htons(x + 1);
+			rtp->rtcp->us.sin_addr = addr;
+		}
 		/* Try to bind it/them. */
 		if (!(first = bind(rtp->s, (struct sockaddr *)&rtp->us, sizeof(rtp->us))) &&
 			(!rtp->rtcp || !bind(rtp->rtcp->s, (struct sockaddr *)&rtp->rtcp->us, sizeof(rtp->rtcp->us))))
Index: say.c
--- say.c.orig	2005-11-29 19:24:39 +0100
+++ say.c	2006-10-22 14:07:55 +0200
@@ -3133,7 +3133,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+                    { time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -3156,7 +3156,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -3332,7 +3332,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+                    { time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -3355,7 +3355,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+                    { time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -3524,7 +3524,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -3547,7 +3547,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -3727,7 +3727,7 @@
 					char todo = format[offset]; /* The letter to format*/
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -3883,7 +3883,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -3906,7 +3906,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -4101,7 +4101,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -4124,7 +4124,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -4303,7 +4303,7 @@
 					time_t beg_today;
 	
 			        gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -4326,7 +4326,7 @@
 					time_t beg_today;
 	
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -4528,7 +4528,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -4551,7 +4551,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -4740,7 +4740,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -4763,7 +4763,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -5010,7 +5010,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -5033,7 +5033,7 @@
 					time_t beg_today;
 
 					gettimeofday(&now,NULL);
-					ast_localtime(&now.tv_sec,&tmnow,timezone);
+					{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 					/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 					/* In any case, it saves not having to do ast_mktime() */
 					beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -6043,7 +6043,7 @@
 				time_t beg_today;
 				
 				gettimeofday(&now,NULL);
-				ast_localtime(&now.tv_sec,&tmnow,timezone);
+				{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 				/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 				/* In any case, it saves not having to do ast_mktime() */
 				beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -6066,7 +6066,7 @@
 				time_t beg_today;
 				
 				gettimeofday(&now,NULL);
-				ast_localtime(&now.tv_sec,&tmnow,timezone);
+				{ time_t t = (time_t)now.tv_sec; ast_localtime(&t,&tmnow,timezone); }
 				/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
 				/* In any case, it saves not having to do ast_mktime() */
 				beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
Index: utils.c
--- utils.c.orig	2006-10-12 20:31:26 +0200
+++ utils.c	2006-10-22 14:07:55 +0200
@@ -63,6 +63,8 @@
 /* duh? ERANGE value copied from web... */
 #define ERANGE 34
 #undef gethostbyname
+#undef gethostbyname_r
+#define gethostbyname_r __ast_gethostbyname_r
 
 AST_MUTEX_DEFINE_STATIC(__mutex);
 
Index: utils/Makefile
--- utils/Makefile.orig	2005-11-29 19:24:39 +0100
+++ utils/Makefile	2006-10-22 14:07:55 +0200
@@ -16,17 +16,15 @@
 #
 CFLAGS+=-DNO_AST_MM
 
-ifeq ($(findstring BSD,${OSARCH}),BSD)
-  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
-endif
+CFLAGS+=-I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)/lib
 
 TARGET=stereorize streamplayer
 
-ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/popt.h)$(wildcard -f $(CROSS_COMPILE_TARGET)/usr/local/include/popt.h),)
+ifneq ($(wildcard $(INSTALL_PREFIX)/include/popt.h)$(wildcard -f $(INSTALL_PREFIX)/include/popt.h),)
   TARGET+=smsq
 endif
 
-ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/newt.h)$(wildcard -f $(CROSS_COMPILE_TARGET)/usr/local/include/newt.h),)
+ifneq ($(wildcard $(INSTALL_PREFIX)/include/newt.h)$(wildcard -f $(INSTALL_PREFIX)/include/newt.h),)
   TARGET+=astman
 endif
 
