From 72fea370ff20ecb2494ab985c4431b4bd691e7cd Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Mon, 17 Nov 2025 15:11:05 +0800
Subject: [PATCH] update lighted program

---
 project/lightd/makefile |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/project/lightd/makefile b/project/lightd/makefile
index 3797387..2920afa 100644
--- a/project/lightd/makefile
+++ b/project/lightd/makefile
@@ -12,7 +12,7 @@
 #*******************************************************************************
 
 PRJ_PATH=$(shell pwd)
-APP_NAME = iotd
+APP_NAME = lightd 
 
 BUILD_ARCH=$(shell uname -m)
 ifneq ($(findstring $(BUILD_ARCH), "x86_64" "i386"),)
@@ -25,8 +25,8 @@
 # common CFLAGS for our source code
 CFLAGS = -Wall -Wshadow -Wundef -Wmaybe-uninitialized -D_GNU_SOURCE
 
-# sub-directory compiled to a library and need to link
-SRCS=src hal booster
+# C source file in sub-directory
+SRCS=booster hal
 SRCS_PATH=$(patsubst %,${PRJ_PATH}/%,$(SRCS))
 CFLAGS+=$(patsubst %,-I%,$(SRCS_PATH))
 LDFLAGS+=$(patsubst %,-L%,$(SRCS_PATH))
@@ -34,20 +34,24 @@
 LDFLAGS+=${LIBS}
 
 # Open source libraries
-LDFLAGS+=-lmosquitto -lgpiod -lcjson -lm
+CFLAGS+=-I ${PRJ_PATH}/openlibs/install/include
+LDFLAGS+=-L ${PRJ_PATH}/openlibs/install/lib
 
-# sub-directory need to entry and compile
-SUBDIR=${SRCS}
+# libraries
+libs=openlibs ${SRCS}
+LDFLAGS+=-lmosquitto -lcjson -lssl -lcrypto -lgpiod -lm
+
+LDFLAGS+=-lpthread
 
 all: entry subdir
-	${CROSS_COMPILE}gcc ${CFLAGS} main.c -o ${APP_NAME} ${LDFLAGS}
+	${CROSS_COMPILE}gcc ${CFLAGS} ${SRCFILES} -o ${APP_NAME} ${LDFLAGS}
 
 entry:
 	@echo "Building ${APP_NAME} on ${BUILD_ARCH}"
 
 subdir:
-	@for dir in ${SUBDIR} ; do if [ ! -e $${dir} ] ; then ln -s ../$${dir}; fi; done
-	@for dir in ${SUBDIR} ;  do make CFLAGS="${CFLAGS}" -C $${dir} ; done
+	@for dir in ${libs} ; do if [ ! -e $${dir} ] ; then ln -s ../$${dir}; fi; done
+	@for dir in ${libs} ;  do CFLAGS="${CFLAGS}" make -C $${dir} ; done
 
 install:
 	cp ${APP_NAME} /tftp
@@ -57,8 +61,8 @@
 	@rm -f ${APP_NAME}
 
 distclean:
-	@for dir in ${SUBDIR} ; do if [ -e $${dir} ] ; then make clean -C $${dir}; fi; done
+	@for dir in ${libs} ; do if [ -e $${dir} ] ; then make clean -C $${dir}; fi; done
+	@for dir in ${libs} ; do if [ -e $${dir} ] ; then unlink $${dir}; fi; done
 	@rm -f ${APP_NAME}
 	@rm -f cscope.* tags
-	@rm -f *.log *.db
 

--
Gitblit v1.9.1