Guo Wenxue
2022-04-08 4473a603e8e4bb8830cee61b7509e995f6cc0a1a
Add cjson build.sh
1 files added
66 ■■■■■ changed files
3rdparty/arm/cjson/build.sh 66 ●●●●● patch | view | raw | blame | history
3rdparty/arm/cjson/build.sh
New file
@@ -0,0 +1,66 @@
#!/bin/bash
#+--------------------------------------------------------------------------------------------
#|Description:  This shell script used download and compile cJSON for RaspberryPi
#|     Author:  GuoWenxue <guowenxue@gmail.com>
#|  ChangeLog:
#|           1, Initialize 1.0.0 on 2021.04.12
#+--------------------------------------------------------------------------------------------
PREFIX_PATH=/usr
LYFTP_SRC=ftp://master.iot-yun.club/src/
function msg_banner()
{
    echo ""
    echo "+-----------------------------------------------------------------------"
    echo "|  $1 "
    echo "+-----------------------------------------------------------------------"
    echo ""
}
function check_result()
{
    if [ $? != 0 ] ; then
       echo ""
       echo "+-----------------------------------------------------------------------"
       echo "|  $1 "
       echo "+-----------------------------------------------------------------------"
       echo ""
       exit ;
    fi
}
function compile_cJSON()
{
    SRC_NAME=cJSON-1.7.15
    PACK_SUFIX=tar.gz
    IMG_NAME=ipt
    if [ -f ${PREFIX_PATH}/lib/libcjson.so ] ; then
        msg_banner "$SRC_NAME already compile and installed"
        return 0;
    fi
    msg_banner "Start compile $SRC_NAME "
    if [ ! -f ${SRC_NAME}.${PACK_SUFIX} ] ; then
        #wget https://github.com/downloads/libevent/libevent/${SRC_NAME}.${PACK_SUFIX}
        wget ${LYFTP_SRC}/${SRC_NAME}.${PACK_SUFIX}
        check_result "ERROR: download ${SRC_NAME} failure"
    fi
    tar -xzf ${SRC_NAME}.${PACK_SUFIX}
    check_result "ERROR: decompress ${SRC_NAME} failure"
    cd ${SRC_NAME}
    make  && sudo make install
    check_result "ERROR: compile ${SRC_NAME} failure"
    cd -
}
compile_cJSON