diff -ruN asterisk-1.0.7-orig/Makefile asterisk-1.0.7-2/Makefile
--- asterisk-1.0.7-orig/Makefile	2005-03-10 09:15:05.000000000 +0100
+++ asterisk-1.0.7-2/Makefile	2005-03-19 17:38:06.000000000 +0100
@@ -63,10 +63,10 @@
 #K6OPT  = -DK6OPT
 
 #Tell gcc to optimize the asterisk's code
-OPTIMIZE+=-O6
+#OPTIMIZE+=-O6
 
 #Include debug symbols in the executables (-g) and profiling info (-pg)
-DEBUG=-g #-pg
+#DEBUG=-g #-pg
 
 # If you are running a radio application, define RADIO_RELAX so that the DTMF
 # will be received more reliably
@@ -74,7 +74,7 @@
 
 # If you don't have a lot of memory (e.g. embedded Asterisk), uncomment the
 # following to reduce the size of certain static buffers
-#OPTIONS += -DLOW_MEMORY
+OPTIONS += -DLOW_MEMORY
 
 # Optional debugging parameters
 DEBUG_THREADS = #-DDEBUG_THREADS #-DDO_CRASH 
@@ -112,7 +112,7 @@
 BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
 
 ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
-ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
+ASTVARLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
 ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
 ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
 ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
@@ -128,7 +128,7 @@
 
 INCLUDE=-Iinclude -I../include
 CFLAGS=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
-CFLAGS+=$(OPTIMIZE)
+CFLAGS+=$(OPTIMIZE) $(CFLAGS_EXTRA)
 
 ifneq ($(PROC),ultrasparc)
 CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
@@ -187,7 +187,7 @@
 CFLAGS+=# -fomit-frame-pointer 
 SUBDIRS=res channels pbx apps codecs formats agi cdr astman stdtime
 ifeq (${OSARCH},Linux)
-LIBS=-ldl -lpthread
+LIBS=$(LDFLAGS_EXTRA) -ldl -lpthread
 endif
 LIBS+=-lncurses -lm
 ifeq (${OSARCH},Linux)
@@ -205,7 +205,7 @@
 ifeq (${OSARCH},OpenBSD)
 LIBS=-lcrypto -lpthread -lm -lncurses
 endif
-LIBS+=-lssl
+LIBS+=-Wl,-Bstatic -lssl -Wl,-Bdynamic
 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 \
@@ -240,12 +240,12 @@
 	cd editline && unset CFLAGS LIBS && ./configure ; \
 
 editline/libedit.a: FORCE
-	cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
-	$(MAKE) -C editline libedit.a
+	cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE) $(CFLAGS_EXTRA)" LDFLAGS="$(LDFLAGS_EXTRA)" ./configure
+	$(MAKE) PROC=$(PROC) CFLAGS="$(OPTIMIZE)" -C editline libedit.a
 
 db1-ast/libdb1.a: FORCE
 	@if [ -d db1-ast ]; then \
-		$(MAKE) -C db1-ast libdb1.a ; \
+		$(MAKE) PROC=$(PROC) OORG="$(OPTIMIZE)" -C db1-ast libdb1.a ; \
 	else \
 		echo "You need to do a cvs update -d not just cvs update"; \
 		exit 1; \
@@ -289,7 +289,7 @@
 
 stdtime/libtime.a: FORCE
 	@if [ -d stdtime ]; then \
-		$(MAKE) -C stdtime libtime.a ; \
+		$(MAKE) PROC=$(PROC) -C stdtime libtime.a ; \
 	else \
 		echo "You need to do a cvs update -d not just cvs update"; \
 		exit 1; \
@@ -381,7 +381,7 @@
 	if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
 		install -m 755 contrib/scripts/safe_asterisk $(DESTDIR)$(ASTSBINDIR)/ ;\
 	fi
-	for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
+	for x in $(SUBDIRS); do $(MAKE) PROC=$(PROC) -C $$x install || exit 1 ; done
 	install -d $(DESTDIR)$(ASTHEADERDIR)
 	install -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
 	rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/vm
@@ -519,8 +519,8 @@
 __rpm: _version
 	rm -rf /tmp/asterisk ; \
 	mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
-	$(MAKE) DESTDIR=/tmp/asterisk install ; \
-	$(MAKE) DESTDIR=/tmp/asterisk samples ; \
+	$(MAKE) PROC=$(PROC) DESTDIR=/tmp/asterisk install ; \
+	$(MAKE) PROC=$(PROC) DESTDIR=/tmp/asterisk samples ; \
 	mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
 	cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
 	sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
@@ -544,12 +544,12 @@
 	fi 
 
 dont-optimize:
-	$(MAKE) OPTIMIZE= K6OPT= install
+	$(MAKE) PROC=$(PROC) OPTIMIZE= K6OPT= install
 
 valgrind: dont-optimize
 
 depend: .depend
-	for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
+	for x in $(SUBDIRS); do $(MAKE) PROC=$(PROC) -C $$x depend || exit 1 ; done
 
 .depend:
 	@if ! which mpg123 &>/dev/null ; then \
diff -ruN asterisk-1.0.7-orig/apps/Makefile asterisk-1.0.7-2/apps/Makefile
--- asterisk-1.0.7-orig/apps/Makefile	2004-09-24 23:32:56.000000000 +0200
+++ asterisk-1.0.7-2/apps/Makefile	2005-03-19 17:38:06.000000000 +0100
@@ -35,13 +35,14 @@
 APPS+=app_intercom.so
 endif
 
-#APPS+=app_sql_postgres.so
+# add extra apps
+APPS+=$(EXTRA_APPS)
 #APPS+=app_sql_odbc.so
 #APPS+=app_rpt.so
 
-APPS+=$(shell if [ -f /usr/include/linux/zaptel.h ]; then echo "app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so" ; fi)
-APPS+=$(shell if [ -f /usr/local/include/zaptel.h ]; then echo "app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so" ; fi)
-APPS+=$(shell if [ -f /usr/include/osp/osp.h ]; then echo "app_osplookup.so" ; fi)
+#APPS+=$(shell if [ -f /usr/include/linux/zaptel.h ]; then echo "app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so" ; fi)
+#APPS+=$(shell if [ -f /usr/local/include/zaptel.h ]; then echo "app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so" ; fi)
+#APPS+=$(shell if [ -f /usr/include/osp/osp.h ]; then echo "app_osplookup.so" ; fi)
 
 CFLAGS+=-fPIC
 
diff -ruN asterisk-1.0.7-orig/cdr/Makefile asterisk-1.0.7-2/cdr/Makefile
--- asterisk-1.0.7-orig/cdr/Makefile	2004-08-31 18:33:00.000000000 +0200
+++ asterisk-1.0.7-2/cdr/Makefile	2005-03-19 17:38:06.000000000 +0100
@@ -12,7 +12,7 @@
 #
 
 #ADD cdr_pgsql.so to MODS= to include PostgreSQL support: REQUIRES PostgreSQL libs
-MODS=cdr_csv.so cdr_manager.so
+MODS=cdr_csv.so cdr_manager.so $(EXTRA_MODS)
 
 
 CFLAGS+=-fPIC
diff -ruN asterisk-1.0.7-orig/channels/Makefile asterisk-1.0.7-2/channels/Makefile
--- asterisk-1.0.7-orig/channels/Makefile	2004-08-31 18:33:00.000000000 +0200
+++ asterisk-1.0.7-2/channels/Makefile	2005-03-19 17:38:06.000000000 +0100
@@ -71,25 +71,25 @@
 CHANNEL_LIBS+=chan_oss.so
 endif
 
-CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/ixjuser.h ] && echo chan_phone.so)
-CHANNEL_LIBS+=$(shell [ -f /usr/local/include/ixjuser.h ] && echo chan_phone.so)
-CHANNEL_LIBS+=$(shell [ -f h323/libchanh323.a ] && echo chan_h323.so)
-
-CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
-CFLAGS+=$(shell [ ! -f /usr/include/linux/if_wanpipe.h ] && echo " -DOLD_SANGOMA_API")
-CHANNEL_LIBS+=$(shell [ -f /usr/include/alsa/asoundlib.h ] && echo "chan_alsa.so")
-CFLAGS+=$(shell [ -f /usr/lib/libpri.so.1 ] && echo " -DZAPATA_PRI")
-CFLAGS+=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo " -DZAPATA_R2")
-CFLAGS+=$(shell [ -f alsa-monitor.h ] && echo " -DALSA_MONITOR")
-ZAPPRI=$(shell [ -f /usr/lib/libpri.so.1 ] && echo "-lpri")
-ZAPR2=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo "-lmfcr2")
-CFLAGS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "-DIAX_TRUNKING")
-CFLAGS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "-DIAX_TRUNKING")
-CHANNEL_LIBS+=$(shell [ -f /usr/include/vpbapi.h ] && echo "chan_vpb.so" )
-CFLAGS+=$(shell [ -f /usr/include/vpbapi.h ] && echo " -DLINUX")
+#CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/ixjuser.h ] && echo chan_phone.so)
+#CHANNEL_LIBS+=$(shell [ -f /usr/local/include/ixjuser.h ] && echo chan_phone.so)
+#CHANNEL_LIBS+=$(shell [ -f h323/libchanh323.a ] && echo chan_h323.so)
+
+#CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
+#CFLAGS+=$(shell [ ! -f /usr/include/linux/if_wanpipe.h ] && echo " -DOLD_SANGOMA_API")
+#CHANNEL_LIBS+=$(shell [ -f /usr/include/alsa/asoundlib.h ] && echo "chan_alsa.so")
+#CFLAGS+=$(shell [ -f /usr/lib/libpri.so.1 ] && echo " -DZAPATA_PRI")
+#CFLAGS+=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo " -DZAPATA_R2")
+#CFLAGS+=$(shell [ -f alsa-monitor.h ] && echo " -DALSA_MONITOR")
+#ZAPPRI=$(shell [ -f /usr/lib/libpri.so.1 ] && echo "-lpri")
+#ZAPR2=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo "-lmfcr2")
+#CFLAGS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "-DIAX_TRUNKING")
+#CFLAGS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "-DIAX_TRUNKING")
+#CHANNEL_LIBS+=$(shell [ -f /usr/include/vpbapi.h ] && echo "chan_vpb.so" )
+#CFLAGS+=$(shell [ -f /usr/include/vpbapi.h ] && echo " -DLINUX")
 
-ALSA_SRC=chan_alsa.c
-ALSA_SRC+=$(shell [ -f alsa-monitor.h ] && echo "alsa-monitor.h")
+#ALSA_SRC=chan_alsa.c
+#ALSA_SRC+=$(shell [ -f alsa-monitor.h ] && echo "alsa-monitor.h")
 
 CFLAGS+=-DCRYPTO
 CFLAGS+=-fPIC
@@ -106,10 +106,10 @@
 
 ZAPDIR=/usr/lib
 
-CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "chan_zap.so")
-CHANNEL_LIBS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "chan_zap.so")
+#CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "chan_zap.so")
+#CHANNEL_LIBS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "chan_zap.so")
 
-CHANNEL_LIBS+=$(shell [ -f /usr/include/nbs.h ] && echo "chan_nbs.so" )
+#CHANNEL_LIBS+=$(shell [ -f /usr/include/nbs.h ] && echo "chan_nbs.so" )
 
 ifndef OPENH323DIR
 OPENH323DIR=$(HOME)/openh323
diff -ruN asterisk-1.0.7-orig/channels/h323/Makefile asterisk-1.0.7-2/channels/h323/Makefile
--- asterisk-1.0.7-orig/channels/h323/Makefile	2004-11-15 03:35:35.000000000 +0100
+++ asterisk-1.0.7-2/channels/h323/Makefile	2005-03-19 17:38:06.000000000 +0100
@@ -22,9 +22,11 @@
 OSARCH=$(shell uname -s)
 ifneq (${OSARCH},FreeBSD)
 ifneq (${OSARCH},NetBSD)
+ifneq ($(PROC),mipsel)
 CFLAGS += -march=$(shell uname -m)
 endif
 endif
+endif
 CFLAGS += -DPBYTE_ORDER=PLITTLE_ENDIAN
 
 ifeq (${OSARCH},Linux)
@@ -47,7 +49,7 @@
 
 # Pre Janus release directives
 CFLAGS += -DNDEBUG -DDO_CRASH -DDEBUG_THREADS
-CFLAGS += -pipe -Wall -fPIC
+CFLAGS += -pipe -Wall -fPIC $(OPTIMIZE)
 ifeq (${OSARCH},Linux)
 CFLAGS += -DP_LINUX
 LIBS+=-lpthread
@@ -74,7 +76,7 @@
  
 
 libchanh323.a:	ast_h323.o
-	ar cr libchanh323.a ast_h323.o
+	$(AR) cr libchanh323.a ast_h323.o
 
 ast_h323.o:	ast_h323.cpp
 	$(CXX) -g -c -fno-rtti -o $@ $(CFLAGS) $<
diff -ruN asterisk-1.0.7-orig/codecs/Makefile asterisk-1.0.7-2/codecs/Makefile
--- asterisk-1.0.7-orig/codecs/Makefile	2005-03-17 15:43:51.000000000 +0100
+++ asterisk-1.0.7-2/codecs/Makefile	2005-03-22 23:26:20.000000000 +0100
@@ -17,21 +17,21 @@
 # g723.1b)
 #
 #MODG723=codec_g723_1.so codec_g723_1b.so
-MODG723=$(shell [ -f g723.1/coder.c ] && echo "codec_g723_1.so")
-MODG723+=$(shell [ -f g723.1b/coder2.c ] && echo "codec_g723_1b.so")
-MODSPEEX=$(shell [ -f /usr/include/speex.h ] || [ -f /usr/include/speex/speex.h ] || [ -f /usr/local/include/speex.h ] || [ -f /usr/local/include/speex/speex.h ] && echo "codec_speex.so")
+#MODG723=$(shell [ -f g723.1/coder.c ] && echo "codec_g723_1.so")
+#MODG723+=$(shell [ -f g723.1b/coder2.c ] && echo "codec_g723_1b.so")
+MODSPEEX=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")
-CFLAGS+=$(shell [ -f /usr/local/include/speex/speex.h ] && echo "-I/usr/local/include/speex")
-CFLAGS+=$(shell [ -f /usr/include/speex/speex.h ] && echo "-I/usr/include/speex")
+#CFLAGS+=$(shell [ -f /usr/local/include/speex.h ] && echo "-I/usr/local/include")
+#CFLAGS+=$(shell [ -f /usr/local/include/speex/speex.h ] && echo "-I/usr/local/include/speex")
+#CFLAGS+=$(shell [ -f /usr/include/speex/speex.h ] && echo "-I/usr/include/speex")
 
 LIBG723=g723.1/libg723.a
 LIBG723B=g723.1b/libg723b.a
 LIBGSM=gsm/lib/libgsm.a
 LIBGSMT=gsm/lib/libgsm.a
 LIBLPC10=lpc10/liblpc10.a
-LIBSPEEX=$(shell [ -f /usr/local/lib/libspeex.a ] && echo "-L/usr/local/lib")
+LIBSPEEX=$(LDFLAGS_EXTRA)
 LIBSPEEX+=-lspeex -lm
 LIBILBC=ilbc/libilbc.a
 
@@ -43,26 +43,26 @@
 
 clean:
 	rm -f *.so *.o .depend
-	! [ -d g723.1 ] || $(MAKE) -C g723.1 clean
-	! [ -d g723.1b ] || $(MAKE) -C g723.1b clean
-	$(MAKE) -C gsm clean
-	$(MAKE) -C lpc10 clean
-	$(MAKE) -C ilbc clean
+	! [ -d g723.1 ] || $(MAKE) PROC=$(PROC) -C g723.1 clean
+	! [ -d g723.1b ] || $(MAKE) PROC=$(PROC) -C g723.1b clean
+	$(MAKE) PROC=$(PROC) -C gsm clean
+	$(MAKE) PROC=$(PROC) -C lpc10 clean
+	$(MAKE) PROC=$(PROC) -C ilbc clean
 
 $(LIBG723):
-	$(MAKE) -C g723.1 all
+	$(MAKE) PROC=$(PROC) -C g723.1 all
 
 gsm/lib/libgsm.a:
-	$(MAKE) -C gsm lib/libgsm.a
+	$(MAKE) PROC=$(PROC) -C gsm lib/libgsm.a
 
 $(LIBG723B):
-	$(MAKE) -C g723.1b all
+	$(MAKE) PROC=$(PROC) -C g723.1b all
 
 $(LIBLPC10):
-	$(MAKE) -C lpc10 all
+	$(MAKE) PROC=$(PROC) -C lpc10 all
 
 $(LIBILBC):
-	$(MAKE) -C ilbc all
+	$(MAKE) PROC=$(PROC) -C ilbc all
 
 codec_ilbc.so: codec_ilbc.o $(LIBILBC)
 	$(CC) $(SOLINK) -o $@ $< $(LIBILBC)
diff -ruN asterisk-1.0.7-orig/codecs/gsm/Makefile asterisk-1.0.7-2/codecs/gsm/Makefile
--- asterisk-1.0.7-orig/codecs/gsm/Makefile	2004-12-21 21:49:24.000000000 +0100
+++ asterisk-1.0.7-2/codecs/gsm/Makefile	2005-03-19 17:38:06.000000000 +0100
@@ -40,9 +40,10 @@
 ifneq (${OSARCH},Darwin)
 ifneq (${PROC},x86_64)
 ifneq (${PROC},ultrasparc)
-ifneq ($(shell uname -m),ppc)
-ifneq ($(shell uname -m),alpha)
+ifneq ($(PROC),ppc)
+ifneq ($(PROC),alpha)
 ifneq (${PROC},sparc64)
+ifneq ($(PROC),mipsel)
 OPTIMIZE+=-march=$(PROC)
 endif
 endif
@@ -50,6 +51,7 @@
 endif
 endif
 endif
+endif
 
 #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.
@@ -78,7 +80,7 @@
 # CCFLAGS 	= -c -O
 
 CC		?= gcc
-CCFLAGS 	+= -c -DNeedFunctionPrototypes=1 -funroll-loops -fPIC $(OPTIMIZE) -fomit-frame-pointer
+CCFLAGS 	+= -c -DNeedFunctionPrototypes=1 -fPIC $(OPTIMIZE)
 
 LD 		= $(CC)
 
@@ -213,16 +215,18 @@
 		$(SRC)/short_term.c	\
 		$(SRC)/table.c
 ifeq (${OSARCH},Linux)
-ifneq ($(shell uname -m),x86_64)
-ifneq ($(shell uname -m),ppc)
-ifneq ($(shell uname -m),alpha)
-ifneq ($(shell uname -m),sparc64)
+ifneq ($(PROC),x86_64)
+ifneq ($(PROC),ppc)
+ifneq ($(PROC),alpha)
+ifneq ($(PROC),sparc64)
+ifneq ($(PROC),mipsel)
 GSM_SOURCES+= $(SRC)/k6opt.s
 endif
 endif
 endif
 endif
 endif
+endif
 
 TOAST_SOURCES = $(SRC)/toast.c 		\
 		$(SRC)/toast_lin.c	\
@@ -269,16 +273,18 @@
 		$(SRC)/table.o
 
 ifeq (${OSARCH},Linux)
-ifneq ($(shell uname -m), x86_64)
-ifneq ($(shell uname -m), ppc)
-ifneq ($(shell uname -m), alpha)
-ifneq ($(shell uname -m), sparc64)
+ifneq ($(PROC), x86_64)
+ifneq ($(PROC), ppc)
+ifneq ($(PROC), alpha)
+ifneq ($(PROC), sparc64)
+ifneq ($(PROC), mipsel)
 GSM_OBJECTS+= $(SRC)/k6opt.o
 endif
 endif
 endif
 endif
 endif
+endif
 
 TOAST_OBJECTS =	$(SRC)/toast.o 		\
 		$(SRC)/toast_lin.o	\
diff -ruN asterisk-1.0.7-orig/codecs/ilbc/Makefile asterisk-1.0.7-2/codecs/ilbc/Makefile
--- asterisk-1.0.7-orig/codecs/ilbc/Makefile	2004-08-29 19:40:58.000000000 +0200
+++ asterisk-1.0.7-2/codecs/ilbc/Makefile	2005-03-19 17:38:06.000000000 +0100
@@ -1,5 +1,5 @@
 ARCH=$(PROC)
-CFLAGS+=-Wall -fPIC -O3 -funroll-loops -fomit-frame-pointer
+CFLAGS+=-Wall -fPIC $(OPTIMIZE)
 LIB=libilbc.a
 
 OBJS= anaFilter.o iCBSearch.o packing.o \
@@ -12,8 +12,8 @@
 
 
 $(LIB): $(OBJS)
-	ar cr $(LIB) $(OBJS)
-	ranlib $(LIB)
+	$(AR) cr $(LIB) $(OBJS)
+	$(RANLIB) $(LIB)
 
 clean:
 	rm -f $(LIB) *.o
diff -ruN asterisk-1.0.7-orig/codecs/lpc10/Makefile asterisk-1.0.7-2/codecs/lpc10/Makefile
--- asterisk-1.0.7-orig/codecs/lpc10/Makefile	2004-08-31 18:33:00.000000000 +0200
+++ asterisk-1.0.7-2/codecs/lpc10/Makefile	2005-03-19 17:38:06.000000000 +0100
@@ -31,6 +31,7 @@
 ifneq ($(PROC),ppc)
 ifneq ($(PROC),x86_64)
 ifneq ($(PROC),alpha)
+ifneq ($(PROC),mipsel)
 #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.
 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn.t support it.
@@ -46,6 +47,7 @@
 endif
 endif
 endif
+endif
 
 LIB = $(LIB_TARGET_DIR)/liblpc10.a
 
@@ -62,7 +64,7 @@
 
 $(LIB): $(OBJ)
 	$(AR) cr $@ $(OBJ)
-	ranlib $@
+	$(RANLIB) $@
 
 clean:
 	-rm -f *.o $(LIB)
diff -ruN asterisk-1.0.7-orig/configs/modules.conf.sample asterisk-1.0.7-2/configs/modules.conf.sample
--- asterisk-1.0.7-orig/configs/modules.conf.sample	2003-06-26 20:57:54.000000000 +0200
+++ asterisk-1.0.7-2/configs/modules.conf.sample	2005-03-19 17:38:06.000000000 +0100
@@ -23,8 +23,8 @@
 ; Explicitly load the chan_modem.so early on to be sure
 ; it loads before any of the chan_modem_* 's afte rit
 ;
-load => chan_modem.so
-load => res_musiconhold.so
+noload => chan_modem.so
+noload => res_musiconhold.so
 ;
 ; Load either OSS or ALSA, not both
 ; By default, load OSS only (automatically) and do not load ALSA
@@ -36,4 +36,12 @@
 ; exported to modules loaded after them.
 ;
 [global]
-chan_modem.so=yes
+; chan_modem.so=yes
+noload => app_adsiprog.so
+noload => app_db.so
+noload => app_hasnewvoicemail.so
+noload => app_voicemail.so
+noload => chan_skinny.so
+noload => cdr_csv.so
+noload => res_adsi.so
+noload => res_agi.so
diff -ruN asterisk-1.0.7-orig/db1-ast/Makefile asterisk-1.0.7-2/db1-ast/Makefile
--- asterisk-1.0.7-orig/db1-ast/Makefile	2004-08-31 18:33:00.000000000 +0200
+++ asterisk-1.0.7-2/db1-ast/Makefile	2005-03-19 17:38:06.000000000 +0100
@@ -32,8 +32,8 @@
 
 $(LIBDB): $(OBJS)
 	rm -f $@
-	ar cq $@ $(OBJS)
-	ranlib $@
+	$(AR) cq $@ $(OBJS)
+	$(RANLIB) $@
 
 $(LIBDBSO): $(SHOBJS)
 	$(CC) -Wl,-O1 -Wl,--version-script=libdb.map -Wl,-soname=$(LIBDBSO) -shared -o $@ $^
diff -ruN asterisk-1.0.7-orig/dns.c asterisk-1.0.7-2/dns.c
--- asterisk-1.0.7-orig/dns.c	2004-06-22 22:11:15.000000000 +0200
+++ asterisk-1.0.7-2/dns.c	2005-03-19 17:38:06.000000000 +0100
@@ -153,7 +153,13 @@
 
 #if defined(res_ninit)
 #define HAS_RES_NINIT
-#else
+#endif
+
+#ifdef __UCLIBC__
+#undef HAS_RES_NINIT
+#endif
+
+#ifndef HAS_RES_NINIT
 AST_MUTEX_DEFINE_STATIC(res_lock);
 #if 0
 #warning "Warning, res_ninit is missing...  Could have reentrancy issues"
diff -ruN asterisk-1.0.7-orig/res/Makefile asterisk-1.0.7-2/res/Makefile
--- asterisk-1.0.7-orig/res/Makefile	2004-07-17 22:58:01.000000000 +0200
+++ asterisk-1.0.7-2/res/Makefile	2005-03-19 17:58:17.000000000 +0100
@@ -13,9 +13,9 @@
 
 MODS=res_adsi.so res_features.so res_crypto.so res_musiconhold.so res_indications.so res_monitor.so \
      res_agi.so
-MODS+=$(shell if [ -f "/usr/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
-MODS+=$(shell if [ -f "/usr/local/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
-MODS+=$(shell if [ -f "/usr/include/osp/osp.h" ]; then echo "res_osp.so"; fi)
+#MODS+=$(shell if [ -f "/usr/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
+#MODS+=$(shell if [ -f "/usr/local/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
+#MODS+=$(shell if [ -f "/usr/include/osp/osp.h" ]; then echo "res_osp.so"; fi)
 
 CRYPTO_LIBS=-lssl -lcrypto
 
diff -ruN asterisk-1.0.7-orig/stdtime/Makefile asterisk-1.0.7-2/stdtime/Makefile
--- asterisk-1.0.7-orig/stdtime/Makefile	2003-11-05 07:19:41.000000000 +0100
+++ asterisk-1.0.7-2/stdtime/Makefile	2005-03-19 17:38:06.000000000 +0100
@@ -3,8 +3,8 @@
 all: libtime.a
 
 libtime.a: $(OBJS)
-	ar rv $@ $(OBJS)
-	ranlib $@
+	$(AR) rv $@ $(OBJS)
+	$(RANLIB) $@
 
 install:
 
diff -urN asterisk-1.0.7.old/codecs/Makefile asterisk-1.0.7/codecs/Makefile
--- asterisk-1.0.7.old/codecs/Makefile	2005-04-10 19:40:28.000000000 +0200
+++ asterisk-1.0.7/codecs/Makefile	2005-04-10 19:51:15.000000000 +0200
@@ -19,7 +19,6 @@
 #MODG723=codec_g723_1.so codec_g723_1b.so
 #MODG723=$(shell [ -f g723.1/coder.c ] && echo "codec_g723_1.so")
 #MODG723+=$(shell [ -f g723.1b/coder2.c ] && echo "codec_g723_1b.so")
-MODSPEEX=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")