From ed778b78c3ee7cb25aecb0d70efd66239662c44c Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Mon, 25 Mar 2019 18:19:26 +0800 Subject: [PATCH] update mqttd program, add mosquitto compile --- mqttd/makefile | 7 ++++++- mqttd/mosquitto/build.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletions(-) diff --git a/mqttd/makefile b/mqttd/makefile index 684dac6..0cf60b5 100644 --- a/mqttd/makefile +++ b/mqttd/makefile @@ -18,6 +18,8 @@ CFLAGS+=-I${PWD} #CFLAGS+=-Wall -Werror +MQTT_LIBPATH=mosquitto + LDFLAGS+=-lwiringPi LDFLAGS+=-lpthread @@ -38,7 +40,7 @@ SRCFILES = $(wildcard *.c) IMAGE_NAME=$(shell basename ${PWD}) -all: entry binary +all: entry MQTT binary entry: @echo " "; @echo " ========================================================="; @@ -49,6 +51,9 @@ $(CC) $(CFLAGS) -o ${IMAGE_NAME} $^ ${LDFLAGS} @echo " Compile over" +MQTT: + cd ${MQTT_LIBPATH} && bash build.sh + tag: @ctags --c-kinds=+defglmnstuvx --langmap=c:.c.h.ho.hem.het.hec.hev.him.hit.hic.hiv -R . @cscope -Rbq diff --git a/mqttd/mosquitto/build.sh b/mqttd/mosquitto/build.sh new file mode 100755 index 0000000..5e1b708 --- /dev/null +++ b/mqttd/mosquitto/build.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +MQTT_LIB=mosquitto-1.5.8 + +LIBPATH=/usr/local/lib/libmosquitto.so + +if [ -f ${LIBPATH} ] ; then + echo "${MQTT_LIB} already installed" + exit 0; +fi + + +if [ ! -d $MQTT_LIB ] ; then + if [ ! -f ${MQTT_LIB}.tar.gz ] ; then + wget https://mosquitto.org/files/source/${MQTT_LIB}.tar.gz + fi + + if [ ! -f ${MQTT_LIB}.tar.gz ] ; then + echo "## ERROR: MQTT Library ${MQTT_LIB}.tar.gz not exist or download failure!" + exit 1; + fi + + tar -xzf ${MQTT_LIB}.tar.gz +fi + +if [ ! -d $MQTT_LIB ] ; then + echo "## ERROR: MQTT Library ${MQTT_LIB} not exist or decompress failure!" + exit 2; +fi + +cd $MQTT_LIB + +make install +if [ $? != 0 ] ; then + echo "ERROR: MQTT Library ${MQTT_LIB} failure!" + exit 3; +fi -- Gitblit v1.9.1