Skip to contentSkip to conversation

tools: use pkg-config when available to get SSL flags

PATCH New Thomas Petazzoni 2 participants 2 messages May 16, 2015 – May 28, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tools: use pkg-config when available to get SSL flags

Instead of hardcoding -lssl -lcrypto as the flags needed to build mkimage with FIT signature enabled, use pkg-config when available. This allows to properly support cases where static linking is used, which requires linking with -lz, since OpenSSL uses zlib internally.

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

---
Changes since v1:

- Use both libssl and libcrypto when calling pkg-config, because some symbols of libcrypto are used directly by u-boot. This wasn't visible with static linking because -lssl -lcrypto are returned by pkg-config, but was visible with dynamic linking since only -lssl was returned by pkg-config.

 tools/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Makefile +2 -1
index 4bbb153..8ff9c2e 100644
@@ -122,7 +122,8 @@ endif
 
 # MXSImage needs LibSSL
 ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_FIT_SIGNATURE),)
-HOSTLOADLIBES_mkimage += -lssl -lcrypto
+HOSTLOADLIBES_mkimage += \
+	$(shell pkg-config --libs libssl libcrypto 2> /dev/null || echo "-lssl -lcrypto")
 endif
 
 HOSTLOADLIBES_dumpimage := $(HOSTLOADLIBES_mkimage)
Signature · 1 line
2.1.0
#1 lore raw

PATCH v2 1/1 tools: use pkg-config when available to get SSL flags

Quoted 10 lines · Thomas Petazzoni

Instead of hardcoding -lssl -lcrypto as the flags needed to build mkimage with FIT signature enabled, use pkg-config when available. This allows to properly support cases where static linking is used, which requires linking with -lz, since OpenSSL uses zlib internally.

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

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150528/15ed3243/attachment.sig>