#!/bin/bash
|
|
# libraries install path
|
INST_PATH=`pwd`/../install
|
|
# LingYun studio FTP server address for all the open source code
|
LYFTP_SRC=ftp://master.iot-yun.club/src/
|
|
# set shell script exit when any command failure
|
set -e
|
|
# funciton used to build cjson source code
|
function build_cjson()
|
{
|
SRC_NAME=cJSON-1.7.15
|
|
if [ -L $INST_PATH/lib/libcjson.so ] ; then
|
echo "$SRC_NAME already compile and installed"
|
return ;
|
fi
|
|
# If source code tarball file not exist, it will download the packet.
|
if [ ! -f ${SRC_NAME}.tar.gz ] ; then
|
wget ${LYFTP_SRC}/${SRC_NAME}.tar.gz
|
fi
|
|
|
# If source code folder not exist, decompress the tarball packet
|
if [ ! -d ${SRC_NAME} ] ; then
|
tar -xzf ${SRC_NAME}.tar.gz
|
fi
|
|
cd ${SRC_NAME}
|
|
make && make DESTDIR=${INST_PATH} PREFIX=/ install
|
|
cd -
|
}
|
|
# start build cjson
|
|
build_cjson
|