From 21f87c2b1eb456100f953ce6199dbcd61c85c45c Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Mon, 24 Jun 2024 16:12:10 +0100 Subject: [PATCH] Fixup riscv64 objcopy move Detect new enough objcopy Signed-off-by: Callum Farmer --- Make.defaults | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Make.defaults b/Make.defaults index 2edcb02..fe5351b 100755 --- a/Make.defaults +++ b/Make.defaults @@ -117,6 +117,14 @@ GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \ && [ $(GCCMINOR) -ge "7" ] ) ) \ && echo 1) +PART_ONE = $(shell echo "$(1)" | cut -f1 -d.) +PART_TWO = $(shell echo "$(1)" | cut -f2 -d.) + +IS_NEW_ENOUGH = $(shell ( [ $(call PART_ONE,$(1)) -gt "$(2)" ] \ + || ( [ $(call PART_ONE,$(1)) -eq "$(2)" ] \ + && [ $(call PART_TWO,$(1)) -ge "$(3)" ] ) ) \ + && echo 1) + # # Where to build the package # @@ -176,6 +184,9 @@ endif # Set HAVE_EFI_OBJCOPY if objcopy understands --target efi-[app|bsdrv|rtdrv], # otherwise we need to compose the PE/COFF header using the assembler # + +OBJCOPY_VERSION := $(shell $(OBJCOPY) --version | head -n 1 | awk '{print $$(NF)}') + ifneq ($(ARCH),arm) ifneq ($(ARCH),mips64el) export HAVE_EFI_OBJCOPY=y @@ -183,8 +194,16 @@ endif endif ifeq ($(ARCH),riscv64) +ifneq ($(call IS_NEW_ENOUGH,$(OBJCOPY_VERSION),2,42),1) export SYSTEM_HAS_EFI_OBJCOPY ?= 0 endif +endif + +ifeq ($(ARCH),aarch64) +ifneq ($(call IS_NEW_ENOUGH,$(OBJCOPY_VERSION),2,38),1) +export SYSTEM_HAS_EFI_OBJCOPY ?= 0 +endif +endif ifeq ($(HAVE_EFI_OBJCOPY),y) export SYSTEM_HAS_EFI_OBJCOPY ?= 1