#!/bin/bash
|
|
#+--------------------------------------------------------------------------------------------
|
#|Description: This shell script used to download SQLite code and cross compile it.
|
#| Author: GuoWenxue <guowenxue@gmail.com>
|
#| ChangeLog:
|
#| 1, Initialize 1.0.0 on 2011.12.26
|
#+--------------------------------------------------------------------------------------------
|
|
PRJ_PATH=`pwd`
|
|
APP_NAME="sqlite-autoconf-3071401"
|
PACK_SUFIX="tar.gz"
|
DL_ADDR="http://www.sqlite.org//$APP_NAME.$PACK_SUFIX"
|
PREFIX_PATH=$PRJ_PATH/sqlite3
|
|
#ARCH=arm926t
|
CROSS=
|
|
sup_arch=("" "arm926t" "arm920t" )
|
|
function select_arch()
|
{
|
echo "Current support ARCH: "
|
i=1
|
len=${#sup_arch[*]}
|
|
while [ $i -lt $len ]; do
|
echo "$i: ${sup_arch[$i]}"
|
let i++;
|
done
|
|
echo "Please select: "
|
index=
|
read index
|
ARCH=${sup_arch[$index]}
|
}
|
|
|
function decompress_packet()
|
(
|
echo "+---------------------------------------------+"
|
echo "| Decompress $1 now"
|
echo "+---------------------------------------------+"
|
|
ftype=`file "$1"`
|
case "$ftype" in
|
"$1: Zip archive"*)
|
unzip "$1" ;;
|
"$1: gzip compressed"*)
|
if [ 0 != `expr "$1" : ".*.tar.*" ` ] ; then
|
tar -xzf $1
|
else
|
gzip -d "$1"
|
fi ;;
|
"$1: bzip2 compressed"*)
|
if [ 0 != `expr "$1" : ".*.tar.*" ` ] ; then
|
tar -xjf $1
|
else
|
bunzip2 "$1"
|
fi ;;
|
"$1: POSIX tar archive"*)
|
tar -xf "$1" ;;
|
*)
|
echo "$1 is unknow compress format";;
|
esac
|
)
|
|
if [ -z $ARCH ] ; then
|
select_arch
|
fi
|
|
if [ "i386" == $ARCH ] ; then
|
CROSS=
|
else
|
CROSS="/opt/buildroot-2012.08/${ARCH}/usr/bin/arm-linux-"
|
fi
|
|
export CC=${CROSS}gcc
|
export CXX=${CROSS}g++
|
export AR=${CROSS}ar
|
export AS=${CROSS}as
|
export LD=${CROSS}ld
|
export NM=${CROSS}nm
|
export RANLIB=${CROSS}ranlib
|
export STRIP=${CROSS}strip
|
unset CFLAGS
|
unset LDFLAGS
|
|
if [ ! -d $PREFIX_PATH/lib ] ; then
|
mkdir -p $PREFIX_PATH
|
else
|
echo "$APP_NAME already cross compiled, exit now..."
|
exit;
|
fi
|
|
# Download source code packet
|
if [ ! -s $APP_NAME.$PACK_SUFIX ] ; then
|
echo "+------------------------------------------------------------------+"
|
echo "| Download $APP_NAME.$PACK_SUFIX now "
|
echo "+------------------------------------------------------------------+"
|
wget $DL_ADDR
|
fi
|
|
# Decompress source code packet
|
if [ ! -d $APP_NAME ] ; then
|
decompress_packet $APP_NAME.$PACK_SUFIX
|
fi
|
|
echo "+------------------------------------------------------------------+"
|
echo "| Build $APP_NAME for $ARCH "
|
echo "| Crosstool: $CROSS"
|
echo "+------------------------------------------------------------------+"
|
|
cd $APP_NAME
|
set -x
|
./configure --host=arm-linux --enable-static --prefix=$PREFIX_PATH
|
make
|
make install
|
$STRIP $PREFIX_PATH/bin/sqlite3
|
cd -
|
|
rm -rf $APP_NAME
|