Makefile.defs
4c97b840
 ifeq ($(makefile_defs),"1")
6c3b7f77
 else
16c62928
 makefile_defs="1"
6c3b7f77
 export makefile_defs
cc30937c
 
ee43b839
 GIT := $(shell which git)
e50ab105
 
 ifneq ($(GIT),)
ee43b839
    SCM_REV := $(shell if git --help describe |grep dirty 2>&1 >/dev/null ; \
e73038f1
         then git describe --always --dirty 2>/dev/null; \
         else git describe --always 2>/dev/null; fi)
e50ab105
 endif
 
011dfa1d
 #version number
b6dcf51c
 VERSION = 1
9a5617c4
 PATCHLEVEL = 6
011dfa1d
 SUBLEVEL = 0
e50ab105
 
 ifneq ($(SCM_REV),)
ee43b839
 RELEASE := $(SCM_REV)
52b19cb8
 else
ee43b839
 REL_VERSION := $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
 RELEASE := $(REL_VERSION)$(EXTRAVERSION)
52b19cb8
 endif
011dfa1d
 
85ec87b8
 APP_NAME ?= sems
a024753f
 
052984ad
 CPPFLAGS += -D_DEBUG \
 	  -D_THREAD_SAFE -D_REENTRANT \
6f44a030
 	  -DSEMS_VERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"'\
052984ad
 	  -DOS='"$(OS)"' 	\
839255d9
 	  -DSYSTEM_SAMPLECLOCK_RATE=32000LL \
           -DSEMS_APP_NAME='"$(APP_NAME)"'
3981e001
 #         -DMAX_RTP_SESSIONS=8192 \
 #	  -DSUPPORT_IPV6 \
75c40f15
 #	  -DNO_THREADID_LOG \
425648e5
 #         -DLOG_PRETTY_FUNCTION \
 #         -DLOG_LOC_DATA_ATEND
052984ad
 
ceb2030a
 
 # compile with session thread pool support?
 #      use this for very high concurrent call count 
 #      applications (e.g. for signaling only)
 #      if compiled with thread pool, there will be a 
 #      thread pool of configurable size processing the
 #      signaling and application logic of the calls.
 #      if compiled without thread pool support, every
 #      session will have its own thread.
 #
c8528a25
 #USE_THREADPOOL = yes
ceb2030a
 
052984ad
 # compile with spandsp DTMF detection? see soft-switch.org
 #   this needs a fairly new version of spandsp - tested with 0.0.4pre11
 #   will not work with spandsp 0.0.2 .
 #   (which means that current debian and gentoo packages don't work)
 #   
 #USE_SPANDSP    = yes
 # statically link spandsp library? 
 #   (might need adjusting spandsp lib path LIBSPANDSP_LDIR - may be /usr/lib)
 #LIBSPANDSP_STATIC = yes
 #LIBSPANDSP_LDIR = /usr/local/lib/
 
ab2b4367
 # compile with sample rate conversion from secret rabbit code? 
 # (see http://www.mega-nerd.com/SRC/)
 #
 #USE_LIBSAMPLERATE = yes
 
212426f6
 # compile with internal resampler?
 #
 #
 USE_INTERNAL_RESAMPLER = yes
 
6f44a030
 #
 # ZRTP support? (see zfoneproject.com)
e1ef61f1
 #WITH_ZRTP = yes
6f44a030
 
ed0d5240
 #
 # exclude some modules from compilation?
 # e.g. python modules:
a0dfd71a
 
75856d71
 exclude_core_modules = g729 silk
a0dfd71a
 #exclude_apps_modules = py_sems ivr mailbox pin_collect conf_auth mp3 examples
ed0d5240
 
43a387c3
 # build in support for monitoring?
 #
 #
a8c0a8fb
 USE_MONITORING=yes
43a387c3
 
37e35c7e
 # Support for long debug messages? (useful for debugging SIP messages' contents)
 #
c60b508e
 # disable for slight performance gain
 LONG_DEBUG_MESSAGE=yes
37e35c7e
 
be60e06c
 # Is this a debug build or not?
 debug=no
 
f8a47278
 # Propagate all unparsed SIP headers into AmSipReply. Disabled by default
 # because only special applications might need this and it brings higher memory
 # demands and affects performance.
 #PROPAGATE_UNPARSED_REPLY_HEADERS=no
 
37e35c7e
 
 ################### end of configuration section #######################
 
7be66986
 LDFLAGS += -lm
011dfa1d
 
a0dfd71a
 GETOS=$(COREPATH)/compat/getos
 GETARCH=$(COREPATH)/compat/getarch
 
c88ed81e
 
 OS   := $(shell if [ -f $(GETOS) ] ; then $(GETOS); else  $(CC) $(EXTRA_CFLAGS) -o $(GETOS) $(GETOS).c && $(GETOS); fi)
 ARCH := $(shell if [ -f $(GETARCH) ] ; then $(GETARCH); else $(CC) $(EXTRA_CFLAGS) -o $(GETARCH) $(GETARCH).c && $(GETARCH); fi)
011dfa1d
 
ceb2030a
 ifdef USE_THREADPOOL
 CPPFLAGS += -DSESSION_THREADPOOL
 endif
 
ee43b839
 ifndef USE_SPANDSP
a0dfd71a
 exclude_core_modules += g722
d52ad8a0
 endif
 
43a387c3
 ifdef USE_MONITORING
37e35c7e
 CPPFLAGS += -DUSE_MONITORING
43a387c3
 endif
 
f277efd5
 ifndef LONG_DEBUG_MESSAGE
37e35c7e
 CPPFLAGS += -DLOG_BUFFER_LEN=2048
 endif
 
f8a47278
 ifeq ($(PROPAGATE_UNPARSED_REPLY_HEADERS),yes)
 CPPFLAGS += -DPROPAGATE_UNPARSED_REPLY_HEADERS
 endif
37e35c7e
 
9411ad3a
 # Additions for Solaris support.
011dfa1d
 ifeq ($(OS),solaris)
535e45a8
 	CPPFLAGS += -DHAVE_SYS_SOCKIO_H -DBSD_COMP -fPIC -include compat/solaris.h
         CFLAGS += -DHAVE_SYS_SOCKIO_H -DBSD_COMP -fPIC -include compat/solaris.h
9411ad3a
         # For nanosleep.
         LDFLAGS += -lrt
         # For inet_aton.
         LDFLAGS += -lresolv
 
2835753a
 	# I don't have libspeex installed.
 	# binrpcctrl does some really weird header stuff that doesn't work.
a0dfd71a
 	exclude_core_modules += binrpcctrl ilbc speex
011dfa1d
 endif
 
ea2a6e38
 
 
ecd357cf
 
011dfa1d
 # fix sparc -> sparc64
 ifeq ($(ARCH),sparc)
 	ifeq ($(shell uname -m),sun4u)
 		ARCH := sparc64
 	endif
 endif
 
5eb6b49c
 # need OS specific for this ?
400d6c6e
 CXX = g++
 CC = gcc
ae4d79e2
 LD = $(CC)
9411ad3a
 
839255d9
 CXXFLAGS += -Wall -Wno-reorder -Wno-unused -fPIC -g $(EXTRA_CXXFLAGS) 
be60e06c
 CFLAGS   += -Wall -fPIC -g $(EXTRA_CFLAGS)
5eb6b49c
 
be60e06c
 # only optimize if releasing, as it slows down the build process
 ifneq ($(debug),yes)
 	CXXFLAGS += -O2
 	CFLAGS += -O2
 endif
ecd357cf
 
f4d64a3d
 ifeq ($(DEBUG_PLAYOUT), yes)
ecd357cf
 CPPFLAGS +=  -DDEBUG_PLAYOUTBUF
c2d96d60
 endif
 
9187598d
 ifdef WITH_ZRTP
 CPPFLAGS += -DWITH_ZRTP \
 	    -DBUILD_ZRTP_MUTEXES \
 	    -DBUILD_DEFAULT_CACHE -DBUILD_DEFAULT_TIMER -DUNIX -DBUILD_ZRTP_MUTEXES \
 	    -I/usr/local/include/zrtp 
 endif
 
a0dfd71a
 TARGET=
268532f5
 LIB_LDFLAGS = -shared
 
b0e99ce4
 ifeq ($(LD), clang)
 LDFLAG_DYN=
 LDFLAG_PTHREAD=
 else
 LDFLAG_DYN = -rdynamic
 LDFLAG_PTHREAD = -lpthread
 endif
 
011dfa1d
 ifeq ($(OS), linux)
b0e99ce4
 	LDFLAGS +=  -ldl $(LDFLAG_DYN) $(LDFLAG_PTHREAD)
aa8384c7
 	CPPFLAGS += -DPROPAGATE_COREDUMP_SETTINGS
011dfa1d
 else
 ifeq ($(OS), freebsd)
b0e99ce4
 	LDFLAGS += $(LDFLAG_DYN) $(LDFLAG_PTHREAD)
011dfa1d
 else
 ifeq ($(OS), openbsd)
b0e99ce4
 	LDFLAGS += $(LDFLAG_DYN) $(LDFLAG_PTHREAD)
011dfa1d
 else
 ifeq ($(OS), netbsd)
b0e99ce4
 	LDFLAGS += $(LDFLAG_DYN) $(LDFLAG_PTHREAD)
268532f5
 else
ea2a6e38
 ifeq ($(OS), macosx)
b0e99ce4
 	LDFLAGS += $(LDFLAG_DYN) $(LDFLAG_PTHREAD)
268532f5
 	LIB_LDFLAGS = -flat_namespace -undefined suppress -bundle
 	CXXFLAGS += -fno-common
 	CFLAGS += -fno-common
 
4121365f
 	#necessary for sa_len|ss_len|sin_len
 	# may be needed on other *BSD
 	CPPFLAGS += -DBSD44SOCKETS
 
268532f5
 	# add the DarwinPorts directory
34a5a9d6
 	ifneq ($(ARCH), iphone)
 	      CPPFLAGS += -D__DARWIN_UNIX03
 	      CPPFLAGS += -I /opt/local/include
 	      LDFLAGS += -L/opt/local/lib
 	endif	      
011dfa1d
 else
a0dfd71a
 ifeq ($(OS), solaris)
b0e99ce4
        	LDFLAGS+= -fPIC -ldl -lsocket -lnsl $(LDFLAG_PTHREAD)
011dfa1d
 	TARGET=solaris
a0dfd71a
 	# These don't build on Solaris because of missing Python, invalid make args, or other.
 	exclude_app_modules += py_sems py_comp pin_collect mailbox ivr diameter_client conf_auth mp3 cc_acc_xmlrpc xmlrpc2di
 
 endif
 endif
 endif
 endif
 endif
 endif
 
 LDFLAGS += -lstdc++ 
 
 ifeq ($(ARCH),iphone)
 LDFLAGS += -lgcc_eh
011dfa1d
 endif
a0dfd71a
 
 ifdef WITH_ZRTP
 LDFLAGS +=-lzrtp -lbn
268532f5
 endif
011dfa1d
 
268532f5
 LIB_LDFLAGS += $(LDFLAGS)
011dfa1d
 
a0dfd71a
 
011dfa1d
 # install path is $(basedir) $(prefix) 
 # example:
 #  creating a bin. archive in /tmp, which unpacks in /usr/local
 #  basedir=/tmp
 #  prefix=/usr/local
 
55433a71
 DESTDIR ?= 
 PREFIX ?= /usr/local
ec26765b
 prefix ?= $(PREFIX)
011dfa1d
 BASEDIR ?=
 basedir = $(BASEDIR)
 
 # Redhat users should use sems.redhat instead of sems
 # the file will be to $(bin-prefix)/$(bin-dir)/sems copied.
 start-script = sems.redhat
 
 # install prefixes for various stuff
 cfg-prefix = $(basedir)$(prefix)
 bin-prefix = $(basedir)$(prefix)
 modules-prefix = $(basedir)$(prefix)
 doc-prefix = $(basedir)$(prefix)
 audio-prefix = $(basedir)$(prefix)
db569f1e
 lib-prefix = $(basedir)$(prefix)
011dfa1d
 
 # dirs
a024753f
 cfg-dir = etc/$(APP_NAME)/
011dfa1d
 
 bin-dir = sbin/
a024753f
 modules-dir = lib/$(APP_NAME)/plug-in/
 audio-dir = lib/$(APP_NAME)/audio/
 lib-dir = lib/$(APP_NAME)/
011dfa1d
 
 ifeq ($(OS), linux)
a024753f
 	doc-dir = share/doc/$(APP_NAME)/
011dfa1d
 	man-dir = share/man/
 else
 ifeq ($(OS), freebsd)
a024753f
 	doc-dir = share/doc/$(APP_NAME)/
011dfa1d
 	man-dir = man/
 else
 ifeq ($(OS), openbsd)
a024753f
 	doc-dir = share/doc/$(APP_NAME)/
011dfa1d
 	man-dir = man/
 else
 ifeq ($(OS), netbsd)
a024753f
 	doc-dir = share/doc/$(APP_NAME)
011dfa1d
 	man-dir = man/
 else
a024753f
 	doc-dir = doc/$(APP_NAME)/
011dfa1d
 	man-dir = man/
 endif
 endif
 endif
 endif
b5fe5320
 
011dfa1d
 # target dirs for various stuff
 bin-target = $(prefix)/$(bin-dir)
ec26765b
 cfg-target ?= $(prefix)/$(cfg-dir)
 app-cfg-target = $(cfg-target)etc/
011dfa1d
 modules-target = $(prefix)/$(modules-dir)
 audio-target = $(prefix)/$(audio-dir)
b5fe5320
 lib-target = $(prefix)/$(lib-dir)
011dfa1d
 
 ifeq ($(OS), solaris)
 #use GNU versions
 INSTALL ?= ginstall
 TAR ?= gtar
 else
 INSTALL ?= install 
 TAR ?= tar
 endif
 
 INSTALL-TOUCH = touch          # used to create the file first (good to 
                                #  make solaris install work)
 INSTALL-CFG = $(INSTALL) -m 644
 INSTALL-BIN = $(INSTALL) -m 755
 INSTALL-MODULES = $(INSTALL) -m 755
 INSTALL-DOC = $(INSTALL) -m 644
 INSTALL-AUDIO = $(INSTALL) -m 644
 
d8f1aeb9
 #export stuff to sub-makes
ea2a6e38
 export REL_VERSION RELEASE OS ARCH
d8f1aeb9
 export CPPFLAGS CXXFLAGS LDFLAGS CFLAGS LIB_LDFLAGS
 export CXX CC LD
 export DESTDIR PREFIX prefix basedir ser-prefix
 export start-script
db569f1e
 export cfg-prefix bin-prefix modules-prefix doc-prefix audio-prefix lib-prefix
9ea2b531
 export cfg-dir bin-dir modules-dir audio-dir lib-dir doc-dir man-dir
8f289e98
 export bin-target cfg-target app-cfg-target modules-target audio-target lib-target
d8f1aeb9
 export INSTALL TAR INSTALL-TOUCH INSTALL-CFG INSTALL-BIN INSTALL-MODULES INSTALL-DOC INSTALL-AUDIO
a024753f
 export APP_NAME
d8f1aeb9
 
3184c2bb
 export USE_SPANDSP LIBSPANDSP_STATIC LIBSPANDSP_LDIR 
212426f6
 export USE_LIBSAMPLERATE USE_INTERNAL_RESAMPLER
f8a4d6be
 export WITH_ZRTP
3184c2bb
 export USE_MONITORING
a0dfd71a
 export exclude_core_modules exclude_app_modules
d8f1aeb9
 endif  # ifeq ($(makefile_defs, 1)
a867a606
 
55433a71
 mk-install-dirs: $(DESTDIR)$(cfg-target) \
8f289e98
 		 $(DESTDIR)$(app-cfg-target) \
55433a71
 		 $(DESTDIR)$(bin-prefix)/$(bin-dir) \
 		 $(DESTDIR)$(modules-prefix)/$(modules-dir) \
 		 $(DESTDIR)$(audio-prefix)/$(audio-dir) \
 		 $(DESTDIR)$(doc-prefix)/$(doc-dir)
a867a606
 
55433a71
 $(DESTDIR)$(cfg-target): 
 	mkdir -p $(DESTDIR)$(cfg-target)
a867a606
 
8f289e98
 $(DESTDIR)$(app-cfg-target): 
 	mkdir -p $(DESTDIR)$(app-cfg-target)
 
55433a71
 $(DESTDIR)$(bin-prefix)/$(bin-dir):
 	mkdir -p $(DESTDIR)$(bin-prefix)/$(bin-dir)
a867a606
 
55433a71
 $(DESTDIR)$(modules-prefix)/$(modules-dir):
 	mkdir -p $(DESTDIR)$(modules-prefix)/$(modules-dir)
a867a606
 
55433a71
 $(DESTDIR)$(audio-prefix)/$(audio-dir):
 	mkdir -p $(DESTDIR)$(audio-prefix)/$(audio-dir)
a867a606
 
55433a71
 $(DESTDIR)$(doc-prefix)/$(doc-dir):
 	mkdir -p $(DESTDIR)$(doc-prefix)/$(doc-dir)