clean up, use make functions instead of subshells, remove unused stuff
authorKevin P. Fleming <kpfleming@digium.com>
Tue, 30 Aug 2005 02:54:02 +0000 (02:54 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Tue, 30 Aug 2005 02:54:02 +0000 (02:54 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6449 65c4cc65-6c06-0410-ace0-fbb531ad65f3

Makefile
agi/Makefile
apps/Makefile
cdr/Makefile
channels/Makefile
codecs/Makefile
formats/Makefile
funcs/Makefile
pbx/Makefile
res/Makefile
utils/Makefile

index b2b0345..4e99b6b 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -26,9 +26,11 @@ HOST_CC=gcc
 # SUB_PROC=xscale # or maverick
 
 ifeq ($(CROSS_COMPILE),)
-OSARCH=$(shell uname -s)
+  OSARCH=$(shell uname -s)
+  OSREV=$(shell uname -r)
 else
-OSARCH=$(CROSS_ARCH)
+  OSARCH=$(CROSS_ARCH)
+  OSREV=${CROSS_REV)
 endif
 
 ######### More GSM codec optimization
@@ -40,7 +42,7 @@ endif
 #Overwite config files on "make samples"
 OVERWRITE=y
 
-#Tell gcc to optimize the asterisk's code
+#Tell gcc to optimize the code
 OPTIMIZE+=-O6
 
 #Include debug symbols in the executables (-g) and profiling info (-pg)
@@ -93,33 +95,33 @@ BUSYDETECT+= #-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
+  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
+  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
 
 # Pentium Pro Optimize
@@ -146,62 +148,65 @@ HTTP_CGIDIR=/var/www/cgi-bin
 # by the file in your home directory.
 
 ifneq ($(wildcard /etc/asterisk.makeopts),)
-include /etc/asterisk.makeopts
+  include /etc/asterisk.makeopts
 endif
 
 ifneq ($(wildcard ~/.asterisk.makeopts),)
-include ~/.asterisk.makeopts
+  include ~/.asterisk.makeopts
 endif
 
 ifeq (${OSARCH},Linux)
-ifeq ($(CROSS_COMPILE),)
-PROC?=$(shell uname -m)
-else
-PROC=$(CROSS_PROC)
-endif
-ifeq ($(PROC),x86_64)
-# You must have GCC 3.4 to use k8, otherwise use athlon
-PROC=k8
-#PROC=athlon
-OPTIONS+=-m64
-endif
-ifeq ($(PROC),sparc64)
-#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.
-#So we go lowest common available by gcc and go a step down, still a step up from
-#the default as we now have a better instruction set to work with. - Belgarath
-PROC=ultrasparc
-OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
-OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
-OPTIONS+=-fomit-frame-pointer
-endif
-
-ifeq ($(PROC),arm)
-# The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
-ifeq ($(SUB_PROC),maverick)
-OPTIONS+=-fsigned-char -mcpu=ep9312
-else
-ifeq ($(SUB_PROC),xscale)
-OPTIONS+=-fsigned-char -msoft-float -mcpu=xscale
-else
-OPTIONS+=-fsigned-char -msoft-float 
-endif
-endif
-endif
-MPG123TARG=linux
+  ifeq ($(CROSS_COMPILE),)
+    PROC?=$(shell uname -m)
+  else
+    PROC=$(CROSS_PROC)
+  endif
+
+  ifeq ($(PROC),x86_64)
+    # You must have GCC 3.4 to use k8, otherwise use athlon
+    PROC=k8
+    #PROC=athlon
+    OPTIONS+=-m64
+  endif
+
+  ifeq ($(PROC),sparc64)
+    #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.
+    #So we go lowest common available by gcc and go a step down, still a step up from
+    #the default as we now have a better instruction set to work with. - Belgarath
+    PROC=ultrasparc
+    OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
+    OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
+    OPTIONS+=-fomit-frame-pointer
+  endif
+
+  ifeq ($(PROC),arm)
+    # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
+    ifeq ($(SUB_PROC),maverick)
+      OPTIONS+=-fsigned-char -mcpu=ep9312
+    else
+      ifeq ($(SUB_PROC),xscale)
+        OPTIONS+=-fsigned-char -msoft-float -mcpu=xscale
+      else
+        OPTIONS+=-fsigned-char -msoft-float 
+      endif
+    endif
+  endif
+  MPG123TARG=linux
 endif
 
 ifeq ($(findstring BSD,${OSARCH}),BSD)
-PROC=$(shell uname -m)
+  PROC=$(shell uname -m)
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
 endif
 
 PWD=$(shell pwd)
-
 GREP=grep
+
 ifeq (${OSARCH},SunOS)
-GREP=/usr/xpg4/bin/grep
-M4=/usr/local/bin/m4
+  GREP=/usr/xpg4/bin/grep
+  M4=/usr/local/bin/m4
 endif
 
 INCLUDE=-Iinclude -I../include
@@ -209,47 +214,66 @@ CFLAGS+=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarat
 CFLAGS+=$(OPTIMIZE)
 
 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)
+  CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
 endif
+
 ifeq ($(PROC),ppc)
-CFLAGS+=-fsigned-char
+  CFLAGS+=-fsigned-char
 endif
 
-CFLAGS+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/usr/include/osp/osp.h ]; then echo "-DOSP_SUPPORT -I$(CROSS_COMPILE_TARGET)/usr/include/osp" ; fi)
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/osp/osp.h),)
+  CFLAGS+=-DOSP_SUPPORT -I$(CROSS_COMPILE_TARGET)/usr/include/osp
+endif
 
 ifeq (${OSARCH},FreeBSD)
-OSVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
-CFLAGS+=$(shell if test ${OSVERSION} -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
-LIBS+=$(shell if test  ${OSVERSION} -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi) -L$(CROSS_COMPILE_TARGET)/usr/local/lib
-INCLUDE+=-I$(CROSS_COMPILE_TARGET)/usr/local/include
-CFLAGS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/usr/local/include/spandsp ]; then echo "-I$(CROSS_COMPILE_TARGET)/usr/local/include/spandsp"; fi)
-MPG123TARG=freebsd
+  BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
+  CFLAGS+=$(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),)
+    CFLAGS+=" -I$(CROSS_COMPILE_TARGET)/usr/local/include/spandsp"
+  endif
+  MPG123TARG=freebsd
 endif # FreeBSD
 
 ifeq (${OSARCH},NetBSD)
-CFLAGS+=-pthread
-INCLUDE+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -I$(CROSS_COMPILE_TARGET)/usr/pkg/include
-MPG123TARG=netbsd
+  CFLAGS+=-pthread
+  INCLUDE+=-I$(CROSS_COMPILE_TARGET)/usr/pkg/include
+  MPG123TARG=netbsd
 endif
 
 ifeq (${OSARCH},OpenBSD)
-CFLAGS+=-pthread
+  CFLAGS+=-pthread
 endif
+
 ifeq (${OSARCH},SunOS)
-CFLAGS+=-Wcast-align -DSOLARIS
-INCLUDE+=-Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
+  CFLAGS+=-Wcast-align -DSOLARIS
+  INCLUDE+=-Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
 endif
 
-CFLAGS+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h ]; then echo "-DZAPTEL_OPTIMIZATIONS"; fi)
-CFLAGS+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h ]; then echo "-DZAPTEL_OPTIMIZATIONS"; fi)
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
+  CFLAGS+=-DZAPTEL_OPTIMIZATIONS
+endif
 
 LIBEDIT=editline/libedit.a
 
-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"; fi; fi; fi)
-ASTERISKVERSIONNUM=$(shell if [ -d CVS ]; then echo 999999 ; else if [ -f .version ] ; then awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version ; else echo 000000 ; fi ; fi)
-# Set the following two variables to match your httpd installation.
+ifneq ($(wildcard .version),)
+  ASTERISKVERSION=$(shell cat .version)
+  ASTERISKVERSIONNUM=$(shell awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version)
+  RPMVERSION=$(shell sed 's/[-\/:]/_/g' .version)
+else
+  RPMVERSION=unknown
+endif
 
-RPMVERSION=$(shell if [ -f .version ]; then sed 's/[-\/:]/_/g' .version; else echo "unknown" ; fi)
+ifneq ($(wildcard CVS),)
+  ASTERISKVERSIONNUM=999999
+  ifneq ($(wildcard CVS/Tag),)
+    ASTERISKVERSION=$(shell echo "CVS-`sed 's/^T//g' CVS/Tag`-`date +"%D-%T"`")
+  else
+    ASTERISKVERSION=CVS HEAD
+  endif
+else
+  ASTERISKVERSIONNUM=000000
+endif
 
 CFLAGS+= $(DEBUG_THREADS)
 CFLAGS+= $(TRACE_FRAMES)
@@ -258,30 +282,39 @@ CFLAGS+= $(BUSYDETECT)
 CFLAGS+= $(OPTIONS)
 CFLAGS+= -fomit-frame-pointer 
 SUBDIRS=res channels pbx apps codecs formats agi cdr funcs utils stdtime
+
 ifeq (${OSARCH},Linux)
-LIBS=-ldl -lpthread
+  LIBS=-ldl -lpthread
 endif
+
 LIBS+=-lncurses -lm
+
 ifeq (${OSARCH},Linux)
-LIBS+=-lresolv  #-lnjamd
+  LIBS+=-lresolv  #-lnjamd
 endif
+
 ifeq (${OSARCH},Darwin)
-LIBS+=-lresolv
-CFLAGS+=-D__Darwin__
-AUDIO_LIBS=-framework CoreAudio
+  LIBS+=-lresolv
+  CFLAGS+=-D__Darwin__
+  AUDIO_LIBS=-framework CoreAudio
 endif
+
 ifeq (${OSARCH},FreeBSD)
-LIBS+=-lcrypto
+  LIBS+=-lcrypto
 endif
+
 ifeq (${OSARCH},NetBSD)
-LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/local/lib -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib -lncurses
+  LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib -lncurses
 endif
+
 ifeq (${OSARCH},OpenBSD)
-LIBS=-lcrypto -lpthread -lm -lncurses
+  LIBS=-lcrypto -lpthread -lm -lncurses
 endif
+
 ifeq (${OSARCH},SunOS)
-LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
+  LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
 endif
+
 LIBS+=-lssl
 
 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
@@ -292,18 +325,20 @@ OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
        astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
        utils.o config_old.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
        netsock.o slinfactory.o ast_expr2.o ast_expr2f.o
+
 ifeq (${OSARCH},Darwin)
-OBJS+=poll.o dlfcn.o
-ASTLINK=-Wl,-dynamic
-SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
+  OBJS+=poll.o dlfcn.o
+  ASTLINK=-Wl,-dynamic
+  SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
 else
-ASTLINK=-Wl,-E 
-SOLINK=-shared -Xlinker -x
+  ASTLINK=-Wl,-E 
+  SOLINK=-shared -Xlinker -x
 endif
+
 ifeq (${OSARCH},SunOS)
-OBJS+=strcompat.o
-ASTLINK=
-SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
+  OBJS+=strcompat.o
+  ASTLINK=
+  SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
 endif
 
 INSTALL=install
@@ -345,11 +380,11 @@ db1-ast/libdb1.a: FORCE
        fi
 
 ifneq ($(wildcard .depend),)
-include .depend
+  include .depend
 endif
 
 ifneq ($(wildcard .tags-depend),)
-include .tags-depend
+  include .tags-depend
 endif
 
 ast_expr2.c:
index 999a077..8cea349 100755 (executable)
@@ -17,7 +17,11 @@ CFLAGS+=
 
 LIBS=
 ifeq ($(OSARCH),SunOS)
-LIBS=-lsocket -lnsl ../strcompat.o
+  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
 
 all: depend $(AGIS)
index d2211aa..94b5b21 100755 (executable)
@@ -11,7 +11,6 @@
 # the GNU General Public License
 #
 
-#APPS=app_dial.so app_playback.so app_directory.so app_intercom.so app_mp3.so 
 APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_mp3.so\
      app_system.so app_echo.so app_record.so app_image.so app_url.so app_disa.so \
      app_adsiprog.so app_getcpeid.so app_milliwatt.so \
@@ -31,12 +30,6 @@ APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_mp3.so\
      app_md5.so app_readfile.so app_chanspy.so app_settransfercapability.so \
      app_dictate.so app_externalivr.so
 
-ifneq (${OSARCH},Darwin)
-ifneq (${OSARCH},SunOS)
-#APPS+=app_intercom.so
-endif
-endif
-
 #
 # Obsolete things...
 #
@@ -50,27 +43,34 @@ endif
 #APPS+=app_skel.so
 #APPS+=app_rpt.so
 
-APPS+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/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 $(CROSS_COMPILE_TARGET)/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 $(CROSS_COMPILE_TARGET)/usr/include/osp/osp.h ]; then echo "app_osplookup.so" ; fi)
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
+  APPS+=app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/osp/osp.h),)
+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
 
 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
-               ifeq (${OSARCH},OpenBSD)
-                       CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include
-               endif
-       endif 
+  ifneq (${CURLLIBS},)
+    APPS+=app_curl.so
+  endif 
 endif
+
 CFLAGS+=-fPIC
+
 #
-# If you have MySQL 4.1 or later you can use ODBC
+# If you have UnixODBC you can use ODBC voicemail
 # storage
 #
-# Uncomment to use odbc storage
+# Uncomment to use ODBC storage
 #CFLAGS+=-DUSE_ODBC_STORAGE
-# Uncomment for extended odbc voicemail storage
+# Uncomment for extended ODBC voicemail storage
 #CFLAGS+=-DEXTENDED_ODBC_STORAGE
 # See doc/README.odbcstorage for more information
 
@@ -112,7 +112,7 @@ endif
 
 
 ifneq ($(wildcard .depend),)
-include .depend
+ include .depend
 endif
 
 depend: .depend
index 5e73cf2..4aeac02 100755 (executable)
 # the GNU General Public License
 #
 
-#ADD cdr_pgsql.so to MODS= to include PostgreSQL support: REQUIRES PostgreSQL libs
 MODS=cdr_csv.so cdr_manager.so cdr_custom.so
 
-
 CFLAGS+=-fPIC
 
-PROC=$(shell uname -m)
-OSARCH=$(shell uname -s)
-
-ifeq (${OSARCH},FreeBSD)
-SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
+ifeq ($(findstring BSD,${OSARCH}),BSD)
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
 endif
 
 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
@@ -30,43 +25,67 @@ endif
 #So we go lowest common available by gcc and go a step down, still a step up from
 #the default as we now have a better instruction set to work with. - Belgarath
 ifeq ($(PROC),sparc64)
-PROC=ultrasparc
-CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
+ PROC=ultrasparc
+  CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
 endif
 
 #
 # unixODBC stuff...
 #
-MODS+=$(shell if [ -f "$(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h" ]; then echo "cdr_odbc.so"; fi)
-MODS+=$(shell if [ -f "$(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h" ]; then echo "cdr_odbc.so"; fi) 
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
+  MODS+=cdr_odbc.so
+endif
 
 #
 # FreeTDS stuff...
 #
-MODS+=$(shell if [ -f "$(CROSS_COMPILE_TARGET)/usr/include/tds.h" ]; then echo "cdr_tds.so"; fi)
-MODS+=$(shell if [ -f "$(CROSS_COMPILE_TARGET)/usr/local/include/tds.h" ]; then echo "cdr_tds.so"; fi)
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/tds.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/tds.h),)
+  MODS+=cdr_tds.so
+endif
 
 #
 # PGSQL stuff...  Autoconf anyone??
 #
-MODS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include ] || [ -d $(CROSS_COMPILE_TARGET)/usr/include/pgsql ] || [ -d $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql ] || [ -d $(CROSS_COMPILE_TARGET)/opt/pgsql/include ] || [ -f $(CROSS_COMPILE_TARGET)/usr/include/libpq-fe.h ] ; then echo "cdr_pgsql.so"; fi)
-CFLAGS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include ]; then echo "-I$(CROSS_COMPILE_TARGET)/usr/local/pgsql/include"; fi)
-CFLAGS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/usr/include/pgsql ]; then echo "-I$(CROSS_COMPILE_TARGET)/usr/include/pgsql"; fi)
-CFLAGS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/usr/include/postgresql ]; then echo "-I$(CROSS_COMPILE_TARGET)/usr/include/postgresql"; fi)
-CFLAGS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql ]; then echo "-I$(CROSS_COMPILE_TARGET)/usr/local/include/pgsql"; fi)
-CFLAGS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/opt/pgsql/include ]; then echo "-I$(CROSS_COMPILE_TARGET)/opt/pgsql/include"; fi)
-#CFLAGS+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/usr/include/libpq-fe.h ]; then echo "-I$(CROSS_COMPILE_TARGET)/usr/include"; fi)
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/pgsql)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql)$(wildcard $(CROSS_COMPILE_TARGET)/opt/pgsql/include)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/libpq-fe.h),)
+  MODS+=cdr_pgsql.so
+endif
+
 MLFLAGS=
-MLFLAGS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/usr/lib/pgsql ]; then echo "-L$(CROSS_COMPILE_TARGET)/usr/lib/pgsql"; fi)
-MLFLAGS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/usr/local/pgsql/lib ]; then echo "-L$(CROSS_COMPILE_TARGET)/usr/local/pgsql/lib"; fi)
-MLFLAGS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/usr/local/lib/pgsql ]; then echo "-L$(CROSS_COMPILE_TARGET)/usr/local/lib/pgsql"; fi)
-MLFLAGS+=$(shell if [ -d $(CROSS_COMPILE_TARGET)/opt/pgsql/lib ]; then echo "-L$(CROSS_COMPILE_TARGET)/opt/pgsql/lib"; fi)
-MLFLAGS+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/usr/lib/libpq.so ]; then echo "-L$(CROSS_COMPILE_TARGET)/usr/lib"; fi)
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include),)
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/pgsql/include
+  MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/local/pgsql/lib
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/pgsql),)
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/pgsql
+  MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib/pgsql
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql),)
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/pgsql
+  MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib/pgsql
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/opt/pgsql/include),)
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/opt/pgsql/include
+  MLFLAGS+=-L$(CROSS_COMPILE_TARGET) /opt/pgsql/lib
+endif
+
+ifneq ($(wilcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql),)
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/postgresql
+endif
+
+ifneq ($(wilcard $(CROSS_COMPILE_TARGET)/usr/lib/libpq.so),)
+  MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib
+endif
 
 #
-# SQLIte stuff...
+# SQLite stuff...
 #
-MODS+=$(shell if [ -f "$(CROSS_COMPILE_TARGET)/usr/include/sqlite.h" ]; then echo "cdr_sqlite.so"; fi)
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sqlite.h),)
+  MODS+=cdr_sqlite.so
+endif
 
 all: depend $(MODS)
 
@@ -80,7 +99,7 @@ clean:
        $(CC) $(SOLINK) -o $@ $<
 
 ifneq ($(wildcard .depend),)
-include .depend
+  include .depend
 endif
 
 cdr_odbc.so: cdr_odbc.o
index c4b1d64..8ba12bf 100755 (executable)
 # the GNU General Public License
 #
 
-ifeq ($(CROSS_COMPILE),)
-OSARCH=$(shell uname -s)
-PROC=$(shell uname -m)
-else
-OSARCH=$(CROSS_ARCH)
-PROC=$(CROSS_PROC) 
-HOSTCC=gcc
-endif
-
 CHANNEL_LIBS=chan_modem.so chan_sip.so \
             chan_modem_aopen.so \
              chan_modem_bestdata.so \
              chan_agent.so chan_mgcp.so chan_iax2.so \
             chan_local.so chan_skinny.so chan_features.so
 
+ifeq ($(findstring BSD,${OSARCH}),BSD)
+ CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
+endif
+
 ifeq (${OSARCH},OpenBSD)
-CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include
-PTLIB=-lpt_OpenBSD_x86_r
-H323LIB=-lh323_OpenBSD_x86_r
-CHANH323LIB=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
+  PTLIB=-lpt_OpenBSD_x86_r
+  H323LIB=-lh323_OpenBSD_x86_r
 endif
+
 ifeq (${OSARCH},Linux)
-PTLIB=-lpt_linux_x86_r
-H323LIB=-lh323_linux_x86_r
-CHANH323LIB=-ldl
+  PTLIB=-lpt_linux_x86_r
+  H323LIB=-lh323_linux_x86_r
+  CHANH323LIB=-ldl
+endif
 
 ifeq ($(PROC),sparc64)
-PROC=ultrasparc
-CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
+  PROC=ultrasparc
+  CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
 endif
 
-endif
 ifeq (${OSARCH},FreeBSD)
-PTLIB=-lpt_FreeBSD_x86_r
-H323LIB=-lh323_FreeBSD_x86_r
-CHANH323LIB=-pthread
-SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
+  PTLIB=-lpt_FreeBSD_x86_r
+  H323LIB=-lh323_FreeBSD_x86_r
+  CHANH323LIB=-pthread
 endif
+
 ifeq (${OSARCH},NetBSD)
-PTLIB=-lpt_NetBSD_x86_r
-H323LIB=-lh323_NetBSD_x86_r
-SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
+  PTLIB=-lpt_NetBSD_x86_r
+  H323LIB=-lh323_NetBSD_x86_r
 endif
+
 ifneq (${OSARCH},Darwin)
-ifneq (${OSARCH},SunOS)
-CHANNEL_LIBS+=chan_oss.so chan_modem_i4l.so 
-endif
+  ifneq (${OSARCH},SunOS)
+    CHANNEL_LIBS+=chan_oss.so chan_modem_i4l.so 
+  endif
 endif
 
 ifeq (${OSARCH},SunOS)
-SOLINK+=-lrt
+  SOLINK+=-lrt
 endif
 
-CHANNEL_LIBS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/include/linux/ixjuser.h ] && echo chan_phone.so)
-CHANNEL_LIBS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/ixjuser.h ] && echo chan_phone.so)
-CHANNEL_LIBS+=$(shell [ -f h323/libchanh323.a ] && echo chan_h323.so)
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/ixjuser.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/ixjuser.h),)
+  CHANNEL_LIBS+=chan_phone.so
+endif
+
+ifneq ($(wildcard h323/libchanh323.a),)
+  CHANNEL_LIBS+=chan_h323.so
+endif
 
 CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
-CFLAGS+=$(shell [ ! -f $(CROSS_COMPILE_TARGET)/usr/include/linux/if_wanpipe.h ] && echo " -DOLD_SANGOMA_API")
-CHANNEL_LIBS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/include/alsa/asoundlib.h ] && echo "chan_alsa.so")
-CFLAGS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/lib/libpri.so.1 ] && echo " -DZAPATA_PRI")
-CFLAGS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/lib/libmfcr2.so.1 ] && echo " -DZAPATA_R2")
-CFLAGS+=$(shell [ -f alsa-monitor.h ] && echo " -DALSA_MONITOR")
-ZAPPRI=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/lib/libpri.so.1 ] && echo "-lpri")
-ZAPR2=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/lib/libmfcr2.so.1 ] && echo "-lmfcr2")
-CFLAGS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h ] && echo "-DIAX_TRUNKING")
-CFLAGS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h ] && echo "-DIAX_TRUNKING")
-CHANNEL_LIBS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h ] && echo "chan_vpb.so" )
-CFLAGS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h ] && echo " -DLINUX")
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/if_wanpipe.h),)
+  CFLAGS+=-DOLD_SANGOMA_API
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/alsa/asoundlib.h),)
+  CHANNEL_LIBS+=chan_alsa.so
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libpri.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libpri.so.1),)
+  CFLAGS+=-DZAPATA_PRI
+  ZAPPRI=-lpri
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libmfcr2.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libmfcr2.so.1),)
+  CFLAGS+=-DZAPATA_R2
+  ZAPR2=-lmfcr2
+endif
 
 ALSA_SRC=chan_alsa.c
-ALSA_SRC+=$(shell [ -f alsa-monitor.h ] && echo "alsa-monitor.h")
+
+ifneq ($(wildcard alsa-monitor.h),)
+  CFLAGS+=-DALSA_MONITOR
+  ALSA_SRC+=alsa-monitor.h
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
+  CFLAGS+=-DIAX_TRUNKING
+  CHANNEL_LIBS+=chan_zap.so
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h),)
+  CHANNEL_LIBS+=chan_vpb.so
+  CFLAGS+=-DLINUX
+endif
 
 CFLAGS+=-DCRYPTO
 CFLAGS+=-fPIC
@@ -94,17 +113,16 @@ CFLAGS+=#-DVOFRDUMPER
 
 ZAPDIR=/usr/lib
 
-CHANNEL_LIBS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h ] && echo "chan_zap.so")
-CHANNEL_LIBS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h ] && echo "chan_zap.so")
-
-CHANNEL_LIBS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/include/nbs.h ] && echo "chan_nbs.so" )
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/nbs.h),)
+  CHANNEL_LIBS+=chan_nbs.so
+endif
 
 ifndef OPENH323DIR
-OPENH323DIR=$(HOME)/openh323
+  OPENH323DIR=$(HOME)/openh323
 endif
 
 ifndef PWLIBDIR
-PWLIBDIR=$(HOME)/pwlib
+  PWLIBDIR=$(HOME)/pwlib
 endif
 
 #CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
@@ -119,26 +137,18 @@ clean:
        $(CC) $(SOLINK) -o $@ $<
 
 ifneq ($(wildcard .depend),)
-include .depend
+  include .depend
 endif
 
 ifneq ($(wildcard h323/Makefile.ast),)
-include h323/Makefile.ast
+  include h323/Makefile.ast
 endif
 
-ifeq ($(CROSS_COMPILE),)
-gentone: gentone.c
-       $(CC) -o gentone gentone.c -lm
-
-gentone-ulaw: gentone-ulaw.c
-       $(CC) -o gentone-ulaw gentone-ulaw.c -lm
-else
 gentone: gentone.c
-       $(HOSTCC) -o gentone gentone.c -lm
+       $(HOST_CC) -o gentone gentone.c -lm
 
 gentone-ulaw: gentone-ulaw.c
-       $(HOSTCC) -o gentone-ulaw gentone-ulaw.c -lm
-endif
+       $(HOST_CC) -o gentone-ulaw gentone-ulaw.c -lm
 
 busy.h: gentone
        ./gentone busy 480 620
index 9801f2c..0c5c2c2 100755 (executable)
 # the GNU General Public License
 #
 
-#
-# Uncomment if you have g723.1 code (with the same API as the Annex-A code
-# and have placed it in the g723.1 directory and/or the Annex-B code in 
-# 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 $(CROSS_COMPILE_TARGET)/usr/include/speex.h ] || [ -f $(CROSS_COMPILE_TARGET)/usr/include/speex/speex.h ] || [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/speex.h ] || [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/speex/speex.h ] && echo "codec_speex.so")
-MODILBC=$(shell [ -f ilbc/iLBC_decode.h ] && echo "codec_ilbc.so")
+ifneq ($(wildcard g723.1/coder.c),)
+  MODG723=codec_g723_1.so
+  LIBG723=g723.1/libg723.a
+endif
+
+ifneq ($(wildcard g723.1b/coder2.c),)
+  MODG723+=codec_g723_1b.so
+  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/usr/include/speex
+  LIBSPEEX+=-lspeex -lm
+endif
+ifneq (${ULI_SPEEX},)
+  MODSPEEX=codec_speex.so
+  CFLAGS+=-I/usr/local/include
+  LIBSPEEX=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
+  LIBSPEEX+=-lspeex -lm
+endif
+ifneq (${ULIS_SPEEX},)
+  MODSPEEX=codec_speex.so
+  CFLAGS+=-I/usr/local/include/speex
+  LIBSPEEX=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
+  LIBSPEEX+=-lspeex -lm
+endif
+
+ifneq ($(wildcard ilbc/iLBC_decode.h),)
+  MODILC=codec_ilbc.so
+  LIBILBC=ilbc/libilbc.a
+endif
+
 CFLAGS+=-fPIC
-CFLAGS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/speex.h ] && echo "-I$(CROSS_COMPILE_TARGET)/usr/local/include")
-CFLAGS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/speex/speex.h ] && echo "-I$(CROSS_COMPILE_TARGET)/usr/local/include/speex")
-CFLAGS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/include/speex/speex.h ] && echo "-I$(CROSS_COMPILE_TARGET)/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 $(CROSS_COMPILE_TARGET)/usr/local/lib/libspeex.a ] && echo "-L$(CROSS_COMPILE_TARGET)/usr/local/lib")
-LIBSPEEX+=-lspeex -lm
-LIBILBC=ilbc/libilbc.a
+
+ifeq ($(findstring BSD,${OSARCH}),BSD)
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
+endif
 
 CODECS+=$(MODG723) $(MODSPEEX) $(MODILBC) codec_gsm.so codec_lpc10.so  \
         codec_adpcm.so codec_ulaw.so codec_alaw.so codec_a_mu.so \
@@ -52,7 +79,7 @@ clean:
 $(LIBG723):
        $(MAKE) -C g723.1 all
 
-gsm/lib/libgsm.a:
+$(LIBGSM):
        $(MAKE) -C gsm lib/libgsm.a
 
 $(LIBG723B):
@@ -64,7 +91,7 @@ $(LIBLPC10):
 $(LIBILBC):
        $(MAKE) -C ilbc all
 
-codec_ilbc.so: codec_ilbc.o $(LIBILBC)
+$(MODILBC): codec_ilbc.o $(LIBILBC)
        $(CC) $(SOLINK) -o $@ $< $(LIBILBC)
 
 codec_g723_1.so : codec_g723_1.o $(LIBG723)
@@ -79,7 +106,7 @@ codec_g723_1b.so : codec_g723_1b.o $(LIBG723B)
 codec_gsm.so: codec_gsm.o $(LIBGSMT) 
        $(CC) $(SOLINK) -o $@ $< $(LIBGSM)
 
-codec_speex.so: codec_speex.o
+$(MODSPEEX): codec_speex.o
        $(CC) $(SOLINK) -o $@ $< $(LIBSPEEX)
 
 codec_lpc10.so: codec_lpc10.o $(LIBLPC10)
@@ -89,7 +116,7 @@ codec_lpc10.so: codec_lpc10.o $(LIBLPC10)
        $(CC) $(SOLINK) -o $@ $<
 
 ifneq ($(wildcard .depend),)
-include .depend
+  include .depend
 endif
 
 install: all
index ea0efee..823515c 100755 (executable)
@@ -16,15 +16,22 @@ FORMAT_LIBS=format_gsm.so format_wav.so \
        format_pcm_alaw.so format_h263.so format_g726.so format_ilbc.so \
        format_sln.so format_au.so
 FORMAT_LIBS+=format_jpeg.so
+
 #
-# G723 simple frame is depricated
+# G723 simple frame is deprecated
 #
 FORMAT_LIBS+=format_g723.so
 
 #
 # OGG/Vorbis format
 #
-FORMAT_LIBS+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/usr/include/vorbis/codec.h ]; then echo "format_ogg_vorbis.so" ; fi)
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vorbis/codec.h),)
+  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
 
 GSMLIB=../codecs/gsm/lib/libgsm.a
 
@@ -39,7 +46,7 @@ clean:
        $(CC) $(SOLINK) -o $@ $<
 
 ifneq ($(wildcard .depend),)
-include .depend
+  include .depend
 endif
 
 format_mp3.so : format_mp3.o
index 274a0df..e99cde0 100755 (executable)
@@ -35,6 +35,10 @@ CFLAGS+=-fPIC
 
 FUNC_SOURCES=$(BUILTINS:.o=.c)
 
+ifeq ($(findstring BSD,${OSARCH}),BSD)
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
+endif
+
 all: $(FUNCS)
 
 clean:
@@ -59,7 +63,7 @@ install: all
        for x in $(FUNCS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
 
 ifneq ($(wildcard .depend),)
-include .depend
+  include .depend
 endif
 
 depend: .depend
index da3f426..7af318a 100755 (executable)
 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
+
 # Add GTK console if appropriate
 #PBX_LIBS+=$(shell $(CROSS_COMPILE_BIN)gtk-config --cflags >/dev/null 2>/dev/null && echo "pbx_gtkconsole.so")
 # Add KDE Console if appropriate
@@ -58,7 +62,7 @@ pbx_dundi.so: dundi-parser.o pbx_dundi.o
        $(CC) $(SOLINK) -o $@ $<
 
 ifneq ($(wildcard .depend),)
-include .depend
+  include .depend
 endif
 
 install: all
index e745f9e..5804b21 100755 (executable)
 
 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 "$(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
-MODS+=$(shell if [ -f "$(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
-MODS+=$(shell if [ -f "$(CROSS_COMPILE_TARGET)/usr/include/osp/osp.h" ]; then echo "res_osp.so"; fi)
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
+  ifneq (${OSARCH},FreeBSD)
+    MODS+=res_config_odbc.so
+  else
+    MODS+=$(shell if test ${BSDVERSION} -ge 500000 ; then echo "res_config_odbc.so"; fi)
+  endif
+  MODS+=res_odbc.so
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/osp/osp.h),)
+  MODS+=res_osp.so
+  OSPLIB=$(CROSS_COMPILE_TARGET)/usr/lib/libosp.a
+endif
+
+ifeq ($(findstring BSD,${OSARCH}),BSD)
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
+endif
 
 CRYPTO_LIBS=-lssl -lcrypto
 
 CFLAGS+=
-CFLAGS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h ] && echo " -DZAPATA_MOH")
-CFLAGS+=$(shell [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h ] && echo " -DZAPATA_MOH")
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
+  CFLAGS+=-DZAPATA_MOH
+endif
+
 #
 # Work around buggy RedHat 9.0
 #
 CFLAGS+=-DOPENSSL_NO_KRB5 -fPIC
-OSPLIB=$(CROSS_COMPILE_TARGET)/usr/lib/libosp.a
 
 all: depend $(MODS)
 
@@ -46,13 +63,13 @@ res_odbc.so: res_odbc.o
        $(CC) $(SOLINK) -o $@ $< -lodbc
 
 res_osp.so: res_osp.o $(OSPLIB)
-       $(CC) $(SOLINK) -o $@ $< $(OSPLIB)
+       $(CC) $(SOLINK) -o $@ $^
 
 %.so : %.o
        $(CC) $(SOLINK) -o $@ $<
 
 ifneq ($(wildcard .depend),)
-include .depend
+  include .depend
 endif
 
 depend: .depend
index 2ee6a59..30a2a1f 100755 (executable)
 #
 CFLAGS+=-DNO_AST_MM
 
-OSARCH=$(shell uname -s)
 ifeq ($(findstring BSD,${OSARCH}),BSD)
-CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
+  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
 endif
 
 TARGET=stereorize streamplayer
 
-TARGET+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/usr/include/popt.h ]; then echo "smsq"; else if [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/popt.h ]; then echo "smsq"; fi ; fi)
-TARGET+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/usr/include/newt.h ]; then echo "astman"; else if [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/newt.h ]; then echo "astman"; fi ; fi)
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/popt.h)$(wildcard -f $(CROSS_COMPILE_TARGET)/usr/local/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),)
+  TARGET+=astman
+endif
+
 ifeq (${OSARCH},SunOS)
-SOL=../strcompat.o
+  SOL=../strcompat.o
 endif
 
 all: depend $(TARGET)
@@ -64,7 +69,7 @@ streamplayer: streamplayer.o
        $(CC) $(CFLAGS) -o streamplayer ${SOL} streamplayer.o
 
 ifneq ($(wildcard .depend),)
-include .depend
+  include .depend
 endif
 
 depend: .depend