From 5f20547d454eda23ad5db4900a48bc28747d1359 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Sun, 11 Aug 2019 11:18:05 +0800
Subject: [PATCH] update build shell script to format

---
 3rdparty/zbar/build.sh |  282 +++++++++++++++++--------------------------------------
 1 files changed, 88 insertions(+), 194 deletions(-)

diff --git a/3rdparty/zbar/build.sh b/3rdparty/zbar/build.sh
index 86512b3..f16d794 100755
--- a/3rdparty/zbar/build.sh
+++ b/3rdparty/zbar/build.sh
@@ -1,221 +1,115 @@
 #!/bin/bash
 
 #+--------------------------------------------------------------------------------------------
-#|Description:  This is shell script used to download a zbarapplication
-#|             and cross compile it.
+#|Description:  This shell script used download and compile zbar for ARM
 #|     Author:  GuoWenxue <guowenxue@gmail.com>
 #|  ChangeLog:
-#|           1, Initialize 1.0.0 on 2011.12.26
+#|           1, Initialize 1.0.0 on 2018.08.16
 #+--------------------------------------------------------------------------------------------
 
-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-
+PREFIX_PATH=`pwd`/../install/
 
 LYFTP_SRC=ftp://master.iot-yun.club/src/
 
-# arg1 is the packet download address
-# arg2 is the download packet rename name
-function download_packet()
+CROSSTOOL=/opt/crosstool/cortex-a7/bin/arm-linux-gnueabi-
+
+function msg_banner()
 {
-    if [ $# -lt 1 ] ; then
-        echo "ERROR: $0 without argument for packet download address"
-        exit;
+    echo ""
+    echo "+-----------------------------------------------------------------------"
+    echo "|  $1 "
+    echo "+-----------------------------------------------------------------------"
+    echo ""
+}
+
+function check_result()
+{
+    if [ $? != 0 ] ; then
+       echo ""
+       echo "+-----------------------------------------------------------------------"
+       echo "|  $1 "
+       echo "+-----------------------------------------------------------------------"
+       echo ""
+       exit ;
     fi
+}
 
-    rename=0
+function export_cross()
+{
+    # export cross toolchain
+    export CC=${CROSSTOOL}gcc
+    export CXX=${CROSSTOOL}g++
+    export AS=${CROSSTOOL}as
+    export AR=${CROSSTOOL}ar
+    export LD=${CROSSTOOL}ld
+    export NM=${CROSSTOOL}nm
+    export RANLIB=${CROSSTOOL}ranlib
+    export OBJDUMP=${CROSSTOOL}objdump
+    export STRIP=${CROSSTOOL}strip
 
-    dl_addr=$1
-    dl_file=`basename $dl_addr`
+    # export cross configure 
+    export CONFIG_CROSS=" --build=i686-pc-linux --host=arm-linux "
 
-    if [ $# -ge 2 ] ; then
-        pack=$2
-        rename=1
-    else
-        pack=$dl_file
-    fi
+    # Clear LDFLAGS and CFLAGS
+    export LDFLAGS=
+    export CFLAGS=
+}
 
-    if [ -s $pack ] ; then
-        echo "INFO: $pack already exist, skip download it"
+
+function compile_zbar()
+{
+    SRC_NAME=zbar-latest
+    PACK_SUFIX=tar.bz2
+
+    if [ -f ${PREFIX_PATH}/bin/zbarcam ] ; then
+        echo "$SRC_NAME already compile and installed"
         return 0;
     fi
 
-    echo "INFO: Start to download packet $pack now"
-    wget $dl_addr 
+    msg_banner "Start cross compile $SRC_NAME "
 
-    if [ $? != 0  ] ; then
-        echo "ERROR: Download $pack failure, exit now..."
-        exit;
-    fi 
-    echo "INFO: Download $pack ok!"
+    if [ ! -f ${SRC_NAME}.${PACK_SUFIX} ] ; then
+        wget ${LYFTP_SRC}/${SRC_NAME}.${PACK_SUFIX}
 
-    if [ $rename != 0 ] ; then
-        mv  $dl_file $pack
+        check_result "ERROR: download ${SRC_NAME} failure"
     fi
 
-    return 0;
+    tar -xjf ${SRC_NAME}.${PACK_SUFIX}
+
+    cd ${SRC_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=$PREFIX_PATH \
+    --without-gtk --without-python --without-qt --without-x --without-java  \
+    --with-imagemagick=${PREFIX_PATH}/ --without-graphicsmagick \
+    MAGICK_CFLAGS=-I${PREFIX_PATH}//include/ImageMagick-6 \
+    MAGICK_LIBS="-L${PREFIX_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 -
 }
 
-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 ../zlib 
+    ./build.sh 
 cd -
 
+
+cd ../imageMagick
+    ./build.sh 
+cd -
+
+
+export_cross
+
+compile_zbar
+
+

--
Gitblit v1.9.1