[asterisk-dev] asterisk-addons

Tzafrir Cohen tzafrir.cohen at xorcom.com
Sat Jan 30 16:37:23 CST 2010


On Sat, Jan 30, 2010 at 12:06:24PM +0100, Olle E. Johansson wrote:
> 
> 30 jan 2010 kl. 11.46 skrev Tzafrir Cohen:
> 
> > On Sat, Jan 30, 2010 at 04:04:26PM +0530, Bhrugu Mehta wrote:
> >> hi,
> >> thnks for reply,
> >> what is build system?
> > 
> > As I mentioned, the makefiles, Makefile*
> > 
> > Are you familiar with the utility 'make'?
> > 
> In this case specifically the configure system. In short:
> 
> 1. To build Asterisk, you start with running "configure"
> 2. Configure scans your system and detects various pieces of software that Asterisk may use or require
> 3. Menuselect use this input to build the menu system.
>     If a third-party library is missing, menuselect disables the module. 
>     This is what you saw in the res_config_mysql.c file - the instructions for menuselect.
> 4. The actual build is done by make, which also gets input from configure on
>     how to build and link Asterisk on your platform.
> 
> So in order to add oracle, you need to add Oracle library detection to 
> configure and add the needed instructions in your source code files for menuselect.
> I believe there's documentation on this either on Asterisk.org or in doxygen. 
> Russell has made several presentations on this, which should be available if you 
> google on the keywords given above.

I don't have a time to review the build system right now, but I'll just
add this:

The library dependency is used not only in configure time but also at
build time. Asterisk's configure script detect which extra CFLAGS (e.g.:
extra include pathes) and which LDFLAGS (extra libraries, extra library
pathes: -l, -L) are added to the build commands.

If a module declares it depends[1] on a 'foo', Asterisk will add
foo_CFLAGS to the compilation command and foo_LDFLAGS to the link
command. These flags are taken from a file that is generated by the
configure script: makeopts. The configure script produces it from the
template file makeopts.in . You'll see there "FOO=1:1" if we have 'foo'.

The configure script also writes in build_tools/menuselect-deps the
libraries it found. This is again generated from the template
build_tools/menuselect-deps.in .

The requires module dependencies are added to the file
menuselect.makedeps, which menuselect generates. If app_bar depends on
foo and baz, you're supposed to see there the line:

  MENUSELECT_DEPENDS_app_bar=FOO BAZ

Asterisk will then add to app_bar.c's compilation FOO_CFLAGS and
BAR_CFLAGS and will add to app_bar.so's linking FOO_LDFLAGS and
BAZ_LDFLAGS.


So to add extra CFLAGS / LDFLAGS you can:

1. Manually edit the Makefile in the respective subdirectory. To see
some examples of that:

  grep CFLAGS */Makefile

That's the quickest and dirtiest way.

2. Properly add support to your library to the configure script. If it
provides a -config script or uses pkg-config it should be simple.
Otherwise it might take some work.

You'll also need to add the proper entries to those two .in files I
mentioned.

3. An uglier and slightly quicker variation of (2) - skip all the
autoconf stuff. Just edit the two template files to include the values
you actually need, and those values will be copied verbatim. Naturally
it is up to you to make sure the requires library is actually available.

Obviously (2) is the one required if you want to submit a patch.

Also note that as of the next release (1.8, but already in current
trunk) the asterisk-addons have been removed and merged into the
Asterisk tarball, in the subdirectory addons (Hmmm.. where is the mysql
stuff?)

[1] also: if a module "use"-s a library and it is available

-- 
               Tzafrir Cohen
icq#16849755              jabber:tzafrir.cohen at xorcom.com
+972-50-7952406           mailto:tzafrir.cohen at xorcom.com
http://www.xorcom.com  iax:guest at local.xorcom.com/tzafrir



More information about the asterisk-dev mailing list