Skip to contentSkip to conversation

tools: mkeficapsule: use pkg-config to get -luuid and -lgnutls

PATCH Superseded Heiko Thiery 3 participants 11 messages Jul 19, 2022 – Jul 20, 2022

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tools: mkeficapsule: use pkg-config to get -luuid and -lgnutls

Instead of hardcoding -luuid -lgnutls as the flags needed to build mkeficapsule, use pkg-config when available.

We gracefully fallback on the previous behavior of hardcoding -luuid -lgnutls if pkg-config is not available or fails with an error.

---
 tools/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Makefile +2 -1
index 9f2339666a..9f6b282ad8 100644
@@ -242,7 +242,8 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
 hostprogs-$(CONFIG_ASN1_COMPILER)	+= asn1_compiler
 HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
 
-HOSTLDLIBS_mkeficapsule += -lgnutls -luuid
+HOSTLDLIBS_mkeficapsule += \
+	$(shell pkg-config --libs gnutls uuid 2> /dev/null || echo "-lgnutls -luuid")
 hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule
 
 # We build some files with extra pedantic flags to try to minimize things
Signature · 1 line
2.30.2
#1 lore raw

PATCH 2/2 tools: kwboot: use pkg-config to get -ltinfo

Instead of hardcoding -ltinfo as the flags needed to build kwboot, use pkg-config when available.

We gracefully fallback on the previous behavior of hardcoding -ltinfo if pkg-config is not available or fails with an error.

---
 tools/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/Makefile +3 -1
index 9f6b282ad8..45195a8ce7 100644
@@ -198,7 +198,9 @@ hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
 HOSTCFLAGS_mkexynosspl.o := -pedantic
 
 HOSTCFLAGS_kwboot.o += -pthread
-HOSTLDLIBS_kwboot += -pthread -ltinfo
+HOSTLDLIBS_kwboot += -pthread
+HOSTLDLIBS_kwboot += \
+	$(shell pkg-config --libs tinfo 2> /dev/null || echo "-ltinfo")
 
 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
 hostprogs-$(CONFIG_X86) += ifdtool
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH 2/2] tools: kwboot: use pkg-config to get -ltinfo

Quoted 2 lines · On Tuesday 19 July 2022 20:38:39 Heiko Thiery wrote:

Instead of hardcoding -ltinfo as the flags needed to build kwboot, use pkg-config when available.

Interesting, I did not know that there is pc file also for tinfo. Anyway when using it, there should be also HOSTCFLAGS_kwboot definition from pkg-config.

Quoted 26 lines

We gracefully fallback on the previous behavior of hardcoding -ltinfo if pkg-config is not available or fails with an error.

---
 tools/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/Makefile +3 -1
index 9f6b282ad8..45195a8ce7 100644
@@ -198,7 +198,9 @@ hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
 HOSTCFLAGS_mkexynosspl.o := -pedantic
 
 HOSTCFLAGS_kwboot.o += -pthread
-HOSTLDLIBS_kwboot += -pthread -ltinfo
+HOSTLDLIBS_kwboot += -pthread
+HOSTLDLIBS_kwboot += \
+	$(shell pkg-config --libs tinfo 2> /dev/null || echo "-ltinfo")
 
 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
 hostprogs-$(CONFIG_X86) += ifdtool
Signature · 1 line
2.30.2
#3 lore raw

Re: [PATCH 2/2] tools: kwboot: use pkg-config to get -ltinfo

Hi,

Am Di., 19. Juli 2022 um 20:52 Uhr schrieb Pali Rohár <[email protected]>:

Quoted 8 lines · On Tuesday 19 July 2022 20:38:39 Heiko Thiery wrote:
Quoted 2 lines

Instead of hardcoding -ltinfo as the flags needed to build kwboot, use pkg-config when available.

Interesting, I did not know that there is pc file also for tinfo. Anyway when using it, there should be also HOSTCFLAGS_kwboot definition from pkg-config.

Just checked the cflags for tinfo.

# pkg-config --cflags tinfo
-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600

Can we also add that to kwboot?

Quoted 22 lines
Quoted 22 lines

We gracefully fallback on the previous behavior of hardcoding -ltinfo if pkg-config is not available or fails with an error.

---
 tools/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/Makefile +3 -1
index 9f6b282ad8..45195a8ce7 100644
@@ -198,7 +198,9 @@ hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
 HOSTCFLAGS_mkexynosspl.o := -pedantic
 
 HOSTCFLAGS_kwboot.o += -pthread
-HOSTLDLIBS_kwboot += -pthread -ltinfo
+HOSTLDLIBS_kwboot += -pthread
+HOSTLDLIBS_kwboot += \
+     $(shell pkg-config --libs tinfo 2> /dev/null || echo "-ltinfo")
 
Quoted 5 lines
Quoted 5 lines
tools/Makefile +0 -1
 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
 hostprogs-$(CONFIG_X86) += ifdtool
--

2.30.2

--
Heiko

#4 lore raw

Re: [PATCH 2/2] tools: kwboot: use pkg-config to get -ltinfo

Quoted 8 lines · On Tuesday 19 July 2022 21:11:21 Heiko Thiery wrote:

Hi,

Am Di., 19. Juli 2022 um 20:52 Uhr schrieb Pali Rohár <[email protected]>:

Quoted 5 lines · On Tuesday 19 July 2022 20:38:39 Heiko Thiery wrote:
Quoted 2 lines

Instead of hardcoding -ltinfo as the flags needed to build kwboot, use pkg-config when available.

Quoted 8 lines
Quoted 3 lines

Interesting, I did not know that there is pc file also for tinfo. Anyway when using it, there should be also HOSTCFLAGS_kwboot definition from pkg-config.

Just checked the cflags for tinfo.

# pkg-config --cflags tinfo
-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600

I think these two flags are harmless...

Quoted 1 line

Can we also add that to kwboot?

... but now it reminds me that we have issues with tinfo header files which are in direct conflict with linux uapi termbits header files. And so kwboot.c does not include any tinfo header file.

Therefore tinfo cflags are not used at all.

So I would rather stick with not importing --cflags to prevent possible future incompatibility (in case into tinfo cflags in future would be added something which conflict with linux uapi header files). We do not need them at all.

Quoted 30 lines
Quoted 22 lines
Quoted 22 lines

We gracefully fallback on the previous behavior of hardcoding -ltinfo if pkg-config is not available or fails with an error.

---
 tools/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/Makefile +3 -1
index 9f6b282ad8..45195a8ce7 100644
@@ -198,7 +198,9 @@ hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
 HOSTCFLAGS_mkexynosspl.o := -pedantic
 
 HOSTCFLAGS_kwboot.o += -pthread
-HOSTLDLIBS_kwboot += -pthread -ltinfo
+HOSTLDLIBS_kwboot += -pthread
+HOSTLDLIBS_kwboot += \
+     $(shell pkg-config --libs tinfo 2> /dev/null || echo "-ltinfo")
 
Quoted 5 lines
Quoted 5 lines
tools/Makefile +0 -1
 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
 hostprogs-$(CONFIG_X86) += ifdtool
--

2.30.2

--
Heiko

Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] tools: kwboot: use pkg-config to get -ltinfo

In reply to Heiko Thiery
Quoted 7 lines · On Tuesday 19 July 2022 20:38:39 Heiko Thiery wrote:

Instead of hardcoding -ltinfo as the flags needed to build kwboot, use pkg-config when available.

We gracefully fallback on the previous behavior of hardcoding -ltinfo if pkg-config is not available or fails with an error.

So... in current form this patch is OK.

Quoted 22 lines
---
 tools/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/Makefile +3 -1
index 9f6b282ad8..45195a8ce7 100644
@@ -198,7 +198,9 @@ hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
 HOSTCFLAGS_mkexynosspl.o := -pedantic
 
 HOSTCFLAGS_kwboot.o += -pthread
-HOSTLDLIBS_kwboot += -pthread -ltinfo
+HOSTLDLIBS_kwboot += -pthread
+HOSTLDLIBS_kwboot += \
+	$(shell pkg-config --libs tinfo 2> /dev/null || echo "-ltinfo")
 
 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
 hostprogs-$(CONFIG_X86) += ifdtool
Signature · 1 line
2.30.2
#6 lore raw

Re: [PATCH 2/2] tools: kwboot: use pkg-config to get -ltinfo

Hi,

Am Di., 19. Juli 2022 um 21:20 Uhr schrieb Pali Rohár <[email protected]>:

Quoted 11 lines · On Tuesday 19 July 2022 20:38:39 Heiko Thiery wrote:
Quoted 7 lines

Instead of hardcoding -ltinfo as the flags needed to build kwboot, use pkg-config when available.

We gracefully fallback on the previous behavior of hardcoding -ltinfo if pkg-config is not available or fails with an error.

So... in current form this patch is OK.

I already sent a v2 that introduced the cflags. I will send a v3 that removes adding this again. Ok?

Quoted 24 lines
Quoted 22 lines
---
 tools/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/Makefile +3 -2
index 9f6b282ad8..45195a8ce7 100644
@@ -198,7 +198,9 @@ hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
 HOSTCFLAGS_mkexynosspl.o := -pedantic
 
 HOSTCFLAGS_kwboot.o += -pthread
-HOSTLDLIBS_kwboot += -pthread -ltinfo
+HOSTLDLIBS_kwboot += -pthread
+HOSTLDLIBS_kwboot += \
+     $(shell pkg-config --libs tinfo 2> /dev/null || echo "-ltinfo")
 
 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
 hostprogs-$(CONFIG_X86) += ifdtool
--

2.30.2

#7 lore raw

Re: [PATCH 2/2] tools: kwboot: use pkg-config to get -ltinfo

Quoted 12 lines · On Wednesday 20 July 2022 08:06:28 Heiko Thiery wrote:

Hi,

Am Di., 19. Juli 2022 um 21:20 Uhr schrieb Pali Rohár <[email protected]>:

Quoted 8 lines · On Tuesday 19 July 2022 20:38:39 Heiko Thiery wrote:
Quoted 6 lines

Instead of hardcoding -ltinfo as the flags needed to build kwboot, use pkg-config when available.

We gracefully fallback on the previous behavior of hardcoding -ltinfo if pkg-config is not available or fails with an error.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

So... in current form this patch is OK.

I already sent a v2 that introduced the cflags. I will send a v3 that removes adding this again. Ok?

Ou, sorry for that :-(

Anyway, details about this issue are described here:
https://source.denx.de/u-boot/u-boot/-/blob/master/tools/termios_linux.h
https://source.denx.de/u-boot/u-boot/-/commit/e8d26e8276358fcd1c2fe28293d3b4c82a735731

Quoted 24 lines
Quoted 24 lines
Quoted 22 lines
---
 tools/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/Makefile +3 -2
index 9f6b282ad8..45195a8ce7 100644
@@ -198,7 +198,9 @@ hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
 HOSTCFLAGS_mkexynosspl.o := -pedantic
 
 HOSTCFLAGS_kwboot.o += -pthread
-HOSTLDLIBS_kwboot += -pthread -ltinfo
+HOSTLDLIBS_kwboot += -pthread
+HOSTLDLIBS_kwboot += \
+     $(shell pkg-config --libs tinfo 2> /dev/null || echo "-ltinfo")
 
 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
 hostprogs-$(CONFIG_X86) += ifdtool
--

2.30.2

#8 lore raw
In reply to Heiko Thiery
Quoted 16 lines · On Tuesday 19 July 2022 20:38:37 Heiko Thiery wrote:

Instead of hardcoding -luuid -lgnutls as the flags needed to build mkeficapsule, use pkg-config when available.

We gracefully fallback on the previous behavior of hardcoding -luuid -lgnutls if pkg-config is not available or fails with an error.

---
 tools/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Makefile +0 -0
index 9f2339666a..9f6b282ad8 100644

tools/Makefile hostprogs-$(CONFIG_MIPS) += mips-relocs · line 246

Quoted 6 lines
tools/Makefile +2 -1
@@ -242,7 +242,8 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
 hostprogs-$(CONFIG_ASN1_COMPILER)	+= asn1_compiler
 HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
 
-HOSTLDLIBS_mkeficapsule += -lgnutls -luuid
+HOSTLDLIBS_mkeficapsule += \
+	$(shell pkg-config --libs gnutls uuid 2> /dev/null || echo "-lgnutls -luuid")

When using pkg-config then you should add also --cflags into HOSTCFLAGS_

Quoted 6 lines
tools/Makefile +0 -0
 hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule
 
 # We build some files with extra pedantic flags to try to minimize things
Signature · 1 line
2.30.2
#9 lore raw

Hi,

Am Di., 19. Juli 2022 um 20:51 Uhr schrieb Pali Rohár <[email protected]>:

Quoted 21 lines · On Tuesday 19 July 2022 20:38:37 Heiko Thiery wrote:
Quoted 19 lines

Instead of hardcoding -luuid -lgnutls as the flags needed to build mkeficapsule, use pkg-config when available.

We gracefully fallback on the previous behavior of hardcoding -luuid -lgnutls if pkg-config is not available or fails with an error.

---
 tools/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Makefile +0 -0
index 9f2339666a..9f6b282ad8 100644
@@ -242,7 +242,8 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
 hostprogs-$(CONFIG_ASN1_COMPILER)    += asn1_compiler
 HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
 
Quoted 5 lines

tools/Makefile hostprogs-$(CONFIG_MIPS) += mips-relocs · line 246

Quoted 3 lines
tools/Makefile +2 -1
-HOSTLDLIBS_mkeficapsule += -lgnutls -luuid
+HOSTLDLIBS_mkeficapsule += \
+     $(shell pkg-config --libs gnutls uuid 2> /dev/null || echo "-lgnutls -luuid")

When using pkg-config then you should add also --cflags into HOSTCFLAGS_

Will add the cflags accordingly.

Quoted 6 lines
Quoted 6 lines
tools/Makefile +0 -1
 hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule
 
 # We build some files with extra pedantic flags to try to minimize things
--

2.30.2

Reviewed-by on v1 1/2
#10 lore raw
In reply to Heiko Thiery
Quoted 16 lines · Heiko Thiery

Instead of hardcoding -luuid -lgnutls as the flags needed to build mkeficapsule, use pkg-config when available.

We gracefully fallback on the previous behavior of hardcoding -luuid -lgnutls if pkg-config is not available or fails with an error.

---
  tools/Makefile | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
tools/Makefile +0 -0
index 9f2339666a..9f6b282ad8 100644

tools/Makefile hostprogs-$(CONFIG_MIPS) += mips-relocs · line 249

Quoted 9 lines
tools/Makefile +2 -1
@@ -242,7 +242,8 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
  hostprogs-$(CONFIG_ASN1_COMPILER)	+= asn1_compiler
  HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
 
-HOSTLDLIBS_mkeficapsule += -lgnutls -luuid
+HOSTLDLIBS_mkeficapsule += \
+	$(shell pkg-config --libs gnutls uuid 2> /dev/null || echo "-lgnutls -luuid")
  hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule
 
  # We build some files with extra pedantic flags to try to minimize things

We already do the same for mkimage build flags.