From d8cd01ee83a0a480485b7560584102d192b245c9 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 9 Apr 2020 18:24:42 -0700 Subject: [PATCH] only automatically link libevent for PROD/LIB using libpvxs --- configure/CONFIG_PVXS_MODULE | 10 +++------- configure/Makefile | 3 ++- configure/RULES_PVXS_MODULE | 19 +++++++++++++++++++ example/Makefile | 1 + src/Makefile | 2 ++ src/log.cpp | 2 +- test/Makefile | 1 + tools/Makefile | 1 + 8 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 configure/RULES_PVXS_MODULE diff --git a/configure/CONFIG_PVXS_MODULE b/configure/CONFIG_PVXS_MODULE index c8f8537..81074fd 100644 --- a/configure/CONFIG_PVXS_MODULE +++ b/configure/CONFIG_PVXS_MODULE @@ -3,8 +3,8 @@ _PVXS := $(dir $(lastword $(MAKEFILE_LIST))) # we're appending so must be idempotent -ifeq (,$(_PVXS_INCLUDED)) -_PVXS_INCLUDED := YES +ifeq (,$(_PVXS_CONF_INCLUDED)) +_PVXS_CONF_INCLUDED := YES ifdef T_A @@ -42,10 +42,6 @@ LIBEVENT_SYS_LIBS_WIN32 = iphlpapi netapi32 ws2_32 LIBEVENT_SYS_LIBS += $(LIBEVENT_SYS_LIBS_POSIX_$(POSIX)) LIBEVENT_SYS_LIBS += $(LIBEVENT_SYS_LIBS_$(OS_CLASS)) -PROD_SYS_LIBS += $(LIBEVENT_SYS_LIBS) -LIB_SYS_LIBS += $(LIBEVENT_SYS_LIBS) - - endif # T_A -endif # _PVXS_INCLUDED +endif # _PVXS_CONF_INCLUDED diff --git a/configure/Makefile b/configure/Makefile index 6d7f72f..128cc96 100644 --- a/configure/Makefile +++ b/configure/Makefile @@ -5,8 +5,9 @@ include $(TOP)/configure/CONFIG TARGETS = $(CONFIG_TARGETS) CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS))) -CFG += CONFIG_PVXS_MODULE CFG += CONFIG_PVXS_VERSION +CFG += CONFIG_PVXS_MODULE +CFG += RULES_PVXS_MODULE include $(TOP)/configure/RULES diff --git a/configure/RULES_PVXS_MODULE b/configure/RULES_PVXS_MODULE new file mode 100644 index 0000000..05074e7 --- /dev/null +++ b/configure/RULES_PVXS_MODULE @@ -0,0 +1,19 @@ + +# we're appending so must be idempotent +ifeq (,$(_PVXS_RULE_INCLUDED)) +_PVXS_RULE_INCLUDED := YES + +ifneq ($(_PVXS_CONF_INCLUDED),YES) +$(error CONFIG_PVXS_MODULE was not loaded) +endif + +_PVXS_CHECK_VARS := PROD TESTPROD $(PROD) $(TESTPROD) $(LIBRARY) + +# $(1) is PROD or LIBRARY name +define _PVXS_ADD_LIBEVENT +$(1)_SYS_LIBS += $$(if $$(findstring pvxs,$$($(1)_LIBS)),$$(LIBEVENT_SYS_LIBS)) +endef + +$(foreach loc,$(_PVXS_CHECK_VARS),$(eval $(call _PVXS_ADD_LIBEVENT,$(loc)))) + +endif # _PVXS_RULE_INCLUDED diff --git a/example/Makefile b/example/Makefile index 8fe870c..9fa2e74 100644 --- a/example/Makefile +++ b/example/Makefile @@ -26,6 +26,7 @@ client_SRCS += client.cpp #=========================== include $(TOP)/configure/RULES +include $(TOP)/configure/RULES_PVXS_MODULE #---------------------------------------- # ADD RULES AFTER THIS LINE diff --git a/src/Makefile b/src/Makefile index 4206740..9957fd2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -93,10 +93,12 @@ LIB_SRCS += clientget.cpp LIB_SRCS += clientmon.cpp LIB_LIBS += Com +LIB_SYS_LIBS += $(LIBEVENT_SYS_LIBS) #=========================== include $(TOP)/configure/RULES +include $(TOP)/configure/RULES_PVXS_MODULE #---------------------------------------- # ADD RULES AFTER THIS LINE diff --git a/src/log.cpp b/src/log.cpp index 411d782..c112d90 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -79,7 +79,7 @@ void _log_printf(unsigned lvl, const char* fmt, ...) auto L = Level(lvl&0xff); auto abt = L==Level::Crit && abortOnCrit!=0; - if(abortOnCrit!=0 || L==Level::Crit) { + { va_list args; va_start(args, fmt); errlogVprintf(fmt, args); diff --git a/test/Makefile b/test/Makefile index 9101038..b004030 100644 --- a/test/Makefile +++ b/test/Makefile @@ -83,6 +83,7 @@ TESTSCRIPTS_HOST += $(TESTS:%=%.t) #=========================== include $(TOP)/configure/RULES +include $(TOP)/configure/RULES_PVXS_MODULE #---------------------------------------- # ADD RULES AFTER THIS LINE diff --git a/tools/Makefile b/tools/Makefile index cee8428..52e0903 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -35,6 +35,7 @@ pvxcall_SRCS += call.cpp #=========================== include $(TOP)/configure/RULES +include $(TOP)/configure/RULES_PVXS_MODULE #---------------------------------------- # ADD RULES AFTER THIS LINE