guowenxue
2021-08-17 d634817310a7186e9a84a65bb135d850d0adee17
3rdparty/local/libevent/build.sh
@@ -1,17 +1,14 @@
#!/bin/bash
#+--------------------------------------------------------------------------------------------
#|Description:  This shell script used download and compile libevent for ARM
#|Description:  This shell script used download and compile libevent for RaspberryPi
#|     Author:  GuoWenxue <guowenxue@gmail.com>
#|  ChangeLog:
#|           1, Initialize 1.0.0 on 2011.04.12
#|           1, Initialize 1.0.0 on 2021.04.12
#+--------------------------------------------------------------------------------------------
PREFIX_PATH=`pwd`/install
if [ -z $CROSSTOOL ] ; then
   CROSSTOOL=/opt/rpi/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
fi
PREFIX_PATH=/usr
LYFTP_SRC=ftp://master.iot-yun.club/src/
function msg_banner()
{
@@ -34,57 +31,38 @@
    fi
}
function export_cross()
{
    # export cross toolchain
    export CC=${CROSSTOOL}gcc
    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
    # export cross configure
    export CONFIG_CROSS=" --build=i686-pc-linux --host=arm-linux "
    # Clear LDFLAGS and CFLAGS
    export LDFLAGS=
    export CFLAGS=
}
function compile_libevent()
{
    SRC_NAME=libevent-2.0.21-stable
    SRC_NAME=libevent-2.1.11-stable
    PACK_SUFIX=tar.gz
    IMG_NAME=ipt
    if [ -f ${PREFIX_PATH}/${IMG_NAME} ] ; then
    if [ -f ${PREFIX_PATH}/lib/libevent.so ] ; then
        msg_banner "$SRC_NAME already compile and installed"
        return 0;
    fi
    msg_banner "Start cross compile $SRC_NAME "
    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 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}
    ./configure --prefix=${PREFIX_PATH} ${CONFIG_CROSS}  --enable-thread-support --enable-openssl --enable-function-sections
    ./configure --prefix=${PREFIX_PATH} --enable-thread-support --enable-openssl --enable-function-sections
    check_result "ERROR: configure ${SRC_NAME} failure"
    make  && make install
    make  && sudo make install
    check_result "ERROR: compile ${SRC_NAME} failure"
    cd -
}
export_cross
compile_libevent