PDA

View Full Version : HOWTO: Compile Asterisk from scratch


fizgig
February 26th, 2006, 07:01 PM
I took notes on what I did so I could do it later. Maybe someone else might find them useful. They might not be the most ideal - I'm not an expert but please feel free to comment and I'll update this message.

0. Edit the /etc/apt/sources.list file to remove the # signs before the lines that begin with # deb http to activate them and then do apt-get update.

1. Install Packages:
apt-get install sendmail zlib1g-dev libssl-dev ncurses-dev libnewt-dev gcc-3.4 subversion openssh-server build-essential linux-source-2.6.12 (or whatever kernel you have)

2. Prepare Linux kernel source
cd /usr/src
tar xvjf linux-source* (Extracts the files from the zip file)
rm linux-source-2.6.12.tar.bz2 (Don't need the zip anymore)
ln -s linux-source-2.6.12 linux (makes /usr/src/linux point to /usr/src/linux-source-2.6.12)
cd linux
cp /boot/config-2.6.whatever .config (copies the config file that was used to compile your kernel into the /usr/src/linux dir)
make menuconfig then exit and save config
uname -r (examine what comes after 2.6.12 For example, I had 2.6.12-9-386)
vi /usr/src/linux/Makefile
Go to the EXTRAVERSION line and make it like so:
EXTRAVERSION=-9-386
make modules_prepare
ln -s /usr/src/linux /lib/modules/`uname -r`/build

3. Get Asterisk Packages
cd /usr/src
svn checkout http://svn.digium.com/svn/asterisk/branches/1.2 asterisk-1.2
svn checkout http://svn.digium.com/svn/zaptel/branches/1.2 zaptel-1.2
svn checkout http://svn.digium.com/svn/libpri/branches/1.2 libpri-1.2
svn checkout http://svn.digium.com/svn/asterisk-sounds/branches/1.0 asterisk-sounds-1.0


4. Compile Stuff
-=libpri=-
cd /usr/src/libpri-1.2
make clean
make
make install
-=Zaptel Modules=- (If you're going to use zaptel hardware to connect to PSTN)
cd /usr/src/zaptel-1.2
Change anything in /usr/src/zaptel/zconfig.h if you need to (I didn't need to)
make clean
make linux26
make zttool
make install
-=Asterisk=-
cd /usr/src/asterisk-1.2
make clean
make mpg123

note: This doesn't work for me as of 2-20-07. I had to go into the mpg123 directory myself and type:

make CC=gcc LDFLAGS= OBJECTS='decode_i386.o dct64_i386.o decode_i586.o audio_oss.o term.o' CFLAGS='-DI386_ASSEM -DPENTIUM_OPT -DREAL_IS_FLOAT -DLINUX -DREAD_MMAP -DOSS -DTERM_CONTROL -Wall -O2 -m486 -fomit-frame-pointer -funroll-all-loops -finline-functions -ffast-math' mpg123-make
make
make install
make samples (if you want sample config files put into /etc/asterisk)
-=Asterisk-Sounds=-
cd /usr/src/asterisk-sounds-1.0
make install

5. Edit udev
vi /etc/udev/udev.rules

Stick the paragraph below somewhere

# Section for zaptel device
KERNEL="zapctl", NAME="zap/ctl"
KERNEL="zaptimer", NAME="zap/timer"
KERNEL="zapchannel", NAME="zap/channel"
KERNEL="zappseudo", NAME="zap/pseudo"
KERNEL="zap[0-9]*", NAME="zap/%n"

6. That's the installation part. Go ahead and reboot. Then, if you have some zaptel piece of hardware installed, try lsmod | grep zap and see if the two modules are already installed.

7. Configure it!

================
Excelent source of asterisk info: The Free Asterisk O'Reilly Book (http://voipspeak.net/images/stories/orielly/AsteriskTFOT.zip)
A good forum for questions: http://forums.digium.com/edit: removed extra steps to manually compile mpg123 that weren't necessary.
edit2: removed tar extraction step since svn brings the files over untarred. (duh)
edit3: Added some explanation notes.
edit4: Added mpg123 compile note 2-20-07

kennedymat
March 9th, 2006, 08:02 PM
I'm having a problem that I'm guessing is udev related.

I built the zaptel drivers successfully and rebooted using the directions found here:

http://www.voip-info.org/wiki/index.php?page=Asterisk+Zaptel+Installation

When I enter

modprobe zaptel

I receive:

FATAL: Module zaptel not found.

I am using Ubuntu 5.1, and I believe that is the nature of the problem.

In the /etc/udev/rules.d folder, there was no file named 50-udev.rules. Instead, there was a symbolic link to ../udev.rules, and in the file ../udev.rules I found that the zaptel definitions had already been included, except that they used an "==" in the KERNEL statements rather than a single "=". I tried modifying them, adding new ones, etc., but nothing has worked.

I did some googling and decided to copy the ../udev.rules to the /etc/udev/rules.d folder under the name 50-udev.rules. I rebooted and it still didn't work.

So, I moved the file 50-udev.rules up to the parent directory and created a symbolic link to the new location named 50-udev.rules, but it still doesn't work.

I have confirmed that the file /etc/modprobe.d/zaptel is the output from my zaptel build.

Clearly, I'm missing a very simple point, but I just can't find it.

Thanks in advance for any help.

fizgig
March 9th, 2006, 08:05 PM
Well, if you didn't do it my way I don't think I'm smart enough to help you.

kennedymat
March 9th, 2006, 08:59 PM
fizgig,

You underestimate your abilities! By closely examining what you did and comparing to what I did, then doing some trial and error, I found my issue.

In the other tutorial, it says:

For a Linux 2.6 kernel you may need to:
modify the EXTRAVERSION statement in Makefile so it matches what you see in: cat /proc/version

To clarify that, if your cat/proc/version says (for example):

Linux version 2.6.12-mytestbuild (root@agpcserver) (gcc version 3.4.5 20050 809 (prerelease) (Ubuntu 3.4.4-6ubuntu8.1)) #1 Wed Mar 8 18:01

Then the line in your Makefile should be:

EXTRAVERSION =-mytestbuild

It was your example that saved me.

Thanks!

fizgig
March 9th, 2006, 09:36 PM
sweet! So I helped someone!

kennedymat
March 10th, 2006, 07:16 PM
I am sure I am missing something very easy.

I have installed my TDM400 with 4 FXO ports to connect to loopstart lines.

I've got the drivers loaded, the zttool tells me it sees the 4 channels, but asterisk is not recognizing them.

One clue is that the output from my asterisk console never indicates that asterisk is attempting to parse /etc/asterisk/zapata.conf. If it never parses it, it will never see the channels.

Any hints?



From /etc/zaptel.conf:

fxsls=1-4
loadzone = us
defaultzone=us

From /etc/asterisk/zapata.conf:

[trunkgroups]
[channels]
usercallerid=yes
hidecallerid=no
callwaiting=no
threewaycalling=yes
transfer=yes
echocancel=yes
echotraining=yes

context=PublicNetworkRingin
signalling=fxs_ls

channel => 1
channel => 2
channel => 3
channel => 4

In the Asterisk console, if I type:

show channels

I get:

Channel (Context Extension Pri ) State Appl. Data
0 active channel(s)


In the zttool, I do see the card:

Alarms Span │
│ OK Wildcard TDM400P REV I Board 1 ▒ │


In the zttool, when I look at the channels, they seem to be there, but no amount of plugging in, unplugging, or ringing in seems to change the status;


Current Alarms: No alarms. │ │
│ │ Sync Source: Internally clocked │ ▒ │
│ │ IRQ Misses: 0 │ ▒ │
│ │ Bipolar Viol: 0 │ ▒ │
│ │ Tx/Rx Levels: 0/ 0 │ ▒ │
│ │ Total/Conf/Act: 4/ 4/ 1 │ ▒ │
│ │ ┌──────┐ │ ▒ │
│ │ 1234 │ Back │ │ ▒ │
│ │ TxA ---- └──────┘ │ ▒ │
│ │ TxB ---- │ ▒ │
│ │ TxC ---- │ │
│ │ TxD ---- │ │
│ │ ┌──────┐ │ │
│ │ RxA ---- │ Loop │ │ │
│ │ RxB ---- └──────┘ │ │
│ │ RxC ---- │ │
│ │ RxD ----


On the physical card, all four green LEDs are lit all of the time.

If I ring in on any of the lines, Asterisk completely ignores the ringin.

From /etc/asterisk/extensions.conf:

[PublicNetworkRingin]
exten => s,1,answer()
exten => s,2,echo()

kennedymat
March 10th, 2006, 07:42 PM
OK Fizgig, you win.

I see now that the asterisk I got from Ubuntu doesn't include chan_zap. It looks like I need to compile the thing myself.

Ubuntu was my first try at Linux, and for all the nice things people say about it I think I'll probably try a different distro next time around.

The feature I THOUGHT I would like best was the ability to simply grab packages and have them work ALMOST right out of the box. Instead, I've spent hours fixing things that would have probably worked the first time if I had just built them myself inside a more standard Linux.

I guess that's the open source way. Read, try, cry, repeat.

fizgig
March 10th, 2006, 11:55 PM
Well, good luck in your linux adventure. I will say that I've tried a lot of distros (debian, mepis, xandros, mandrake, redhat) and I always keep coming back to Ubuntu.

Anyhow, the zaptel modules need to be compiled against the specific kernel you have installed. While ubuntu does include a few custom modules to save you from compiling, I think zaptel modules are a little too out there for a regular distribution to supply.

Besides, the zaptel code keeps changing so it's easier to use the subversioning system to update them directly from the source instead of waiting for the packager to make them. A compile takes about 15 seconds so I don't see it as a big deal.

Each to his own I guess.

p.s. you might want the line that reads fxsls=1-4 to be fxsks-1-4

kennedymat
March 13th, 2006, 09:03 PM
Thanks for the info.

It's not the zaptel drivers that I'm having trouble with, it's that the asterisk that you get from Ubuntu using Synaptic Package Manager does not include the chan_zap module in the asterisk build. So, the drivers are running great, but asterisk never goes looking for the channels!

In terms of using kewlstart instead of loopstart, I'm an old-school telephony guy, so I'm sticking with what I know until it is working, then I'll try the new stuff.

Thanks again. I'm working my way through your tutorial now.

kennedymat
March 14th, 2006, 09:06 PM
Hey fizgig,

I'm trying it your way and have followed everything step-by-step three times now. Each time I try to do:

make mpg123

I get all of the following, and then nothing compiles correctly afterward. By the way, I actuall do "sudo make mpg123", but I wouldn't think that would be the difference.

It appears to me that it is compiling and tryint to optimize for an Intel system (I have an AMD-64), so I'm guessing I need to do something like 'make mpg123 amd-64', but I don't see that option.

Any hints?


[ -f mpg123-0.59r.tar.gz ] || wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz
[ -d mpg123-0.59r ] || tar xfz mpg123-0.59r.tar.gz
make -C mpg123-0.59r linux
make[1]: Entering directory `/usr/src/asterisk-1.2/mpg123-0.59r'
make CC=gcc LDFLAGS= \
OBJECTS='decode_i386.o dct64_i386.o decode_i586.o \
audio_oss.o term.o' \
CFLAGS='-DI386_ASSEM -DPENTIUM_OPT -DREAL_IS_FLOAT -DLINUX \
-DREAD_MMAP -DOSS -DTERM_CONTROL\
-Wall -O2 -m486 \
-fomit-frame-pointer -funroll-all-loops \
-finline-functions -ffast-math' \
mpg123-make
make[2]: Entering directory `/usr/src/asterisk-1.2/mpg123-0.59r'
make[3]: Entering directory `/usr/src/asterisk-1.2/mpg123-0.59r'
gcc -DI386_ASSEM -DPENTIUM_OPT -DREAL_IS_FLOAT -DLINUX -DREAD_MMAP -DOSS -DTERM_CONTROL -Wall -O2 -m486 -fomit-frame-pointer -funroll-all-loops -finline-functions -ffast-math -c -o mpg123.o mpg123.c
mpg123.c: In function ‘shuffle_files’:
mpg123.c:225: warning: implicit declaration of function ‘time’
mpg123.c: At top level:
mpg123.c:480: warning: initialization makes integer from pointer without a cast
gcc -DI386_ASSEM -DPENTIUM_OPT -DREAL_IS_FLOAT -DLINUX -DREAD_MMAP -DOSS -DTERM_CONTROL -Wall -O2 -m486 -fomit-frame-pointer -funroll-all-loops -finline-functions -ffast-math -c -o common.o common.c
gcc -DI386_ASSEM -DPENTIUM_OPT -DREAL_IS_FLOAT -DLINUX -DREAD_MMAP -DOSS -DTERM_CONTROL -Wall -O2 -m486 -fomit-frame-pointer -funroll-all-loops -finline-functions -ffast-math -c -o decode_i386.o decode_i386.c
gcc -DI386_ASSEM -DPENTIUM_OPT -DREAL_IS_FLOAT -DLINUX -DREAD_MMAP -DOSS -DTERM_CONTROL -Wall -O2 -m486 -fomit-frame-pointer -funroll-all-loops -finline-functions -ffast-math -c -o dct64_i386.o dct64_i386.c
as -o decode_i586.o decode_i586.s
decode_i586.s: Assembler messages:
decode_i586.s:44: Error: suffix or operands invalid for `push'
decode_i586.s:45: Error: suffix or operands invalid for `push'
decode_i586.s:46: Error: suffix or operands invalid for `push'
decode_i586.s:47: Error: suffix or operands invalid for `push'
decode_i586.s:67: Error: suffix or operands invalid for `push'
decode_i586.s:70: Error: suffix or operands invalid for `push'
decode_i586.s:81: Error: suffix or operands invalid for `push'
decode_i586.s:83: Error: suffix or operands invalid for `push'
decode_i586.s:86: Error: suffix or operands invalid for `push'
decode_i586.s:161: Error: suffix or operands invalid for `pop'
decode_i586.s:211: Error: suffix or operands invalid for `pop'
decode_i586.s:296: Error: suffix or operands invalid for `pop'
decode_i586.s:315: Error: suffix or operands invalid for `pop'
decode_i586.s:316: Error: suffix or operands invalid for `pop'
decode_i586.s:317: Error: suffix or operands invalid for `pop'
decode_i586.s:318: Error: suffix or operands invalid for `pop'
make[3]: *** [decode_i586.o] Error 1
make[3]: Leaving directory `/usr/src/asterisk-1.2/mpg123-0.59r'
make[2]: *** [mpg123-make] Error 2
make[2]: Leaving directory `/usr/src/asterisk-1.2/mpg123-0.59r'
make[1]: *** [linux] Error 2
make[1]: Leaving directory `/usr/src/asterisk-1.2/mpg123-0.59r'
make: *** [mpg123] Error 2

kennedymat
March 15th, 2006, 01:20 AM
I pushed through the process and ran into a few more bumps along the way, but finally got Asterisk up and running. Unfortunately, I didn't take very good notes along the way so I don't want to post my steps here.

Thanks fizgig for your help.

I never did get mpg123 compiled, so I'll need to go find out what that particular module does.

fizgig
March 15th, 2006, 07:46 AM
Well, I just noticed that I have an extra unneccessary step in my steps since make mpg123 not only downloads the source for mpg123 and extracts it, it also compiles it for you so I just removed the step where I recompile.

I did a search on google (http://www.google.com/search?hl=en&q=compile+mpg123+amd+64&btnG=Google+Search) about your problem and found this (http://www.voip-info.org/wiki-Asterisk+mpg123+redhat) where somebody says that mpg123 doesn't compile on AMD64. I found a few other similar posts so it might be that you'll need a patch to get that version to compile. I wasn't able to find a patch like that after 5 minutes of searching but you might have better luck than me.

fizgig
March 18th, 2006, 07:28 PM
I pushed through the process and ran into a few more bumps along the way, but finally got Asterisk up and running. Unfortunately, I didn't take very good notes along the way so I don't want to post my steps here.

Thanks fizgig for your help.

I never did get mpg123 compiled, so I'll need to go find out what that particular module does.

mpg123 allows you to play mp3's. Nothing more.

miggl
March 28th, 2006, 09:45 PM
Thanks for the walkthrough fizgig! I finally got everything installed thanks to you !!!! Great help!

I would like to post this help on my blog, since it helped me out tons (with your permission of course).

Thanks,
Mike

fizgig
March 29th, 2006, 12:33 AM
So glad I could help! Feel free to post it wherever. Say you wrote it. Improve it. Doesn't matter to me!

honeydew
April 6th, 2006, 07:17 PM
haruumm.. got asterisk up and running and can call into the asterisk box from my did.. but I cant for the life of me figure out how to set it up to dail out.. Im using the iax protocol.. hrmm.. Ill post some output later.. does can anyone post up there iax.confs? if they are running softphones?

miggl
April 10th, 2006, 10:46 PM
So glad I could help! Feel free to post it wherever. Say you wrote it. Improve it. Doesn't matter to me!

Thanks, I'll have you in there with full credit, of course!

Hey, another thing: I've been able to install it. But now what? I'll admit, I like GUIs... is there a config GUI that can get me started? Or is it really all command-line based?

Thanks again!

fizgig
April 11th, 2006, 01:34 AM
Well, if you like gui's, then you'll probably want to install asterisk@home (http://asteriskathome.sourceforge.net/). It's much easier to use with its included gui but it's based on centos so you'll have to learn how that works (centos=free redhat).

I didn't like the gui since it forces you into a certain template without your own custom stuff. Dialplans aren't hard to learn. Check out the link to the free O'reilly book about Asterisk you can download that I posted at the end of my first post. It walks you through it and you get to really understand how it works.

Cavaco
April 20th, 2006, 11:51 AM
Does the module exist in /lib/modules/XXXXXX/misc where xxx is the kernel headers you used ?

Cavaco
April 20th, 2006, 11:53 AM
Can you be more specific on your setup ?

fizgig
April 20th, 2006, 12:16 PM
huh? specific? Can you be more specific about what you want me to be specific about?

Also, I'll look into your modules question when I get home.

disterics
May 10th, 2006, 03:15 AM
The mpg123 patch for amd64 can be found here:
http://www.gentoo.org/cgi-bin/viewcvs.cgi/media-sound/mpg123/files/mpg123-0.59r-amd64.diff

Download it into a clean mpg123-0.59r directory.
cd into the directory

user@box: patch < mpg123-0.59r-amd64.diff
user@box: make linux-x86_64

ncksm
March 2nd, 2007, 12:34 PM
Does anyone have this patch, cause the link is dead. Thanks

disterics
March 2nd, 2007, 08:25 PM
I attached it as a text file. Not sure how relevant it is at the moment though.

ncksm
March 3rd, 2007, 05:17 PM
Thanks. It's working now !!!