From f39ecb3d272c68f77c2439659df14a140342cb22 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sat, 2 Mar 2024 10:34:12 +0000 Subject: [PATCH] Factor out a load of duplicated makefile code --- plugins/dynamic-security/Makefile | 47 ++----------------- plugins/examples/add-properties/Makefile | 27 ++--------- plugins/examples/auth-by-env/Makefile | 27 ++--------- plugins/examples/auth-by-ip/Makefile | 27 ++--------- .../examples/client-lifetime-stats/Makefile | 27 ++--------- plugins/examples/client-properties/Makefile | 27 ++--------- plugins/examples/connection-state/Makefile | 27 ++--------- plugins/examples/delayed-auth/Makefile | 27 ++--------- .../examples/deny-protocol-version/Makefile | 27 ++--------- plugins/examples/force-retain/Makefile | 27 ++--------- .../examples/limit-subscription-qos/Makefile | 27 ++--------- plugins/examples/message-timestamp/Makefile | 27 ++--------- plugins/examples/payload-ban/Makefile | 27 ++--------- .../examples/payload-modification/Makefile | 27 ++--------- plugins/examples/payload-size-stats/Makefile | 27 ++--------- plugins/examples/plugin-event-stats/Makefile | 27 ++--------- plugins/examples/print-ip-on-publish/Makefile | 27 ++--------- plugins/examples/topic-jail/Makefile | 27 ++--------- plugins/examples/topic-modification/Makefile | 27 ++--------- plugins/examples/wildcard-temp/Makefile | 27 ++--------- plugins/persist-sqlite/Makefile | 30 ++---------- plugins/persist-sqlite/common.c | 1 - plugins/plugin.mk | 36 ++++++++++++++ plugins/sparkplug-aware/Makefile | 35 ++------------ 24 files changed, 144 insertions(+), 518 deletions(-) create mode 100644 plugins/plugin.mk diff --git a/plugins/dynamic-security/Makefile b/plugins/dynamic-security/Makefile index 348ade92..a57760f5 100644 --- a/plugins/dynamic-security/Makefile +++ b/plugins/dynamic-security/Makefile @@ -1,14 +1,12 @@ R=../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test test-compile install uninstall - PLUGIN_NAME=mosquitto_dynamic_security -LOCAL_CFLAGS+=-fPIC +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+=-I${R}/lib/ -I${R}/src/ -I${R}/plugins/common LOCAL_LIBADD+=-lcjson -lm -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= WITH_PW_CACHE:=yes ifeq ($(WITH_PW_CACHE),yes) @@ -38,6 +36,8 @@ OBJS_EXTERNAL = \ misc_mosq.o \ password_mosq.o \ +EXTRA_DEPS:=dynamic_security.h + ifeq ($(WITH_TLS),yes) ALL_DEPS:= binary else @@ -46,27 +46,6 @@ endif all : ${ALL_DEPS} -ifeq ($(WITH_FUZZING),yes) -binary : ${PLUGIN_NAME}.a -else -binary : ${PLUGIN_NAME}.so -endif - -ifeq ($(WITH_FUZZING),yes) -binary : ${PLUGIN_NAME}.a -else -binary : ${PLUGIN_NAME}.so -endif - -${PLUGIN_NAME}.a : ${OBJS} ${OBJS_EXTERNAL} - ${CROSS_COMPILE}$(AR) cr $@ $^ - -${PLUGIN_NAME}.so : ${OBJS} ${OBJS_EXTERNAL} - ${CROSS_COMPILE}${CC} $(LOCAL_LDFLAGS) $^ -o $@ ${LOCAL_LIBADD} - -${OBJS} : %.o: %.c dynamic_security.h - ${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@ - base64_mosq.o : ${R}/common/base64_mosq.c ${R}/common/base64_mosq.h ${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@ @@ -79,20 +58,4 @@ misc_mosq.o : ${R}/common/misc_mosq.c ${R}/common/misc_mosq.h password_mosq.o : ${R}/common/password_mosq.c ${R}/common/password_mosq.h ${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@ -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -test-compile: - -check: test -test: test-compile - -install: all -ifeq ($(WITH_TLS),yes) - $(INSTALL) -d "${DESTDIR}$(libdir)" - $(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" -endif - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/add-properties/Makefile b/plugins/examples/add-properties/Makefile index 0aca8463..d52cff82 100644 --- a/plugins/examples/add-properties/Makefile +++ b/plugins/examples/add-properties/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_add_properties +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/auth-by-env/Makefile b/plugins/examples/auth-by-env/Makefile index 2661e2b1..2efae35e 100644 --- a/plugins/examples/auth-by-env/Makefile +++ b/plugins/examples/auth-by-env/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_auth_by_env +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/auth-by-ip/Makefile b/plugins/examples/auth-by-ip/Makefile index 9eee29a5..919020d1 100644 --- a/plugins/examples/auth-by-ip/Makefile +++ b/plugins/examples/auth-by-ip/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_auth_by_ip +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/client-lifetime-stats/Makefile b/plugins/examples/client-lifetime-stats/Makefile index 2f5bdb21..22fb1099 100644 --- a/plugins/examples/client-lifetime-stats/Makefile +++ b/plugins/examples/client-lifetime-stats/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_client_lifetime_stats +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/client-properties/Makefile b/plugins/examples/client-properties/Makefile index 3b573c25..64285d76 100644 --- a/plugins/examples/client-properties/Makefile +++ b/plugins/examples/client-properties/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_client_properties +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ $(LOCAL_LIBADD) - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/connection-state/Makefile b/plugins/examples/connection-state/Makefile index f8122ba6..41a3ff8f 100644 --- a/plugins/examples/connection-state/Makefile +++ b/plugins/examples/connection-state/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_connection_state +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/delayed-auth/Makefile b/plugins/examples/delayed-auth/Makefile index 8e0510e7..7cfa175c 100644 --- a/plugins/examples/delayed-auth/Makefile +++ b/plugins/examples/delayed-auth/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_delayed_auth +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/deny-protocol-version/Makefile b/plugins/examples/deny-protocol-version/Makefile index a37191b3..d50f5aba 100644 --- a/plugins/examples/deny-protocol-version/Makefile +++ b/plugins/examples/deny-protocol-version/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_deny_protocol_version +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/force-retain/Makefile b/plugins/examples/force-retain/Makefile index aeee265b..711c8084 100644 --- a/plugins/examples/force-retain/Makefile +++ b/plugins/examples/force-retain/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_force_retain +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/limit-subscription-qos/Makefile b/plugins/examples/limit-subscription-qos/Makefile index 1c0274a0..e0c2c59f 100644 --- a/plugins/examples/limit-subscription-qos/Makefile +++ b/plugins/examples/limit-subscription-qos/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_limit_subscription_qos +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/message-timestamp/Makefile b/plugins/examples/message-timestamp/Makefile index 4e995ff2..aacb08bd 100644 --- a/plugins/examples/message-timestamp/Makefile +++ b/plugins/examples/message-timestamp/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_message_timestamp +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/payload-ban/Makefile b/plugins/examples/payload-ban/Makefile index aa9b9eeb..4332e6a5 100644 --- a/plugins/examples/payload-ban/Makefile +++ b/plugins/examples/payload-ban/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_payload_ban +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/payload-modification/Makefile b/plugins/examples/payload-modification/Makefile index 2a11bab5..5fde7ee0 100644 --- a/plugins/examples/payload-modification/Makefile +++ b/plugins/examples/payload-modification/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_payload_modification +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/payload-size-stats/Makefile b/plugins/examples/payload-size-stats/Makefile index 00da80a0..29e797f6 100644 --- a/plugins/examples/payload-size-stats/Makefile +++ b/plugins/examples/payload-size-stats/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_payload_size_stats +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/plugin-event-stats/Makefile b/plugins/examples/plugin-event-stats/Makefile index 309596eb..c9595240 100644 --- a/plugins/examples/plugin-event-stats/Makefile +++ b/plugins/examples/plugin-event-stats/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_plugin_event_stats +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/print-ip-on-publish/Makefile b/plugins/examples/print-ip-on-publish/Makefile index 711b44de..5738b2a2 100644 --- a/plugins/examples/print-ip-on-publish/Makefile +++ b/plugins/examples/print-ip-on-publish/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_print_ip_on_publish +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/topic-jail/Makefile b/plugins/examples/topic-jail/Makefile index bcff9cba..670d56b4 100644 --- a/plugins/examples/topic-jail/Makefile +++ b/plugins/examples/topic-jail/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_topic_jail +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/topic-modification/Makefile b/plugins/examples/topic-modification/Makefile index 718c2bcb..03b2d296 100644 --- a/plugins/examples/topic-modification/Makefile +++ b/plugins/examples/topic-modification/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_topic_modification +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/examples/wildcard-temp/Makefile b/plugins/examples/wildcard-temp/Makefile index 9fc9702f..dfc8140b 100644 --- a/plugins/examples/wildcard-temp/Makefile +++ b/plugins/examples/wildcard-temp/Makefile @@ -1,32 +1,15 @@ R=../../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_wildcard_temp +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+= -LOCAL_CFLAGS+=-fPIC -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= LOCAL_LIBADD+= all : binary -binary : ${PLUGIN_NAME}.so +OBJS:=${PLUGIN_NAME}.o -${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $< -o $@ ${LOCAL_LIBADD} - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -check: test -test: - -install: ${PLUGIN_NAME}.so - # Don't install, these are examples only. - #$(INSTALL) -d "${DESTDIR}$(libdir)" - #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +PLUGIN_NOINST:=1 +include ${R}/plugins/plugin.mk diff --git a/plugins/persist-sqlite/Makefile b/plugins/persist-sqlite/Makefile index 688ef1c0..2ffaa7cf 100644 --- a/plugins/persist-sqlite/Makefile +++ b/plugins/persist-sqlite/Makefile @@ -1,12 +1,11 @@ R=../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test test-compile install uninstall - PLUGIN_NAME=mosquitto_persist_sqlite +LOCAL_CFLAGS+= LOCAL_CPPFLAGS+=-I${R}/src/ -I${R}/plugins/common LOCAL_LIBADD+=-lsqlite3 -lcjson -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_LDFLAGS+= OBJS = \ base_msgs.o \ @@ -30,31 +29,10 @@ ALL_DEPS:= endif all : ${ALL_DEPS} -binary : ${PLUGIN_NAME}.so - -${PLUGIN_NAME}.so : ${OBJS} ${OBJS_EXTERNAL} - ${CROSS_COMPILE}${CC} $(LOCAL_LDFLAGS) $^ -o $@ ${LOCAL_LIBADD} - -${OBJS} : %.o: %.c persist_sqlite.h - ${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@ json_help.o : ${R}/common/json_help.c ${R}/common/json_help.h ${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@ -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno +EXTRA_DEPS:=persist_sqlite.h -test-compile: - -check : test -test: test-compile - -install: all -ifeq ($(WITH_SQLITE),yes) - $(INSTALL) -d "${DESTDIR}$(libdir)" - $(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" -endif - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +include ${R}/plugins/plugin.mk diff --git a/plugins/persist-sqlite/common.c b/plugins/persist-sqlite/common.c index 2f879044..e6e0c3bd 100644 --- a/plugins/persist-sqlite/common.c +++ b/plugins/persist-sqlite/common.c @@ -20,7 +20,6 @@ Contributors: #include #include "mosquitto.h" -#include "mosquitto_broker.h" #include "persist_sqlite.h" diff --git a/plugins/plugin.mk b/plugins/plugin.mk new file mode 100644 index 00000000..a5b26771 --- /dev/null +++ b/plugins/plugin.mk @@ -0,0 +1,36 @@ +.PHONY : all binary check clean reallyclean test test-compile install uninstall + + +LOCAL_CFLAGS+=-fPIC +LOCAL_CPPFLAGS+= +LOCAL_LIBADD+= +LOCAL_LDFLAGS+=-fPIC -shared + +binary : ${PLUGIN_NAME}.so ${PLUGIN_NAME}.a + +${PLUGIN_NAME}.a : ${OBJS} ${OBJS_EXTERNAL} + ${CROSS_COMPILE}$(AR) cr $@ $^ + +${PLUGIN_NAME}.so : ${OBJS} ${OBJS_EXTERNAL} + ${CROSS_COMPILE}${CC} $(LOCAL_LDFLAGS) $^ -o $@ ${LOCAL_LIBADD} + +${OBJS} : %.o: %.c ${EXTRA_DEPS} + ${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@ + +reallyclean : clean +clean: + -rm -f *.o ${PLUGIN_NAME}.a ${PLUGIN_NAME}.so *.gcda *.gcno + +test-compile: + +check: test +test: test-compile + +ifeq ($(PLUGIN_NOINST),) +install: all + $(INSTALL) -d "${DESTDIR}$(libdir)" + $(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" + +uninstall : + -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" +endif diff --git a/plugins/sparkplug-aware/Makefile b/plugins/sparkplug-aware/Makefile index 34685eec..abcd8697 100644 --- a/plugins/sparkplug-aware/Makefile +++ b/plugins/sparkplug-aware/Makefile @@ -1,11 +1,10 @@ R=../.. include ${R}/config.mk -.PHONY : all binary check clean reallyclean test install uninstall - PLUGIN_NAME=mosquitto_sparkplug_aware -LOCAL_CFLAGS+=-I${R}/include -I${R}/ -LOCAL_LDFLAGS+=-fPIC -shared +LOCAL_CFLAGS+= +LOCAL_CPPFLAGS+= +LOCAL_LDFLAGS+= LOCAL_LDADD+= # Objects for this plugin only, built from source in this directory @@ -18,30 +17,4 @@ OBJS_EXTERNAL = all : binary -binary : ${PLUGIN_NAME}.so - -${PLUGIN_NAME}.so : ${OBJS} ${OBJS_EXTERNAL} - $(CROSS_COMPILE)$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $^ -o $@ ${LOCAL_LDADD} - -${OBJS} : %.o: %.c plugin_global.h - ${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@ - - -reallyclean : clean -clean: - -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno - -test-compile: -check: test -test: - -install: ${PLUGIN_NAME}.so - $(INSTALL) -d "${DESTDIR}$(libdir)" - $(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -uninstall : - -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" - -coverage: - lcov --capture --directory . --output-file coverage.info --no-external - genhtml coverage.info --output-directory out +include ${R}/plugins/plugin.mk