Guo Wenxue
2022-04-18 dc4b04335bd8086487dfcd332082b324e3bbdf3c
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
#!/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