Warning: The following is a filthy dirty hack. Read at your own risk.
A few weeks ago at AstriCon, I saw two really cool things. I saw Asterisk running on a wide range of < $100 routers (including one loaded on the back of a Roomab). I also saw the new Digium Asterisk appliance running the new GUI framework. This got me to wondering if version 1.4 with it's brand new GUI could be shoe-horned onto a WRT.
A quick perusal of the OpenWRT hardware list brought me to the Linksys WRTSL54GS, the unfortunately named but relatively powerful SOHO router with USB (ostensibly for storage). The WRTSL54GS (hereafter the SL54 -- life is too short to type really long, awkward product names) appears to have complete OpenWRT support and the USB storage made it much easier to fit in ALL of Asterisk 1.4. After a few days of playing with the (already outdated) SDK, I figured I could give Asterisk 1.4 a try.
From a build perspective, Asterisk 1.4 is completely different from its predecessors. Previous versions used only a makefile and required nothing more than the ancient mantra: 'make; make install'. 1.4 adds the features and complexities of autoconf and menuselect to the mix. On standard Linux and standard hardware both additions are a step forward. On the OpenWRT SDK they make things somewhat more complex.
Another confession: I've no real experience with the package management system and I still don't have the Makefile in the package folder properly packing everything into an ipk. I followed the instructions in the SDK guide: I created a package folder and a Makefile which downloaded Asterisk 1.4 beta 3. The initial download worked but things went down hill from there. Autoconf worked (or at least appeared to work) and produced a makefile, but the compile died as soon as it tried to build menuselect.
The build fails as it attempts to generate the menuselect executable. This makes some sense -- the executable needs to be built for the host, not the target. Fortunately the system seems to be willing to continue where it left off, so all you really have to do is manually generate the executable. First, change directory into the menuselect directory:
/path/to/sdk/OpenWrt-SDK-Linux-i686/build_mipsel/asterisk-1.4.0-beta3/menuselect
Now execute the mantra here: './configure; make' This will build the menuselect executable. This actually creates all the basics but you can tweak your build now by dropping back to the asterisk-1.4.0-beta3 directory and executing 'make menuselect'. I didn't make any massive changes: I turned off a number of channels (phone, mgcp, skinny), a number of codecs (specifically LPC10 and iLBC -- both of which require an FPU to work), and anything else I don't plan on using on my SL54. I didn't use any optimizations (though I'm sure some of them would help -- something to try in the future). I also nixed the sms application and the snmp resource modules (after discovering they had dependencies which made things fail).
Once the meuselect process is done, go back to the SDK folder and start the process rolling again with 'make'. I found (after a big dump of error messages) that I had to go into the utils folder and remove smsq from the Makefile. Surely there's a better way of handling this but I don't use sms, so it was not worth fighting over. Again restart the build. Mine ran until it hit res_crypto where it died missing OpenSSL. Funny, it seemed to find OpenSSL during the configure stage...
It seems that much of the build process gets off track due to missing libraries (or apparently missing libraries). I solved this probably the hard way: I edited the 'makeopts' file (located in the Asterisk source folder under build_mipsel) and added the full include path and library path to the various makeopts directives. Here are the changes I made:
SSL_INCLUDE=
SSL_LIB=-lssl -lcrypto
changes to:
SSL_INCLUDE=-I/usr/src/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include
SSL_LIB=-L/usr/src/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -lssl -lcrypto
I had to do roughly the same thing for:
ZLIB_INCLUDE
ZLIB_LIB
CURL_LIB (which you have to build yourself if you really want it -- i just nixed func_curl)
CURSES_INCLUDE
CURSES_LIB
Things really get fun when you hit the next error: libedit in the Asterisk mail/editline folder. For some reason the editlib's autoconf script fails to find the necessary header files and libs for termcap. I wound up running the configure script in the host environment, then changing out a few options:
-CC = gcc
+CC = /usr/src/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc
-CFLAGS = -Wall -pipe -g3
+CFLAGS = -O6 -I/usr/src/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include
Onec I got past this it was actually pretty much down hill. Instead of trying to figure out the full ipk install, I just copied all of the binary files into a series of directories on my USB key. I created an /etc/asterisk directory on the SL54 and created an asterisk.conf that pointed to the folders on my USB key. I created a symlink for the Asterisk binary from the /usr/sbin folder.
After all that I had to go through and remove a number of modules that caused issues -- DUNDi seemed to hang things up. I also learned the hard way that you can't create pipes on a Fat32 partition -- you have to map the run directory to a Linux native partition so that the asterisk.ctl pipe can be created.
More (and perhaps more coherent) later. I'll give some thoughts on the GUI when i've had a chance to play with it a bit more.
Thanks,
Steve