From ed4285674b9648e85e45e9aeadcc79bd8898790e Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Tue, 17 Aug 2021 14:12:14 +0800 Subject: [PATCH] Add 3rdparty local build shell script --- 3rdparty/local/build.sh | 43 ++++++++ 3rdparty/local/libevent/build.sh | 44 ++------ 3rdparty/build.sh | 28 +++++ 3rdparty/local/mosquitto/build.sh | 57 ++--------- 3rdparty/local/libgpiod/build.sh | 6 3rdparty/local/paho.mqtt/build.sh | 69 ++----------- 6 files changed, 107 insertions(+), 140 deletions(-) diff --git a/3rdparty/build.sh b/3rdparty/build.sh new file mode 100755 index 0000000..bc14e72 --- /dev/null +++ b/3rdparty/build.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +ARCH=`uname -m` + +function msg_banner() +{ + echo "" + echo "+-----------------------------------------------------------------------" + echo "| $1 " + echo "+-----------------------------------------------------------------------" + echo "" +} + +echo ${ARCH} | grep "arm" > /dev/null +if [ $? == 0 ] ; then + msg_banner "Start local compile on RaspberryPi..." + cd local && bash build.sh + exit 0; +fi + +echo ${ARCH} | grep "x86" > /dev/null +if [ $? == 0 ] ; then + msg_banner "Start cross compile on x86 server..." + cd cross && bash build.sh + exit 0; +fi + + diff --git a/3rdparty/local/build.sh b/3rdparty/local/build.sh new file mode 100755 index 0000000..60a7516 --- /dev/null +++ b/3rdparty/local/build.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +ARCH=`uname -m` + +echo ${ARCH} | grep "arm" > /dev/null +if [ $? != 0 ] ; then + echo "+---------------------------------------------------+" + echo "| ERROR: This folder must compile on RaspberryPi |"; + echo "+---------------------------------------------------+" + exit 1; +fi + + +function do_compile +{ + for dir in `ls` + do + if [ -f $dir/build*.sh ] ; then + cd $dir + ./build*.sh + cd - + fi + done +} + +function do_clean +{ + for dir in `ls` + do + if [ -f $dir/build*.sh ] ; then + rm -rf ${dir}/${dir}* + fi + done +} + +if [[ $# == 1 ]] && [[ $1 == "clean" ]] ; then + do_clean + exit; +fi + +do_compile + + diff --git a/3rdparty/local/libevent/build.sh b/3rdparty/local/libevent/build.sh index f358a02..bccf0aa 100755 --- a/3rdparty/local/libevent/build.sh +++ b/3rdparty/local/libevent/build.sh @@ -7,11 +7,8 @@ #| 1, Initialize 1.0.0 on 2011.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,36 @@ 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} 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 diff --git a/3rdparty/local/libgpiod/build.sh b/3rdparty/local/libgpiod/build.sh index f7a7613..ac6b8f8 100755 --- a/3rdparty/local/libgpiod/build.sh +++ b/3rdparty/local/libgpiod/build.sh @@ -7,7 +7,7 @@ #| 1, Initialize 1.0.0 on 2011.04.12 #+-------------------------------------------------------------------------------------------- - +PREFIX_PATH=/usr LYFTP_SRC=ftp://master.iot-yun.club/src/ function msg_banner() @@ -53,9 +53,9 @@ tar -xzf ${SRC_NAME}.${PACK_SUFIX} cd ${SRC_NAME} - ./autogen.sh && ./configure --enable-tools + ./autogen.sh && sudo ./configure --prefix=${PREFIX_PATH} --enable-tools - make && make install + make && sudo make install cd - } diff --git a/3rdparty/local/mosquitto/build.sh b/3rdparty/local/mosquitto/build.sh index 928d556..dc03000 100755 --- a/3rdparty/local/mosquitto/build.sh +++ b/3rdparty/local/mosquitto/build.sh @@ -7,12 +7,8 @@ #| 1, Initialize 1.0.0 on 2011.04.12 #+-------------------------------------------------------------------------------------------- -PREFIX_PATH=`pwd`/install -OPENSSL_PATH=`pwd`/../openssl/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() { @@ -35,67 +31,36 @@ fi } -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 - - # export cross configure - export CONFIG_CROSS=" --build=i686-pc-linux --host=arm-linux " - - # Clear LDFLAGS and CFLAGS - export LDFLAGS= - export CFLAGS= -} - function compile_mosquitto() { - SRC_NAME=mosquitto-1.4.15 + SRC_NAME=mosquitto-2.0.10 PACK_SUFIX=tar.gz - if [ -d ${PREFIX_PATH}/lib ] ; then + if [ -f ${PREFIX_PATH}/lib/libmosquitto.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://mosquitto.org/files/source//${SRC_NAME}.${PACK_SUFIX} + #wget https://mosquitto.org/files/source//${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} cd ${SRC_NAME} - export CFLAGS=-I${OPENSSL_PATH}/include - export LDFLAGS=-L${OPENSSL_PATH}/lib - export DESTDIR=${PREFIX_PATH} make WITH_SRV=no WITH_UUID=no check_result "ERROR: compile ${SRC_NAME} failure" - mkdir -p ${PREFIX_PATH}/{lib,bin} - cp lib/libmosquitto.so.1 ${PREFIX_PATH}/lib - cp src/mosquitto src/mosquitto_passwd client/mosquitto_pub client/mosquitto_sub ${PREFIX_PATH}/bin - cd - + sudo make prefix=${PREFIX_PATH} install } - -export_cross - -if [ ! -d ${OPENSSL_PATH}/include ] ; then - cd ../openssl - ./build.sh - cd - -fi +sudo apt install -y libssl1.0-dev compile_mosquitto diff --git a/3rdparty/local/paho.mqtt/build.sh b/3rdparty/local/paho.mqtt/build.sh index 7fb3625..01120af 100755 --- a/3rdparty/local/paho.mqtt/build.sh +++ b/3rdparty/local/paho.mqtt/build.sh @@ -7,12 +7,8 @@ #| 1, Initialize 1.0.0 on 2011.04.12 #+-------------------------------------------------------------------------------------------- -PREFIX_PATH=`pwd`/install -OPENSSL_PATH=`pwd`/../openssl/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() { @@ -35,76 +31,35 @@ 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_paho() { - SRC_NAME=paho.mqtt.c-1.2.1 + SRC_NAME=paho.mqtt.c-1.3.9 PACK_SUFIX=tar.gz - if [ -f ${PREFIX_PATH}/ethtool ] ; then + if [ -f ${PREFIX_PATH}/lib/libpaho-mqtt3a.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/eclipse/paho.mqtt.c/archive/v1.2.1.tar.gz -O ${SRC_NAME}.${PACK_SUFIX} + #wget https://github.com/eclipse/paho.mqtt.c/archive/v1.3.9.tar.gz -O ${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} + tar -xzf ${SRC_NAME}.${PACK_SUFIX} + check_result "ERROR: decompress ${SRC_NAME} failure" + cd ${SRC_NAME} - export CFLAGS=-I${OPENSSL_PATH}/include - export LDFLAGS=-L${OPENSSL_PATH}/lib - - mkdir -p ${PREFIX_PATH}/usr/local/{bin,include,lib} - make && make install DESTDIR=${PREFIX_PATH} + make && sudo make prefix=${PREFIX_PATH} install - cp -af build/output/samples/ ${PREFIX_PATH}/ - - cd ${PREFIX_PATH}/usr/local/lib - ln -s libpaho-mqtt3a.so.1.0 libpaho-mqtt3a.so.1 - ln -s libpaho-mqtt3as.so.1.0 libpaho-mqtt3as.so.1 - ln -s libpaho-mqtt3c.so.1.0 libpaho-mqtt3c.so.1 - ln -s libpaho-mqtt3cs.so.1.0 libpaho-mqtt3cs.so.1 - tar -cf libpaho-mqtt.tar * - mv libpaho-mqtt.tar ${PREFIX_PATH} - cd - - - check_result "ERROR: compile ${SRC_NAME} failure" cd - } - - -export_cross - -if [ ! -d ${OPENSSL_PATH}/include ] ; then - cd ../openssl - ./build.sh - cd - -fi compile_paho -- Gitblit v1.9.1