[Cluster-devel] [PATCH dlm-tool 3/4] dlm_controld: move pkg-config fail to bin target
Alexander Aring
aahringo at redhat.com
Tue Apr 11 14:49:15 UTC 2023
Currently make (GNU Make 4.2.1) will fail if pkg-config fails even if
it's not necessary, e.g. make clean target. We move the make bailout if
pkg-config failed to the binary target when pkg-config result is
necessary.
Note: this is using $(.SHELLSTATUS) which is only available on GNU Makefile
version 4.2 or above.
---
dlm_controld/Makefile | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index 9cf7152f..44715982 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -54,20 +54,35 @@ BIN_LDFLAGS += -lpthread -lrt -lcpg -lcmap -lcfg -lquorum -luuid
LIB_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -Wl,-z,now -pie
PKG_CONFIG ?= pkg-config
+PKG_CONFIG_FLAGS := --errors-to-stdout
+
ifeq ($(USE_SD_NOTIFY),yes)
- BIN_CFLAGS += $(shell $(PKG_CONFIG) --cflags libsystemd) \
+ SYSTEMD_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libsystemd) \
-DUSE_SD_NOTIFY
- BIN_LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd)
+ SYSTEMD_CFLAGS_STATUS := $(.SHELLSTATUS)
+ SYSTEMD_LDFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libsystemd)
+ SYSTEMD_LDFLAGS_STATUS := $(.SHELLSTATUS)
+else
+ SYSTEMD_CFLAGS_STATUS := 0
+ SYSTEMD_LDFLAGS_STATUS := 0
endif
-ifeq (, $(shell $(PKG_CONFIG) --libs "libquorum >= 3.1.0"))
- $(error "Requires libquorum at least version 3.1.0")
-endif
+CPG_LDFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs "libquorum >= 3.1.0")
+CPG_LDFLAGS_STATUS := $(.SHELLSTATUS)
all: $(LIB_TARGET) $(BIN_TARGET) $(LIB_PC)
$(BIN_TARGET): $(BIN_SOURCE)
- $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L.
+ifneq ($(CPG_LDFLAGS_STATUS),0)
+ $(error "Failed to call pkg-config for corosync ldflags: $(CPG_LDFLAGS)")
+endif
+ifneq ($(SYSTEMD_CFLAGS_STATUS),0)
+ $(error "Failed to call pkg-config for systemd cflags: $(SYSTEMD_CFLAGS)")
+endif
+ifneq ($(SYSTEMD_LDFLAGS_STATUS),0)
+ $(error "Failed to call pkg-config for systemd ldflags: $(SYSTEMD_LDFLAGS)")
+endif
+ $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(SYSTEMD_CFLAGS) $(BIN_LDFLAGS) $(SYSTEMD_LDFLAGS) -o $@ -L.
$(LIB_TARGET): $(LIB_SOURCE)
$(CC) $^ $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -o $@ -Wl,-soname=$(LIB_SMAJOR)
--
2.31.1
More information about the Cluster-devel
mailing list