Asterisk Build Notes for Solaris

Asterisk 1.6 on OpenSolaris

These notes were made in January 2010 by Ben Klang. These notes are the result
of experience building Asterisk 1.6.1 and 1.6.2 on OpenSolaris 2009.06.

Support
According to the README file from 1.6.2: "Asterisk has also been 'ported' and reportedly runs properly on other
operating systems as well, including Sun Solaris, Apple's Mac OS X, Cygwin,
and the BSD variants." Digium's developers have also been doing a good job of addressing build and run-time
issues encountered with Asterisk on Solaris.

Build Prerequisites
The following packages are recommend for building Asterisk 1.6.2 on OpenSolaris:
  • SUNWlibm (math library)
  • gcc-dev (compiler and several dependencies)
  • SUNWflexlex (GNU flex)
  • SUNWggrp (GNU grep)
  • SUNWgsed (GNU sed)
  • SUNWdoxygen (optional; needed for "make progdocs")
  • SUNWopenldap (optional; needed for res_config_ldap; see below)
  • SUNWgnu-coreutils (optional; provides GNU install; see below)

Caution: installing SUNW gnu packages will change the default application run when
the user types 'sed' and 'grep' from /usr/bin/sed to /usr/gnu/bin/sed. Just be aware of this change,
as there are differences between the Sun and GNU versions of these utilities.

LDAP dependencies
Because OpenSolaris ships by default with Sun's LDAP libraries, you must install the
SUNWopenldap package to provide OpenLDAP libraries. Because of namespace conflicts,
the standard LDAP detection will not work.

There are two possible solutions:
  1. Port res_config_ldap to use only the RFC-specified API. This should allow it to link
against Sun's LDAP libraries. The problem is centered around the use of the OpenLDAP-specific
ldap_initialize() call.
  1. Change the detection routines in configure to use OpenSolaris' layout of OpenLDAP. This seems
doubtful simply because the filesystem layout of SUNWopenldap is so non-standard.

Despite the above to possibilities, there is a workaround to make Asterisk compile with res_config_ldap.

  • Modify the "configure" script, changing all instances of "-lldap" to "-lldap-2.4". At the time of this writing
there are only 4 instances. This alone will make configure properly detect LDAP headers. But it will not compile.
  • When running make, specify the use of the OpenLDAP headers like this:
"make LDAP_INCLUDE=-I/usr/include/openldap"

Makefile layouts
The Makefile overrides any usage of --prefix. I hope to address this issue in the future. I suspect the assumptions
are from back before configure provided the ability to set the installation prefix. Regardless, if you are building on
OpenSolaris, be aware of this behavior of the Makefile!

If you want to alter the install locations you will need to hand-edit the Makefile. Search for the string "SunOS"
to find the following section:


# Define standard directories for various platforms
# These apply if they are not redefined in asterisk.conf
ifeq ($(OSARCH),SunOS)
  ASTETCDIR=/etc/asterisk
  ASTLIBDIR=/opt/asterisk/lib
  ASTVARLIBDIR=/var/opt/asterisk
  ASTDBDIR=$(ASTVARLIBDIR)
  ASTKEYDIR=$(ASTVARLIBDIR)
  ASTSPOOLDIR=/var/spool/asterisk
  ASTLOGDIR=/var/log/asterisk
  ASTHEADERDIR=/opt/asterisk/include/asterisk
  ASTBINDIR=/opt/asterisk/bin
  ASTSBINDIR=/opt/asterisk/sbin
  ASTVARRUNDIR=/var/run/asterisk
  ASTMANDIR=/opt/asterisk/man
else


Note that, despite the comment, these definitions have build-time and run-time implications. Make sure you
make these changes BEFORE you build!

FAX support with SpanDSP
I have been able to get this to work reliably. Note Ticket 16342 if
you do not install SpanDSP to the default locations (/usr/include and /usr/lib). T.38 FAX over SIP works
reliably as well.

There is one build issue with SpanDSP that I need to document (FIXME)

Gotchas
  • WAV and WAV49 files are not written correctly (see Ticket 16610)
  • bootstrap.sh does not correctly detect OpenSolaris build tools (see Ticket 16341)
  • Console documentation is not properly loaded at startup (see Ticket 16688)
  • Solaris sed does not properly create AEL parser files (see Ticket 16696; workaround is to install GNU sed with SUNWgsed)
  • Asterisk's provided install script, install-sh, is not properly referenced in the makeopts file that is generated during the build. One workaround is to install GNU install from the SUNWgnu-coreutils package. (See Ticket 16781)

Finally, Solaris memory allocation seems far more sensitive than Linux. This has resulted in the discovery of several previously unknown bugs related to uninitialized variables that Linux handled silently. Note that this means, until these bugs are found and fixed, you may get segfaults.

At the time of this writing I have had a server up and running reasonably stable. However, there are large sections of Asterisk's codebase I do not use and
likely contain more of these uninitialized variable problems and associated potential segfaults.

bklang


Logan submitted these notes ...

I have Asterisk 1.0-RC1 running under Solaris 10 (s10_60) using a
Sipura SPA-3000 for local FXS and FXO ports. I built the binaries with
gcc 3.4.0 on a Solaris 9 box. I initially ran it on the Solaris 9 box
then moved it to the Solaris 10 box. Both boxes are multiprocessor sun
boxes. For my usage using only network based channels Asterisk
appears to run fine under Solaris.

I had to make a large number of minor changes to get it to build. I'll
look into submitting a patch to the developers. Until then here is a
list of the changes.

include/asterisk/lock.h:
added (very important to get properly
initialized recursive mutexes.)
#define AST_MUTEX_INIT_W_CONSTRUCTORS

utils.c:
arguments for gethostbyname_r are different.
res = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &herrno);
if (!res || !hp->hp.h_addr_list || !hp->hp.h_addr_list0)

apps/app_qcall.c:
replaced flock calls with fcntl calls. like
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
if (fcntl(fileno(fp), F_SETLK, &lock) == -1)

acl.c:
added #include and removed the static
initializer for __ourip (os version dependent.)

asterisk.c:
replaced local variable "sun" with "sunAddr" to avoid conflicting macro definition.

logger.c:
the syslog facility enumeration is different under solaris.
I punted and hardwired LOG_LOCAL0 for my use.

stdtime/localtime.c:
added
#define _POSIX_PTHREAD_SEMANTICS
#undef TM_ZONE
#undef TM_GMTOFF

channels/chan_mgcp.c:
replaced INADDR_NONE with (in_addr_t)(-1)

channels/chan_agent.c:
removed sched_yield() calls. they shouldn't be necessary anyway.

channels/chan_modem.c:
cfmakeraw and cfsetspeed don't exist under solaris. Someone should replace them with the appropriate calls to set the speed but I'm not using this channel so I just commented them out for my use.

replaced various references to u_int*_t with uint*_t.
They are both used but only uint*_t is defined under Solaris.

replaced various references to AF_LOCAL with AF_UNIX

defined BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN

removed #include from various source files

added an implementation of strsep which doesn't exist under solaris.
Initially considered replacing with strtok_r but there are too many occurrences.

added sun to the mac rule to note build all the /dev/dsp based stuff. intercom for example.

added -D_REENTRANT for sun.

added sun libs -lsocket -lresolv -ldl -lpthread -lthread

for sun switched -lncurses to -lcurses

changed sun ASTLINK to just -Wl

changed GREP to use /usr/xpg4/bin/grep

avoided -march flags in various build files

changed mkdep to use bash:
first line #!/usr/bin/bash

I'm probably forgetting some changes but that should be most of them.

logan
~/np~


Asterisk 1.6 on OpenSolaris

These notes were made in January 2010 by Ben Klang. These notes are the result
of experience building Asterisk 1.6.1 and 1.6.2 on OpenSolaris 2009.06.

Support
According to the README file from 1.6.2: "Asterisk has also been 'ported' and reportedly runs properly on other
operating systems as well, including Sun Solaris, Apple's Mac OS X, Cygwin,
and the BSD variants." Digium's developers have also been doing a good job of addressing build and run-time
issues encountered with Asterisk on Solaris.

Build Prerequisites
The following packages are recommend for building Asterisk 1.6.2 on OpenSolaris:
  • SUNWlibm (math library)
  • gcc-dev (compiler and several dependencies)
  • SUNWflexlex (GNU flex)
  • SUNWggrp (GNU grep)
  • SUNWgsed (GNU sed)
  • SUNWdoxygen (optional; needed for "make progdocs")
  • SUNWopenldap (optional; needed for res_config_ldap; see below)
  • SUNWgnu-coreutils (optional; provides GNU install; see below)

Caution: installing SUNW gnu packages will change the default application run when
the user types 'sed' and 'grep' from /usr/bin/sed to /usr/gnu/bin/sed. Just be aware of this change,
as there are differences between the Sun and GNU versions of these utilities.

LDAP dependencies
Because OpenSolaris ships by default with Sun's LDAP libraries, you must install the
SUNWopenldap package to provide OpenLDAP libraries. Because of namespace conflicts,
the standard LDAP detection will not work.

There are two possible solutions:
  1. Port res_config_ldap to use only the RFC-specified API. This should allow it to link
against Sun's LDAP libraries. The problem is centered around the use of the OpenLDAP-specific
ldap_initialize() call.
  1. Change the detection routines in configure to use OpenSolaris' layout of OpenLDAP. This seems
doubtful simply because the filesystem layout of SUNWopenldap is so non-standard.

Despite the above to possibilities, there is a workaround to make Asterisk compile with res_config_ldap.

  • Modify the "configure" script, changing all instances of "-lldap" to "-lldap-2.4". At the time of this writing
there are only 4 instances. This alone will make configure properly detect LDAP headers. But it will not compile.
  • When running make, specify the use of the OpenLDAP headers like this:
"make LDAP_INCLUDE=-I/usr/include/openldap"

Makefile layouts
The Makefile overrides any usage of --prefix. I hope to address this issue in the future. I suspect the assumptions
are from back before configure provided the ability to set the installation prefix. Regardless, if you are building on
OpenSolaris, be aware of this behavior of the Makefile!

If you want to alter the install locations you will need to hand-edit the Makefile. Search for the string "SunOS"
to find the following section:


# Define standard directories for various platforms
# These apply if they are not redefined in asterisk.conf
ifeq ($(OSARCH),SunOS)
  ASTETCDIR=/etc/asterisk
  ASTLIBDIR=/opt/asterisk/lib
  ASTVARLIBDIR=/var/opt/asterisk
  ASTDBDIR=$(ASTVARLIBDIR)
  ASTKEYDIR=$(ASTVARLIBDIR)
  ASTSPOOLDIR=/var/spool/asterisk
  ASTLOGDIR=/var/log/asterisk
  ASTHEADERDIR=/opt/asterisk/include/asterisk
  ASTBINDIR=/opt/asterisk/bin
  ASTSBINDIR=/opt/asterisk/sbin
  ASTVARRUNDIR=/var/run/asterisk
  ASTMANDIR=/opt/asterisk/man
else


Note that, despite the comment, these definitions have build-time and run-time implications. Make sure you
make these changes BEFORE you build!

FAX support with SpanDSP
I have been able to get this to work reliably. Note Ticket 16342 if
you do not install SpanDSP to the default locations (/usr/include and /usr/lib). T.38 FAX over SIP works
reliably as well.

There is one build issue with SpanDSP that I need to document (FIXME)

Gotchas
  • WAV and WAV49 files are not written correctly (see Ticket 16610)
  • bootstrap.sh does not correctly detect OpenSolaris build tools (see Ticket 16341)
  • Console documentation is not properly loaded at startup (see Ticket 16688)
  • Solaris sed does not properly create AEL parser files (see Ticket 16696; workaround is to install GNU sed with SUNWgsed)
  • Asterisk's provided install script, install-sh, is not properly referenced in the makeopts file that is generated during the build. One workaround is to install GNU install from the SUNWgnu-coreutils package. (See Ticket 16781)

Finally, Solaris memory allocation seems far more sensitive than Linux. This has resulted in the discovery of several previously unknown bugs related to uninitialized variables that Linux handled silently. Note that this means, until these bugs are found and fixed, you may get segfaults.

At the time of this writing I have had a server up and running reasonably stable. However, there are large sections of Asterisk's codebase I do not use and
likely contain more of these uninitialized variable problems and associated potential segfaults.

bklang


Logan submitted these notes ...

I have Asterisk 1.0-RC1 running under Solaris 10 (s10_60) using a
Sipura SPA-3000 for local FXS and FXO ports. I built the binaries with
gcc 3.4.0 on a Solaris 9 box. I initially ran it on the Solaris 9 box
then moved it to the Solaris 10 box. Both boxes are multiprocessor sun
boxes. For my usage using only network based channels Asterisk
appears to run fine under Solaris.

I had to make a large number of minor changes to get it to build. I'll
look into submitting a patch to the developers. Until then here is a
list of the changes.

include/asterisk/lock.h:
added (very important to get properly
initialized recursive mutexes.)
#define AST_MUTEX_INIT_W_CONSTRUCTORS

utils.c:
arguments for gethostbyname_r are different.
res = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &herrno);
if (!res || !hp->hp.h_addr_list || !hp->hp.h_addr_list0)

apps/app_qcall.c:
replaced flock calls with fcntl calls. like
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
if (fcntl(fileno(fp), F_SETLK, &lock) == -1)

acl.c:
added #include and removed the static
initializer for __ourip (os version dependent.)

asterisk.c:
replaced local variable "sun" with "sunAddr" to avoid conflicting macro definition.

logger.c:
the syslog facility enumeration is different under solaris.
I punted and hardwired LOG_LOCAL0 for my use.

stdtime/localtime.c:
added
#define _POSIX_PTHREAD_SEMANTICS
#undef TM_ZONE
#undef TM_GMTOFF

channels/chan_mgcp.c:
replaced INADDR_NONE with (in_addr_t)(-1)

channels/chan_agent.c:
removed sched_yield() calls. they shouldn't be necessary anyway.

channels/chan_modem.c:
cfmakeraw and cfsetspeed don't exist under solaris. Someone should replace them with the appropriate calls to set the speed but I'm not using this channel so I just commented them out for my use.

replaced various references to u_int*_t with uint*_t.
They are both used but only uint*_t is defined under Solaris.

replaced various references to AF_LOCAL with AF_UNIX

defined BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN

removed #include from various source files

added an implementation of strsep which doesn't exist under solaris.
Initially considered replacing with strtok_r but there are too many occurrences.

added sun to the mac rule to note build all the /dev/dsp based stuff. intercom for example.

added -D_REENTRANT for sun.

added sun libs -lsocket -lresolv -ldl -lpthread -lthread

for sun switched -lncurses to -lcurses

changed sun ASTLINK to just -Wl

changed GREP to use /usr/xpg4/bin/grep

avoided -march flags in various build files

changed mkdep to use bash:
first line #!/usr/bin/bash

I'm probably forgetting some changes but that should be most of them.

logan
~/np~


Created by: benjk, Last modification: Tue 09 of Feb, 2010 (19:04 UTC) by bklang
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+