Index: Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/Makefile,v
retrieving revision 1.34
diff -u -r1.34 Makefile
--- Makefile	13 Oct 2003 18:31:52 -0000	1.34
+++ Makefile	14 Oct 2003 22:47:04 -0000
@@ -98,6 +98,9 @@
 CFLAGS+=$(OPTIMIZE)
 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)
+ifeq (${OSARCH},FreeBSD)
+CFLAGS+=-pthread
+endif
 ifeq (${OSARCH},OpenBSD)
 CFLAGS+=-pthread
 endif
@@ -131,7 +134,18 @@
 ifeq (${OSARCH},Linux)
 LIBS=-ldl
 endif
-LIBS+=-lpthread -lncurses -lm -lresolv  #-lnjamd
+ifeq (${OSARCH},OpenBSD)
+LIBS=-pthread
+else
+ifeq (${OSARCH},FreeBSD)
+LIBS=-pthread
+else
+endif
+endif
+LIBS+=-lncurses -lm
+ifeq (${OSARCH},Linux)
+-lresolv  #-lnjamd
+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 \
Index: apps/app_intercom.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_intercom.c,v
retrieving revision 1.3
diff -u -r1.3 app_intercom.c
--- apps/app_intercom.c	13 Aug 2003 15:25:16 -0000	1.3
+++ apps/app_intercom.c	14 Oct 2003 22:47:04 -0000
@@ -28,6 +28,8 @@
 #include <sys/time.h>
 #ifdef __linux__
 #include <linux/soundcard.h>
+#elif defined(__FreeBSD__)
+#include <machine/soundcard.h>
 #else
 #include <soundcard.h>
 #endif
Index: channels/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/Makefile,v
retrieving revision 1.10
diff -u -r1.10 Makefile
--- channels/Makefile	11 Sep 2003 19:45:43 -0000	1.10
+++ channels/Makefile	14 Oct 2003 22:47:04 -0000
@@ -91,12 +91,13 @@
 
 chan_oss.o: chan_oss.c  busy.h ringtone.h
 
+ifeq (${OSARCH},OpenBSD)
+chan_oss.so: chan_oss.o
+	$(CC) -shared -Xlinker -x -o $@ chan_oss.o -lossaudio
+endif
+
 chan_iax2.so: chan_iax2.o iax2-parser.o
-ifeq (${OSARCH},Linux)
 	$(CC) -shared -Xlinker -x -o $@ chan_iax2.o iax2-parser.o
-else
-	$(CC) -shared -Xlinker -x -o $@ chan_iax2.o iax2-parser.o -lossaudio
-endif
 
 chan_zap.o: $(CHANZAP)
 	$(CC) -c $(CFLAGS) -o chan_zap.o $(CHANZAP)
Index: channels/chan_iax.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax.c,v
retrieving revision 1.12
diff -u -r1.12 chan_iax.c
--- channels/chan_iax.c	16 Aug 2003 05:10:35 -0000	1.12
+++ channels/chan_iax.c	14 Oct 2003 22:47:06 -0000
@@ -532,7 +532,7 @@
 	(rx ? "Rx" : "Tx"),
 	retries, ntohs(fh->seqno), class, subclass);
 		fprintf(stderr,
-"   Timestamp: %05dms  Callno: %5.5d  DCall: %5.5d [%s:%d]\n",
+"   Timestamp: %05ldms  Callno: %5.5d  DCall: %5.5d [%s:%d]\n",
 	ntohl(fh->ts),
 	(short)(ntohs(fh->callno) & ~AST_FLAG_FULL), (short) ntohs(fh->dcallno),
 		inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
Index: channels/chan_oss.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_oss.c,v
retrieving revision 1.6
diff -u -r1.6 chan_oss.c
--- channels/chan_oss.c	13 Aug 2003 15:25:16 -0000	1.6
+++ channels/chan_oss.c	14 Oct 2003 22:47:07 -0000
@@ -35,6 +35,8 @@
 #include <stdio.h>
 #ifdef __linux
 #include <linux/soundcard.h>
+#elif defined(__FreeBSD__)
+#include <machine/soundcard.h>
 #else
 #include <soundcard.h>
 #endif
Index: channels/chan_skinny.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_skinny.c,v
retrieving revision 1.18
diff -u -r1.18 chan_skinny.c
--- channels/chan_skinny.c	30 Sep 2003 10:58:34 -0000	1.18
+++ channels/chan_skinny.c	14 Oct 2003 22:47:08 -0000
@@ -863,6 +863,7 @@
 	transmit_response(s, req);
 }
 
+#if 0
 static void transmit_selectsoftkeys(struct skinnysession *s, int instance, int callid, int softkey)
 {
 	skinny_req *req;
@@ -881,6 +882,7 @@
 	req->data.selectsoftkey.softKeySetIndex = softkey;
 	transmit_response(s, req);
 }
+#endif
 
 static void transmit_lamp_indication(struct skinnysession *s, int instance, int indication)
 {
@@ -2318,7 +2320,7 @@
 
 	for (;;) {
 		sinlen = sizeof(sin);
-		as = accept(skinnysock, &sin, &sinlen);
+		as = accept(skinnysock, (struct sockaddr *)&sin, &sinlen);
 		if (as < 0) {
 			ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno));
 			continue;
@@ -2393,7 +2395,7 @@
 {
 
 	/* If we're supposed to be stopped -- stay stopped */
-	if (monitor_thread == -2)
+	if (monitor_thread == (pthread_t)-2)
 		return 0;
 	if (ast_mutex_lock(&monlock)) {
 		ast_log(LOG_WARNING, "Unable to lock monitor\n");
Index: channels/iax2-parser.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/iax2-parser.c,v
retrieving revision 1.9
diff -u -r1.9 iax2-parser.c
--- channels/iax2-parser.c	1 Oct 2003 22:59:06 -0000	1.9
+++ channels/iax2-parser.c	14 Oct 2003 22:47:08 -0000
@@ -64,7 +64,7 @@
 static void dump_int(char *output, int maxlen, void *value, int len)
 {
 	if (len == sizeof(unsigned int))
-		snprintf(output, maxlen, "%d", ntohl(*((unsigned int *)value)));
+		snprintf(output, maxlen, "%ld", ntohl(*((unsigned int *)value)));
 	else
 		snprintf(output, maxlen, "Invalid INT");
 }
@@ -287,7 +287,7 @@
 	retries, fh->oseqno, fh->iseqno, class, subclass);
 	outputf(tmp);
 snprintf(tmp, sizeof(tmp), 
-"   Timestamp: %05dms  SCall: %5.5d  DCall: %5.5d [%s:%d]\n",
+"   Timestamp: %05ldms  SCall: %5.5d  DCall: %5.5d [%s:%d]\n",
 	ntohl(fh->ts),
 	ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS,
 		inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
Index: codecs/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- codecs/Makefile	6 May 2003 00:00:20 -0000	1.5
+++ codecs/Makefile	14 Oct 2003 22:47:08 -0000
@@ -22,6 +22,7 @@
 MODSPEEX=$(shell [ -f /usr/include/speex.h ] || [ -f /usr/local/include/speex.h ] && echo "codec_speex.so")
 MODILBC=$(shell [ -f ilbc/iLBC_decode.h ] && echo "codec_ilbc.so")
 CFLAGS+=-fPIC
+CFLAGS+=$(shell [ -f /usr/local/include/speex.h ] && echo "-I/usr/local/include")
 
 LIBG723=g723.1/libg723.a
 LIBG723B=g723.1b/libg723b.a
@@ -30,7 +31,8 @@
 LIBGSMT=$(shell if uname -m | grep -q 86; then echo gsm/lib/libgsm.a; fi)
 LIBMP3=mp3/libmp3.a
 LIBLPC10=lpc10/liblpc10.a
-LIBSPEEX=-lspeex -lm
+LIBSPEEX=$(shell [ -f /usr/local/lib/libspeex.a ] && echo "-L/usr/local/lib")
+LIBSPEEX+=-lspeex -lm
 LIBILBC=ilbc/libilbc.a
 
 CODECS+=$(MODG723) $(MODSPEEX) $(MODILBC) codec_gsm.so codec_mp3_d.so codec_lpc10.so  \
Index: codecs/lpc10/lpcini.c
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/lpc10/lpcini.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 lpcini.c
--- codecs/lpc10/lpcini.c	12 Feb 2003 13:59:15 -0000	1.1.1.1
+++ codecs/lpc10/lpcini.c	14 Oct 2003 22:47:08 -0000
@@ -31,7 +31,7 @@
 
 #include "f2c.h"
 
-#include <malloc.h>
+#include <stdlib.h>
 
 /* Common Block Declarations */
 
Index: codecs/mp3/include/L3.h
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/mp3/include/L3.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 L3.h
--- codecs/mp3/include/L3.h	12 Feb 2003 13:59:14 -0000	1.1.1.1
+++ codecs/mp3/include/L3.h	14 Oct 2003 22:47:08 -0000
@@ -37,6 +37,13 @@
 /* #define GLOBAL_GAIN_SCALE 0 */
 
 
+#ifdef __FreeBSD__
+#ifdef __i386__
+#undef LITTLE_ENDIAN
+#define LITTLE_ENDIAN 1
+#endif
+#endif
+
 #ifdef _M_IX86
 #define LITTLE_ENDIAN 1
 #endif
