cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH dlm-tool 2/4] fence: move pkg-config fail to bin target
Date: Tue, 11 Apr 2023 10:49:14 -0400	[thread overview]
Message-ID: <20230411144916.1231886-2-aahringo@redhat.com> (raw)
In-Reply-To: <20230411144916.1231886-1-aahringo@redhat.com>

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


  reply	other threads:[~2023-04-11 14:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11 14:49 [Cluster-devel] [PATCH dlm-tool 1/4] fence: make pkg-config binary as passable make var Alexander Aring
2023-04-11 14:49 ` Alexander Aring [this message]
2023-04-11 14:49 ` [Cluster-devel] [PATCH dlm-tool 3/4] dlm_controld: move pkg-config fail to bin target Alexander Aring
2023-04-11 14:49 ` [Cluster-devel] [PATCH dlm-tool 4/4] dlm_controld: use pkg-config to find corosync libs Alexander Aring
2023-04-14 15:06 ` [Cluster-devel] [PATCH dlm-tool 1/4] fence: make pkg-config binary as passable make var Fabio M. Di Nitto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230411144916.1231886-2-aahringo@redhat.com \
    --to=aahringo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).