From ff970152123acde6084e9de1b3bad134922fc9c2 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Thu, 20 Nov 2025 15:19:48 +0800
Subject: [PATCH] updte iotd to support deb package

---
 project/4.mqttd/makefile |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/project/4.mqttd/makefile b/project/4.mqttd/makefile
index 0eaa3c7..7ba434c 100644
--- a/project/4.mqttd/makefile
+++ b/project/4.mqttd/makefile
@@ -12,7 +12,9 @@
 #*******************************************************************************
 
 PRJ_PATH=$(shell pwd)
-APP_NAME = mqttd
+APP_NAME=iotd
+DEB_NAME=${APP_NAME}.deb
+DEB_PATH=${PRJ_PATH}/deb
 
 BUILD_ARCH=$(shell uname -m)
 ifneq ($(findstring $(BUILD_ARCH), "x86_64" "i386"),)
@@ -26,7 +28,7 @@
 CFLAGS = -Wall -Wshadow -Wundef -Wmaybe-uninitialized -D_GNU_SOURCE
 
 # C source file in sub-directory
-SRCS=booster
+SRCS=booster modules
 SRCS_PATH=$(patsubst %,${PRJ_PATH}/%,$(SRCS))
 CFLAGS+=$(patsubst %,-I%,$(SRCS_PATH))
 LDFLAGS+=$(patsubst %,-L%,$(SRCS_PATH))
@@ -39,24 +41,29 @@
 
 # libraries
 libs=openlibs ${SRCS}
-LDFLAGS+=-lmosquitto -lcjson -lssl -lcrypto -lgpiod
+LDFLAGS+=-lmosquitto -lcjson -lssl -lcrypto -lgpiod -lm
 
 LDFLAGS+=-lpthread
 
 all: entry subdir
-	${CROSS_COMPILE}gcc ${CFLAGS} mqttd.c -o ${APP_NAME} ${LDFLAGS}
+	${CROSS_COMPILE}gcc ${CFLAGS} ${SRCFILES} -o ${APP_NAME} ${LDFLAGS}
+	@make gendeb
 
 entry:
 	@echo "Building ${APP_NAME} on ${BUILD_ARCH}"
 
 subdir:
-	@for dir in ${libs} ;  do CFLAGS="${CFLAGS}" make -C $${dir}; done
+	@for dir in ${libs} ;  do CFLAGS="${CFLAGS}" make -C $${dir} ; done
+
+gendeb:
+	@make -C ${DEB_PATH} APP_NAME=${APP_NAME}
 
 install:
-	cp ${APP_NAME} /tftp
+	cp ${APP_NAME} ${DEB_PATH}/${DEB_NAME} /tftp
 
 clean:
 	@for dir in ${SRCS} ; do if [ -e $${dir} ] ; then make clean -C $${dir}; fi; done
+	@make clean -C ${DEB_PATH} APP_NAME=${APP_NAME}
 	@rm -f ${APP_NAME}
 
 distclean:

--
Gitblit v1.9.1