guowenxue
2020-08-21 da03ea75b637b157697040c552bb9612882650fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/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