SAMA5D4 Xplained Ultra Board BSP
guowenxue
2019-08-05 e00efa5fb6c2fef07dd67af1684083d42f8caf67
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
 
#+--------------------------------------------------------------------------------------------
#|Description:  This is shell script used to download a zbarapplication
#|             and cross compile it.
#|     Author:  GuoWenxue <guowenxue@gmail.com>
#|  ChangeLog:
#|           1, Initialize 1.0.0 on 2011.12.26
#+--------------------------------------------------------------------------------------------
 
set -e
 
PRJ_PATH=`pwd`
 
APP_NAME=zbar-latest
APP_PACK=$APP_NAME.tar.bz2
 
INST_PATH=$PRJ_PATH/../install
 
CROSS=/opt/crosstool/cortex-a7/bin/arm-linux-gnueabi-
 
LYFTP_SRC=ftp://master.iot-yun.club/src/
 
# arg1 is the packet download address
# arg2 is the download packet rename name
function download_packet()
{
    if [ $# -lt 1 ] ; then
        echo "ERROR: $0 without argument for packet download address"
        exit;
    fi
 
    rename=0
 
    dl_addr=$1
    dl_file=`basename $dl_addr`
 
    if [ $# -ge 2 ] ; then
        pack=$2
        rename=1
    else
        pack=$dl_file
    fi
 
    if [ -s $pack ] ; then
        echo "INFO: $pack already exist, skip download it"
        return 0;
    fi
 
    echo "INFO: Start to download packet $pack now"
    wget $dl_addr 
 
    if [ $? != 0  ] ; then
        echo "ERROR: Download $pack failure, exit now..."
        exit;
    fi 
    echo "INFO: Download $pack ok!"
 
    if [ $rename != 0 ] ; then
        mv  $dl_file $pack
    fi
 
    return 0;
}
 
function decompress_packet()
(
   echo "+---------------------------------------------+"
   echo "|  Decompress $1 now"  
   echo "+---------------------------------------------+"
   rv=0;
 
    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" ;;
 
       "$1: LZMA compressed data, streamed"*)
           xz -d $1 && tar -xf `ls *.tar` ;;
 
       *)
           rv=1;
           echo "$1 is unknow compress format";;
    esac
 
    if [ $rv != 0 ] ; then
        echo "ERROR: Decompress $1 failure, exit now..."
        exit 1;
    fi
 
    return $rv;
)
 
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
 
if [ -d $INST_PATH ] ; then
    echo "INFO: $APP_NAME already cross compiled, exit now ..."
    #exit;
fi
 
 
LIB_ZLIB=zlib-1.2.11
PACK_ZLIB=$LIB_ZLIB.tar.gz
 
if [ ! -f $INST_PATH/lib/libz.so ] ; then
 
    download_packet  ${LYFTP_SRC}/${PACK_ZLIB} 
 
    if [ ! -d $LIB_ZLIB ] ; then
        decompress_packet $PACK_ZLIB
        if [ $? != 0 ] ; then
            exit 1;
        fi
    fi
 
    echo "+------------------------------------------------------------------+"
    echo "|          Build $LIB_ZLIB for $ARCH "
    echo "| Crosstool:  $CROSS"
    echo "+------------------------------------------------------------------+"
 
    cd $LIB_ZLIB
    ./configure --prefix=$INST_PATH 
    make && make install
    cd -
else
    echo "+------------------------------------------------------------------+"
    echo "|          $LIB_ZLIB already ready "
    echo "+------------------------------------------------------------------+"
fi
 
LIB_IMGIC=ImageMagick6-6.9.4-0 
PACK_IMGIC=$LIB_IMGIC.tar.gz
 
if [ ! -f $INST_PATH/lib/libMagickCore-6.Q16.a ] ; then
 
    download_packet  ${LYFTP_SRC}/${PACK_IMGIC}
 
    if [ ! -d $LIB_IMGIC ] ; then
        decompress_packet $PACK_IMGIC
        if [ $? != 0 ] ; then
            exit 1;
        fi
    fi
 
    echo "+------------------------------------------------------------------+"
    echo "|          Build $LIB_IMGIC for $ARCH "
    echo "| Crosstool:  $CROSS"
    echo "+------------------------------------------------------------------+"
 
    cd $LIB_IMGIC
 
    CFLAGS="-I${INST_PATH}/include -DMAGICKCORE_QUANTUM_DEPTH=16" LDFLAGS=-L${INST_PATH}/lib \
    ./configure --host=arm-linux --enable-static --disable-shared --prefix=$INST_PATH \
    --without-magick-plus-plus --without-perl --without-x --without-dps --without-xml \
    --without-pango --without-freetype --without-png
  
    make && make install
    cd -
else
    echo "+------------------------------------------------------------------+"
    echo "|          $LIB_IMGIC already ready "
    echo "+------------------------------------------------------------------+"
fi
 
 
# Download source code packet
download_packet ${LYFTP_SRC}/zbar-latest.tar.bz2
 
# Decompress source code packet 
if [ ! -d $APP_NAME ] ; then 
    decompress_packet $APP_PACK
    if [ $? != 0 ] ; then
        exit 1;
    fi
fi
 
 
echo "+------------------------------------------------------------------+"
echo "|          Build $APP_NAME for $ARCH "
echo "| Crosstool:  $CROSS"
echo "+------------------------------------------------------------------+"
 
cd $APP_NAME
   git checkout 8edfa5f8c4d11a54 && rm -rf * && git checkout .
   autoreconf --install
   CFLAGS="-DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16" \
       ./configure --host=arm-linux --enable-static --enable-shared --prefix=$INST_PATH \
   --without-gtk --without-python --without-qt --without-x --without-java  \
   --with-imagemagick=${INST_PATH}/ --without-graphicsmagick \
   MAGICK_CFLAGS=-I${INST_PATH}//include/ImageMagick-6  MAGICK_LIBS="-L${INST_PATH}/lib -lMagickWand-6.Q16 -lMagickCore-6.Q16 -lm -lz -L`pwd`/zbar/.libs/ -lzbar "
  
   mkdir -p ./doc/man/
   touch ./doc/man/zbarimg.1
   touch ./doc/man/zbarcam.1
   make all && make install
cd -