cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH dlm-tool 1/4] fence: make pkg-config binary as passable make var
@ 2023-04-11 14:49 Alexander Aring
  2023-04-11 14:49 ` [Cluster-devel] [PATCH dlm-tool 2/4] fence: move pkg-config fail to bin target Alexander Aring
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alexander Aring @ 2023-04-11 14:49 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This patch defines PKG_CONFIG make var which could be overwrite by the
user like it's the case for dlm_controld Makefile.
---
 fence/Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fence/Makefile b/fence/Makefile
index ee4dfb88..894f6396 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -19,7 +19,10 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
 
 CFLAGS += -fPIE -DPIE
 CFLAGS += -I../include
-CFLAGS += $(shell pkg-config --cflags pacemaker-fencing)
+
+PKG_CONFIG ?= pkg-config
+
+CFLAGS += $(shell $(PKG_CONFIG) --cflags pacemaker-fencing)
 
 LDFLAGS += -Wl,-z,relro -Wl,-z,now -pie
 LDFLAGS += -ldl
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH dlm-tool 2/4] fence: move pkg-config fail to bin target
  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
  2023-04-11 14:49 ` [Cluster-devel] [PATCH dlm-tool 3/4] dlm_controld: " Alexander Aring
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Aring @ 2023-04-11 14:49 UTC (permalink / raw)
  To: cluster-devel.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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH dlm-tool 3/4] dlm_controld: move pkg-config fail to bin target
  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 ` [Cluster-devel] [PATCH dlm-tool 2/4] fence: move pkg-config fail to bin target Alexander Aring
@ 2023-04-11 14:49 ` 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
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Aring @ 2023-04-11 14:49 UTC (permalink / raw)
  To: cluster-devel.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 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH dlm-tool 4/4] dlm_controld: use pkg-config to find corosync libs
  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 ` [Cluster-devel] [PATCH dlm-tool 2/4] fence: move pkg-config fail to bin target Alexander Aring
  2023-04-11 14:49 ` [Cluster-devel] [PATCH dlm-tool 3/4] dlm_controld: " Alexander Aring
@ 2023-04-11 14:49 ` 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
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Aring @ 2023-04-11 14:49 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Currently all corosync dependencies are hardcorded inside the
dlm_controld Makefile. We will determine those dependencies by
pkg-config. This allows us that dlm_controld can detect when the
corosync libaries are installed in a different place determined by
changing the PKG_CONFIG_PATH env variable.
---
 dlm_controld/Makefile | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index 44715982..2d97453a 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -50,7 +50,7 @@ BIN_CFLAGS += -I../include -I../libdlm
 LIB_CFLAGS += $(CFLAGS) -fPIC -fplugin=annobin
 
 BIN_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -Wl,-z,now -pie
-BIN_LDFLAGS += -lpthread -lrt -lcpg -lcmap -lcfg -lquorum -luuid
+BIN_LDFLAGS += -lpthread -lrt -luuid
 LIB_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -Wl,-z,now -pie
 
 PKG_CONFIG ?= pkg-config
@@ -67,12 +67,18 @@ else
 	SYSTEMD_LDFLAGS_STATUS := 0
 endif
 
-CPG_LDFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs "libquorum >= 3.1.0")
+CPG_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libcpg libcmap libcfg "libquorum >= 3.1.0")
+CPG_CFLAGS_STATUS := $(.SHELLSTATUS)
+
+CPG_LDFLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libcpg libcmap libcfg "libquorum >= 3.1.0")
 CPG_LDFLAGS_STATUS := $(.SHELLSTATUS)
 
 all: $(LIB_TARGET) $(BIN_TARGET) $(LIB_PC)
 
 $(BIN_TARGET): $(BIN_SOURCE)
+ifneq ($(CPG_CFLAGS_STATUS),0)
+	$(error "Failed to call pkg-config for corosync cflags: $(CPG_CFLAGS)")
+endif
 ifneq ($(CPG_LDFLAGS_STATUS),0)
 	$(error "Failed to call pkg-config for corosync ldflags: $(CPG_LDFLAGS)")
 endif
@@ -82,7 +88,7 @@ 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.
+	$(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(CPG_CFLAGS) $(SYSTEMD_CFLAGS) $(BIN_LDFLAGS) $(CPG_LDFLAGS) $(SYSTEMD_LDFLAGS) -o $@ -L.
 
 $(LIB_TARGET): $(LIB_SOURCE)
 	$(CC) $^ $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -o $@ -Wl,-soname=$(LIB_SMAJOR)
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH dlm-tool 1/4] fence: make pkg-config binary as passable make var
  2023-04-11 14:49 [Cluster-devel] [PATCH dlm-tool 1/4] fence: make pkg-config binary as passable make var Alexander Aring
                   ` (2 preceding siblings ...)
  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 ` Fabio M. Di Nitto
  3 siblings, 0 replies; 5+ messages in thread
From: Fabio M. Di Nitto @ 2023-04-14 15:06 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi Alex,

all 4 patches look good to me.

Cheers
Fabio

On 11/04/2023 16.49, Alexander Aring wrote:
> This patch defines PKG_CONFIG make var which could be overwrite by the
> user like it's the case for dlm_controld Makefile.
> ---
>   fence/Makefile | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fence/Makefile b/fence/Makefile
> index ee4dfb88..894f6396 100644
> --- a/fence/Makefile
> +++ b/fence/Makefile
> @@ -19,7 +19,10 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
>   
>   CFLAGS += -fPIE -DPIE
>   CFLAGS += -I../include
> -CFLAGS += $(shell pkg-config --cflags pacemaker-fencing)
> +
> +PKG_CONFIG ?= pkg-config
> +
> +CFLAGS += $(shell $(PKG_CONFIG) --cflags pacemaker-fencing)
>   
>   LDFLAGS += -Wl,-z,relro -Wl,-z,now -pie
>   LDFLAGS += -ldl


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-14 15:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Cluster-devel] [PATCH dlm-tool 2/4] fence: move pkg-config fail to bin target Alexander Aring
2023-04-11 14:49 ` [Cluster-devel] [PATCH dlm-tool 3/4] dlm_controld: " 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

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).