[Cluster-devel] [PATCH dlm-tool 2/4] fence: move pkg-config fail to bin target
Alexander Aring
aahringo at redhat.com
Tue Apr 11 14:49:14 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 Make
version 4.2 or above.
---
fence/Makefile | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fence/Makefile b/fence/Makefile
index 894f6396..263657ec 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -21,8 +21,10 @@ CFLAGS += -fPIE -DPIE
CFLAGS += -I../include
PKG_CONFIG ?= pkg-config
+PKG_CONFIG_FLAGS := --errors-to-stdout
-CFLAGS += $(shell $(PKG_CONFIG) --cflags pacemaker-fencing)
+PACEMAKER_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags pacemaker-fencing)
+PACEMAKER_CFLAGS_STATUS := $(.SHELLSTATUS)
LDFLAGS += -Wl,-z,relro -Wl,-z,now -pie
LDFLAGS += -ldl
@@ -30,7 +32,10 @@ LDFLAGS += -ldl
all: $(BIN_TARGET)
$(BIN_TARGET): $(BIN_SOURCE)
- $(CC) $(BIN_SOURCE) $(CFLAGS) $(LDFLAGS) -o $@ -L.
+ifneq ($(PACEMAKER_CFLAGS_STATUS),0)
+ $(error "Failed to call pkg-config for pacemaker cflags: $(PACEMAKER_CFLAGS)")
+endif
+ $(CC) $(BIN_SOURCE) $(CFLAGS) $(PACEMAKER_CFLAGS) $(LDFLAGS) -o $@ -L.
clean:
rm -f *.o *.so *.so.* $(BIN_TARGET)
--
2.31.1
More information about the Cluster-devel
mailing list