Commit 95f9a5c3 authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by Peter Korsgaard
Browse files

uboot-tools: fix static linking with OpenSSL

Add a patch to U-Boot to use pkg-config to get the OpenSSL link flags
when pkg-config is available. This allows to make sure that static
linking works properly. The patch requires adding $(TARGET_MAKE_ENV)
so that the Buildroot provided pkg-config is used instead of the host
one.

The U-Boot patch has been submitted upstream.

Fixes:

  http://autobuild.buildroot.org/results/a9f/a9f316cd076a74b8730ce4cdcdb8176da4ed9eb3/



Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: default avatarGergely Imreh <imrehg@gmail.com>
Signed-off-by: default avatarPeter Korsgaard <peter@korsgaard.com>
parent daa8485b
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
From 7f47f7f8c1a0d634e9febad61504f095476fccc0 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Tue, 12 May 2015 22:54:29 +0200
Subject: [PATCH] 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.

Patch submitted upstream at
http://lists.denx.de/pipermail/u-boot/2015-May/214068.html.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 tools/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/Makefile b/tools/Makefile
index 4bbb153..e1bcd59 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -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 2> /dev/null || echo "-lssl -lcrypto")
 endif
 
 HOSTLOADLIBES_dumpimage := $(HOSTLOADLIBES_mkimage)
-- 
2.1.0
+3 −3
Original line number Diff line number Diff line
@@ -16,14 +16,14 @@ define UBOOT_TOOLS_CONFIGURE_CMDS
endef

define UBOOT_TOOLS_BUILD_CMDS
	$(MAKE) -C $(@D) 			\
	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) 	\
		CROSS_COMPILE="$(TARGET_CROSS)"	\
		CFLAGS="$(TARGET_CFLAGS)"	\
		LDFLAGS="$(TARGET_LDFLAGS)"	\
		CROSS_BUILD_TOOLS=y		\
		CONFIG_FIT_SIGNATURE=$(BR2_PACKAGE_UBOOT_TOOLS_MKIMAGE_FIT_SIGNATURE_SUPPORT) \
		tools-only
	$(MAKE) -C $(@D) 			\
	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) 	\
		CROSS_COMPILE="$(TARGET_CROSS)"	\
		CFLAGS="$(TARGET_CFLAGS)"	\
		LDFLAGS="$(TARGET_LDFLAGS)"	\
@@ -35,7 +35,7 @@ define UBOOT_TOOLS_INSTALL_MKIMAGE
	$(INSTALL) -m 0755 -D $(@D)/tools/mkimage $(TARGET_DIR)/usr/bin/mkimage
endef
ifeq ($(BR2_PACKAGE_UBOOT_TOOLS_MKIMAGE_FIT_SIGNATURE_SUPPORT),y)
UBOOT_TOOLS_DEPENDENCIES += openssl
UBOOT_TOOLS_DEPENDENCIES += openssl host-pkgconf
endif # BR2_PACKAGE_UBOOT_TOOLS_MKIMAGE_FIT_SIGNATURE_SUPPORT
endif # BR2_PACKAGE_UBOOT_TOOLS_MKIMAGE