#!/bin/sh
#linphone-on-arm
#编译安装库
#使用ROOT用户执行
LINPHONE_DIR=`pwd`
################################## 环境变量到声明
echo "环境变量到声明" ||exit
export PREFIX=/usr/local ||exit
export HOSTTPL=arm-none-linux-gnueabi ||exit
export INSTALLDIR=/home/linux/linphone/install ||exit
#################################### 解压所有文件
echo "解压所有文件"
ls *.tar.gz | xargs -n1 tar xzvf ||exit
#####################################安装工具
yum install libtool automake autoconf -y ||exit
#################################tslib
echo "tslib" ||exit
cd tslib* ||exit
chmod +x autogen.sh ||exit
./autogen.sh ||exit
echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.cache ||exit
./configure --prefix=$PREFIX --host=$HOSTTPL --cache-file=arm-linux.cache ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
#######################echo "libiconv"
echo "libiconv" ||exit
cd libiconv* ||exit
./configure --prefix=$PREFIX --host=$HOSTTPL --with-gnu-ld ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
##############################SDL
echo "SDL" ||exit
cd SDL* ||exit
./configure --prefix=$PREFIX --host=$HOSTTPL --build=i386 --with-gnu-ld --disable-video-nanox --disable-video-qtopia --disable-pulseaudio --disable-video-photon --disable-video-ggi --disable-video-svga --disable-video-aalib --disable-video-dummy --disable-video-dga --disable-arts --disable-esd --disable-alsa --disable-video-x11 --disable-nasm --enable-joystick --enable-input-tslib --enable-video-fbcon CPPFLAGS="-I$INSTALLDIR/usr/local/include" LDFLAGS="-L$INSTALLDIR/usr/local/lib -lts -liconv" ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
###########################################
yum install intltool -y ||exit
#################################ncurses
echo "ncurses" ||exit
cd ncurses* ||exit
./configure --prefix=$PREFIX --host=$HOSTTPL --with-shared --with-gnu-ld ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
######################################readline
echo "readline" ||exit
cd readline* ||exit
./configure --prefix=$PREFIX --host=$HOSTTPL --disable-static ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
##############################################libosip2
echo "libosip2" ||exit
cd libosip2* ||exit
./configure --prefix=$PREFIX --host=$HOSTTPL --with-gnu-ld --disable-static ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
#############################################libogg
echo "libogg" ||exit
cd libogg* ||exit
./configure --prefix=$PREFIX --host=$HOSTTPL --with-gnu-ld ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
rm -rf $INSTALLDIR$PREFIX/lib/*.la ||exit
###对于la文件和intltool的关系请自行查阅相关资料。
################################################libeXosip2
cd libeXosip2* ||exit
./configure --prefix=$PREFIX --host=$HOSTTPL --with-gnu-ld --disable-static OSIP_CFLAGS="-I$INSTALLDIR/usr/local/include" OSIP_LIBS="-L$INSTALLDIR/usr/local/lib -losip2 -losipparser2" ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
#此处编译若出现找不到关于openssl相关链接符号信息,请将交叉编译工具链中openssl的相关文件删除即可,否则请移植完整的openssl并确保正确。(update 2013.1.2)
####################################################speex
echo "speex" ||exit
cd speex* ||exit
./configure --prefix=$PREFIX --host=$HOSTTPL --with-gnu-ld --disable-static --enable-fixed-point --enable-arm-asm --with-ogg="$INSTALLDIR/usr/local" ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
#######################################################libav
echo "libav" ||exit
cd libav* ||exit
./configure --prefix=$PREFIX --enable-cross-compile --cross-prefix=arm-none-linux-gnueabi- --arch=armv4 --target-os=linux ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
# 其中--arch=armv4请修改为所开发平台对应的信息
cd .. ||exit
########################################################libvorbis
echo "libvorbis" ||exit
sleep 5
cd libvorbis* ||exit
./configure --prefix=$PREFIX --host=$HOSTTPL --with-gnu-ld --with-ogg="$INSTALLDIR/usr/local" ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
########################################################zlib
echo "zlib" ||exit
cd zlib* ||exit
./configure --prefix=$PREFIX ||exit
# 修改Makefile
sed -i "s/CC=gcc/CC=arm-none-linux-gnueabi-gcc/g" Makefile ||exit
sed -i "s/LDSHARED=gcc.*/LDSHARED=arm-none-linux-gnueabi-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map/g" Makefile ||exit
sed -i "s/CPP=gcc -E/CPP=arm-none-linux-gnueabi-gcc -E/g" Makefile ||exit
sed -i "s/AR=ar rc/AR=arm-none-linux-gnueabi-ar rc/g" Makefile ||exit
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd $LINPHONE_DIR
sleep 5
####################################################libv4l
echo "libv4l" ||exit
cd libv4l* ||exit
# 修改Makefile
echo CC=arm-none-linux-gnueabi-gcc >> libv4l1/Makefile ||exit
echo AR=arm-none-linux-gnueabi-ar >> libv4l1/Makefile ||exit
echo CC=arm-none-linux-gnueabi-gcc >>libv4l2/Makefile ||exit
echo AR=arm-none-linux-gnueabi-ar >>libv4l2/Makefile ||exit
echo CC=arm-none-linux-gnueabi-gcc >>libv4lconvert/Makefile ||exit
echo AR=arm-none-linux-gnueabi-ar >>libv4lconvert/Makefile ||exit
# 在文件起始处增加以下两行:
# CC=arm-none-linux-gnueabi-gcc
# AR=arm-none-linux-gnueabi-ar
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
# 有些交叉工具链可能没有videodev.h文件,修改Makefile以去除对libv4l1的变异,同时在linphone编译时不加入libv4l1。
#######################################################################
rm -rf $INSTALLDIR$PREFIX/lib/*.la ||exit
######################################################linphone
echo "linphone" ||exit
sleep 5
cp mediastreamer-2.7.3-ms_sws_fix.patch linphone*/mediastreamer2/src/ ||exit
cd linphone* ||exit
# cd mediastreamer2/src
# patch < mediastreamer-2.7.3-ms_sws_fix.patch //右击另存为
# linphone-3.5.2使用mediastreamer2-2.8.2版本已修复此错误(update 2013.1.2)
./configure --prefix=$PREFIX --host=$HOSTTPL --disable-static --disable-glib --enable-gtk_ui=no --disable-xv --disable-x11 --disable-pulseaudio --enable-video --enable-ffmpeg --enable-sdl --enable-libv4l --enable-oss --enable-ipv6 --with-gnu-ld --with-ffmpeg=$INSTALLDIR/usr/local --with-libiconv-prefix=$INSTALLDIR/usr/local --with-osip=$INSTALLDIR/usr/local --with-readline=$INSTALLDIR/usr/local SPEEX_CFLAGS="-I$INSTALLDIR/usr/local/include" SPEEX_LIBS="-L$INSTALLDIR/usr/local/lib -lspeex" FFMPEG_CFLAGS="-I$INSTALLDIR/usr/local/include" FFMPEG_LIBS="-L$INSTALLDIR/usr/local/lib -lavcodec" SWSCALE_CFLAGS="-I$INSTALLDIR/usr/local/include" SWSCALE_LIBS="-L$INSTALLDIR/usr/local/lib -lswscale" SDL_CFLAGS="-I$INSTALLDIR/usr/local/include" SDL_LIBS="-L$INSTALLDIR/usr/local/lib -lSDL" OSIP_CFLAGS="-I$INSTALLDIR/usr/local/include" OSIP_LIBS="-L$INSTALLDIR/usr/local/lib -losip2 -losipparser2 -leXosip2" SPEEX_CFLAGS="-I$INSTALLDIR/usr/local/include" SPEEX_LIBS="-L$INSTALLDIR/usr/local/lib -lspeex -lspeexdsp" SPEEXDSP_CFLAGS="-I$INSTALLDIR/usr/local/include" SPEEXDSP_LIBS="-L$INSTALLDIR/usr/local/lib -lspeex -lspeexdsp" LIBV4L2_CFLAGS="-I$INSTALLDIR/usr/local/include" LIBV4L2_LIBS="-L$INSTALLDIR/usr/local/lib -lv4l2" LIBV4L1_CFLAGS="-I$INSTALLDIR/usr/local/include" LIBV4L1_LIBS="-L$INSTALLDIR/usr/local/lib -lv4l1" ||exit
#########################################################################
#####配置完configure后修改Makefile如下:
################## 239行,mediastreamer2/tests/Makefile
sed -i "239d" mediastreamer2/tests/Makefile
sed -i "238a LIBS = -pthread -lpthread -lrt -lvorbisenc -lv4l1 -lv4l2 -lv4lconvert -liconv -lvorbis -logg -lz" mediastreamer2/tests/Makefile ||exit
#LIBS = -pthread -lpthread -lrt -lvorbisenc -lv4l1 -lv4l2 -lv4lconvert -liconv -lvorbis -logg -lz
######################
#修改coreapi/Makefile
sed -i "245d" coreapi/Makefile
sed -i "244a LIBS = -lspeex -lspeexdsp -lSDL -lvorbisenc -lv4l1 -lv4l2 -lv4lconvert -liconv -lvorbis -logg -lz -lavutil" coreapi/Makefile
###################
# coreapi/help/Makefile
sed -i "195d" coreapi/help/Makefile
sed -i "194a LIBS = -losip2 -losipparser2 -leXosip2 -lspeex -lspeexdsp -lSDL -lvorbisenc -lv4l1 -lv4l2 -lv4lconvert -liconv -lvorbis -logg -lz -lavutil" coreapi/help/Makefile ||exit
sed -i "327a \\\t\t\t\t\$(EXOSIP_LIBS) \\\\" coreapi/help/Makefile
#helloworld_LDADD = $(top_builddir)/coreapi/liblinphone.la \
# $(EXOSIP_LIBS) \ 添加该行到328
# $(MEDIASTREAMER_LIBS) \
# $(ORTP_LIBS)
#####################
# vim console/Makefile
sed -i "204d" console/Makefile
sed -i "203a LIBS = -lSDL -lvorbisenc -lv4l1 -lv4l2 -lv4lconvert -liconv -lvorbis -logg -lz -lavutil" console/Makefile ||exit
#LIBS = -lSDL -lvorbisenc -lv4l1 -lv4l2 -lv4lconvert -liconv -lvorbis -logg - lz -lavutil
sed -i "347d" console/Makefile
sed -i "346a linphonecsh_LDADD = \$(ORTP_LIBS) -L/home/linux/linphone/install/usr/local/lib " console/Makefile ||exit
#linphonecsh_LDADD = $(ORTP_LIBS) -L/home/linux/linphone/install/usr/local/lib
#此处路径为交叉编译库安装的位置
make ||exit
make install DESTDIR=$INSTALLDIR ||exit
cd .. ||exit
echo "完成100%,运行结束" ||exit
#至此成功编译了Linphone,但是需要在ARM9上成功运行请接着看下一篇博文