Was this page helpful?

Asterisk Cross-Compile for STLinux(NextVOD)

    交叉編譯

    asterisk 1.8
    ./configure \
    CC=sh4-linux-gcc \
    AR=sh4-linux-ar \
    CXX=sh4-linux-g++ \
    RANLIB=sh4-linux-ranlib \
    --host=sh4-linux --without-pwlib --disable-xmldoc
    
    asterisk 1.8 with dahdi
    ./configure \
    CC=sh4-linux-gcc \
    AR=sh4-linux-ar \
    CXX=sh4-linux-g++ \
    RANLIB=sh4-linux-ranlib \
    --host=sh4-linux --without-pwlib --disable-xmldoc --with-dahdi=/home/alang/STLinux/build_opt/dahdi/usr
    

    TIPs:

    --with-dahdi 這是 dahdi 的安裝目錄,底下必須包含 include/dahdi/*.h,如果仍然發生錯誤,檢查 configure.log,搜尋 dahdi ,檢查路徑是否正確

    asterisk 1.8 with iksemel (gtalk)

    for iksemel)

    wget http://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
    
    ./configure \
    CC=sh4-linux-gcc \
    AR=sh4-linux-ar \
    CXX=sh4-linux-g++ \
    RANLIB=sh4-linux-ranlib \
    --host=sh4-linux --prefix=/opt/iksemel
    
    make
    make install DESTDIR=/home/alang/STLinux_Cross-Compile/build_opt/iksemel

    for asterisk 1.8 with iksemel)

    ./configure \
    CC=sh4-linux-gcc \
    AR=sh4-linux-ar \
    CXX=sh4-linux-g++ \
    RANLIB=sh4-linux-ranlib \
    --host=sh4-linux --without-pwlib --disable-xmldoc --with-iksemel=/home/alang/STLinux_Cross-Compile/build_opt/iksemel/opt/iksemel
    
    Asterisk 1.8 with gmime (res_http_post.so)

    for gmime)

    wget http://ftp.acc.umu.se/pub/GNOME/sources/gmime/2.2/gmime-2.2.27.tar.gz
    tar xzf gmime-2.2.27.tar.gz
    

    先在程式目錄底下,新增 iconv-detect.h
    iconv-detect.h:

    /* This is an auto-generated header, DO NOT EDIT! */
    
    #define ICONV_ISO_INT_FORMAT "iso-%u-%u"
    #define ICONV_ISO_STR_FORMAT "iso-%u-%s"
    #define ICONV_10646 "iso-10646"
    

    編譯參數如下:

    ./configure \
    CC=sh4-linux-gcc \
    AR=sh4-linux-ar \
    CXX=sh4-linux-g++ \
    RANLIB=sh4-linux-ranlib \
    CROSS_COMPILE=1 \
    PKG_CONFIG="/opt/STM/STLinux-2.3/host/bin/pkg-config" \
    CPPFLAGS="-I/opt/STM/STLinux-2.3/devkit/sh4/target/usr/include" \
    LDFLAGS="-L/opt/STM/STLinux-2.3/devkit/sh4/target/usr/lib" \
    ac_cv_have_iconv_detect_h=yes \
    --host=sh4-linux
    
    make
    make install DESTDIR=/home/alang/STLinux_Cross-Compile/build_opt/gmime 
    

    TIPs:

    - 執行 configure 錯誤 configure: error: Copy target system's iconv-detect.h to . and configure with ac_cv_have_iconv_detect_h=yes
    Ans: 必須加上 ac_cv_have_iconv_detect_h=yes

    - 執行 make 錯誤 /usr/lib/libgobject-2.0.so: could not read symbols: File in wrong format
    Ans: 即使指定了 CPFLAGS, LDFLAGS 路徑,編譯時仍會去尋找 /usr/lib 目錄,解法是去修改該模組的定義檔
    /opt/STM/STLinux-2.3/devkit/sh4/target/usr/lib/libgobject-2.0.la
    修改最後一行
    libdir='/opt/STM/STLinux-2.3/devkit/sh4/target/usr/lib'

    - 如果 ./configure 成功,會輸出以下訊息:
    --------------------------------------------------------
    Configuration:

      Source code location: .
      Install prefix:       /usr/local
      Compiler:             sh4-linux-gcc

      Profiling enabled:    no

      Large file support:   no
      rfc2047 workarounds:  no
      Console warnings:     no

      Mono bindings:        no
    ------------------------------------------------------------

    - 執行 make 錯誤 /usr/lib/libglib-2.0.so: could not read symbols: File in wrong format
    Ans: 試過各種有關 Library 的路徑參數都沒效,用笨方法
    cd /usr/lib
    mv libglib-2.0.so libglib-2.0.so.bak
    ln -s /opt/STM/STLinux-2.3/devkit/sh4/target/usr/lib/libglib-2.0.so libglib-2.0.so
    切記: 做完編譯後,記得改回來。

    for asterisk 1.8 with gmime)

    編譯 asterisk 之前,先新增一個 gmime 的路徑,否則會發生 configure 錯誤

    cd /home/alang/STLinux_Cross-Compile/build_opt/gmime
    cd usr/local/include
    ln -s gmime-2.0/gmime gmime 
    

    還有這

    到 gmime 安裝目錄的 include 目錄
    cd /home/alang/STLinux_Cross-Compile/build_opt/gmime/usr/local/include
    
    將目錄 /opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/glib-2.0/ 與 /opt/STM/STLinux-2.3/devkit/sh4/target/usr/lib/glib-2.0/include/ 內有關的檔案都建立連結
    ln -s /opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/glib-2.0/gio ./
    ln -s /opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/glib-2.0/glib ./
    ln -s /opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/glib-2.0/glib.h ./
    ln -s /opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/glib-2.0/glib-object.h ./
    ln -s /opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/glib-2.0/gobject ./
    
    ln -s /opt/STM/STLinux-2.3/devkit/sh4/target/usr/lib/glib-2.0/include/glibconfig.h ./

    編譯 asterisk

    ./configure \
    CC=sh4-linux-gcc \
    AR=sh4-linux-ar \
    CXX=sh4-linux-g++ \
    RANLIB=sh4-linux-ranlib \
    LDFLAGS="-L/home/alang/STLinux_Cross-Compile/build_opt/gmime/usr/local/lib" \
    --host=sh4-linux --without-pwlib --disable-xmldoc --with-gmime=/home/alang/STLinux_Cross-Compile/build_opt/gmime/usr/local
    

    TIPs:

    - 如何確認 --with-gmime 路徑是正確?
    檢查 configure.log,搜尋 GMIME_DIR, GMIME_INCLUDE, GMIME_LIB 沒有一個昰空白

    - 如何確認 CPPFLAGS, LDFLAGS 要加哪些路徑?
    檢查 configure.log,搜尋 gmime,注意那些有缺檔的訊息

    編譯 Asterisk

    make menuselect
    

    按 x 儲存離開

    make 2>&1 | tee make.log
    make install DESTDIR=/home/alang/STLinux/build_opt/asterisk18_sh4
    make samples DESTDIR=/home/alang/STLinux/build_opt/asterisk18_sh4
    

    將 /home/alang/STLinux/build_opt/asterisk18_sh4 所有內容複製到網樂通機上盒。

    另外,Asterisk 執行時還需要有 OpenSSL 的函式庫,所以必須將 OpenSSL 移植到機上盒。

    移植 OpenSSL

    因為 OpenSSL 可以透過 stmyum 方式來安裝,所以不需要做交叉編譯。

    搜尋 openssl 套件

    cd /opt/STM/STLinux-2.3/host/bin
    ./stmyum search openssl 
    

    stlinux23-sh4-openssl.sh4                1.0.0j-20              installed
    Matched from:
    stlinux23-sh4-openssl
    The OpenSSL Project is a collaborative effort to develop a robust,
    commercial-grade, fully featured, and Open Source toolkit implementing the
    Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1)
    protocols as well as a full-strength general purpose cryptography library.
    The project is managed by a worldwide community of volunteers that use the
    Internet to communicate, plan, and develop the OpenSSL tookit and its related
    documentation.

    OpenSSL is based on the excellent SSLeay library developed from Eric A.
    Young and Tim J. Hudson.  The OpenSSL toolkit is licensed under an
    Apache-style licence, which basically means that you are free to get and
    use it for commercial and non-commercial purposes.

    This package contains the base OpenSSL cryptography and SSL/TLS
    libraries and tools.
    http://www.openssl.org/

    NextVOD 的設定

    asterisk 啟動檔

    /etc/init.d/asterisk.sh

    #!/bin/sh
    # Start up file for Asterisk for NextVOD
    
    # Author: alang by 2012-10-13
    # Updated: 2012-10-14
    #
    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    
    AST_CONFIG=/etc/asterisk
    DAEMON=/usr/sbin/asterisk
    
    start() {
        # Check if Asterisk is already running.  If it is, then bug out, because
        # starting safe_asterisk when Asterisk is running is very bad.
        VERSION=`${DAEMON} -rx 'core show version'`
        if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
           echo "Asterisk is already running."
           exit 0
        fi
    
        [ ! -d /mnt/usb/asterisk_log ] && mkdir /mnt/usb/asterisk_log
        $DAEMON -C $AST_CONFIG/asterisk.conf >/dev/null 2>/dev/null
    }
    
    stop() {
        killall -9 asterisk
    }
    
    case $1 in
         start) start ;;
    
         stop)  stop ;;
    
         *) cat <<EOF;;
    Syntax: /etc/init.d/asterisk.sh [command]
    
    Available commands:
       start   Start the service
       stop    Stop the service
    EOF
    esac

    /etc/init.d/rcSBB

    ...
    /etc/init.d/asterisk.sh start 
    

    FAQ

    Q: configure 時出現錯誤

    checking for GNU make... Not Found
    configure: error: *** Please install GNU make.  It is required to build Asterisk!

    Ans: sudo apt-get install build-essential

    Q: make menuselect 發生錯誤

    No menuselect user interface found. Install ncurses,
    newt or GTK libraries to build one and re-rerun
    './configure' and 'make menuselect'.

    Ans:

    1. 安裝 ncurses 開發套件
      sudo apt-get install libncurses5-dev
    2. 如果還是一直出現相同錯誤,在 ./configre 前先執行一次 make distclean。
    Was this page helpful?
    標籤 (Edit tags)
    • No tags
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core