[syslinux:firmware] efi: Add a simple script to find gnu-efi files

syslinux-bot for Matt Fleming matt.fleming at intel.com
Thu Nov 15 11:51:08 PST 2012


Commit-ID:  49acaea5184a5f83db3720c30a3f714b3cb65b34
Gitweb:     http://www.syslinux.org/commit/49acaea5184a5f83db3720c30a3f714b3cb65b34
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Wed, 14 Nov 2012 13:18:31 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Thu, 15 Nov 2012 13:06:48 +0000

efi: Add a simple script to find gnu-efi files

The location of the installed gnu-efi libraries and header files
varies wildly with different distributions. We need a way to find the
correct location for a given architecture.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 efi/find-gnu-efi.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
 mk/efi.mk           | 13 +++++++++----
 2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/efi/find-gnu-efi.sh b/efi/find-gnu-efi.sh
new file mode 100755
index 0000000..9620a4f
--- /dev/null
+++ b/efi/find-gnu-efi.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# Find where the gnu-efi package has been installed as this location
+# differs across distributions.
+
+include_dirs="/usr/include /usr/local/include"
+lib_dirs="/usr/lib /usr/lib64 /usr/local/lib"
+
+function find_include()
+{
+    for d in $include_dirs; do
+	found=`find $d -name efi -type d 2> /dev/null`
+	if [ "$found"x != "x" ] && [ -e $found/$ARCH/efibind.h ]; then
+	    echo $found
+	    break;
+	fi
+    done
+}
+
+function find_lib()
+{
+    for d in $lib_dirs; do
+	found=`find $d -name libgnuefi.a 2> /dev/null`
+	if [ "$found"x != "x" ]; then
+	    crt_name='crt0-efi-'$ARCH'.o'
+	    crt=`find $d -name $crt_name 2> /dev/null`
+	    if [ "$crt"x != "x" ]; then
+		echo $d
+		break;
+	    fi
+	fi
+    done
+}
+
+ARCH=$2
+case $1 in
+    include)
+	find_include
+	;;
+    lib)
+	find_lib
+	;;
+esac
diff --git a/mk/efi.mk b/mk/efi.mk
index b13000c..af25f98 100644
--- a/mk/efi.mk
+++ b/mk/efi.mk
@@ -16,16 +16,21 @@ ifeq ($(ARCH),i386)
 	SARCHOPT = -march=i386
 	CARCHOPT = -m32 -march=i386
 	EFI_SUBARCH = ia32
-	LIBDIR = /usr/local/lib
-	EFIINC = /usr/local/include/efi
 endif
 ifeq ($(ARCH),x86_64)
 	SARCHOPT = -march=x86-64
 	CARCHOPT = -m64 -march=x86-64
 	EFI_SUBARCH = $(ARCH)
-	EFIINC = /usr/include/efi
-	LIBDIR=/usr/lib64
 endif
+
+EFIINC = $(shell $(topdir)/efi//find-gnu-efi.sh include $(EFI_SUBARCH))
+$(if $(EFIINC),, \
+	$(error Missing $(EFI_SUBARCH) gnu-efi header files))
+
+LIBDIR = $(shell $(topdir)/efi/find-gnu-efi.sh lib $(EFI_SUBARCH))
+$(if $(LIBDIR),, \
+	$(error Missing $(EFI_SUBARCH) gnu-efi libraries))
+
 #LIBDIR=/usr/lib
 FORMAT=efi-app-$(EFI_SUBARCH)
 


More information about the Syslinux-commits mailing list