aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-12-10 21:33:53 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-12-10 22:14:06 +0000
commit6e8321066866bf41a91e095fa9421d24dbb886c0 (patch)
tree60dcf581baaf5536f04a6eaf41bf9b0c560e4819
parent3367502e5ca5004c775d1b8b8f7d981df3ea2ba1 (diff)
downloadhdt-6e8321066866bf41a91e095fa9421d24dbb886c0.tar.gz
hdt-6e8321066866bf41a91e095fa9421d24dbb886c0.tar.xz
hdt-6e8321066866bf41a91e095fa9421d24dbb886c0.zip
efi: Add build scripts for gnu-efi
Now that we have a gnu-efi git submodule we need some scripts to build and install it into architecture-specific build directories. This actually simplifies things a bit because we no longer need to account for the variations in distribution installation paths - we now control the paths. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rwxr-xr-xefi/build-gnu-efi.sh18
-rwxr-xr-xefi/check-gnu-efi.sh11
-rwxr-xr-xefi/find-gnu-efi.sh43
-rw-r--r--mk/efi.mk21
4 files changed, 35 insertions, 58 deletions
diff --git a/efi/build-gnu-efi.sh b/efi/build-gnu-efi.sh
new file mode 100755
index 00000000..e90b714d
--- /dev/null
+++ b/efi/build-gnu-efi.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+ARCH=$1
+objdir=$2
+topdir=$3
+
+pushd $topdir
+git submodule init
+git submodule update
+
+cd gnu-efi/gnu-efi-3.0/
+
+make ARCH=$ARCH
+
+make ARCH=$ARCH PREFIX=$objdir install
+make ARCH=$ARCH clean
+
+popd
diff --git a/efi/check-gnu-efi.sh b/efi/check-gnu-efi.sh
new file mode 100755
index 00000000..719e9452
--- /dev/null
+++ b/efi/check-gnu-efi.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+ARCH=$1
+
+if [ ! -f $objdir/include/$ARCH/efibind.h ]; then
+ # Build the external project with a clean make environment, as
+ # Syslinux disables built-in implicit rules.
+ export MAKEFLAGS=
+
+ $topdir/efi/build-gnu-efi.sh $ARCH $objdir $topdir &> /dev/null
+fi
diff --git a/efi/find-gnu-efi.sh b/efi/find-gnu-efi.sh
deleted file mode 100755
index bf203d84..00000000
--- a/efi/find-gnu-efi.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/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 /usr/lib32"
-
-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
-}
-
-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 a0c33ac4..e12e0a66 100644
--- a/mk/efi.mk
+++ b/mk/efi.mk
@@ -7,11 +7,9 @@ core = $(topdir)/core
# Set up architecture specifics; for cross compilation, set ARCH as apt
# gnuefi sets up architecture specifics in ia32 or x86_64 sub directories
# set up the LIBDIR and EFIINC for building for the appropriate architecture
-# For now, the following assumptions are made:
-# 1. gnu-efi lib for IA32 is installed in /usr/local/lib
-# and the include files in /usr/local/include/efi.
-# 2. gnu-efi lib for x86_64 is installed in /usr/lib
-# and the include files in /usr/include/efi.
+EFIINC = $(objdir)/include/efi
+LIBDIR = $(objdir)/lib
+
ifeq ($(ARCH),i386)
SARCHOPT = -march=i386
CARCHOPT = -m32 -march=i386
@@ -23,13 +21,7 @@ ifeq ($(ARCH),x86_64)
EFI_SUBARCH = $(ARCH)
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))
+$(shell $(topdir)/efi/check-gnu-efi.sh $(EFI_SUBARCH))
#LIBDIR=/usr/lib
FORMAT=efi-app-$(EFI_SUBARCH)
@@ -44,9 +36,8 @@ CFLAGS = -I$(EFIINC) -I$(EFIINC)/$(EFI_SUBARCH) \
-DLDLINUX=\"$(LDLINUX)\" -fvisibility=hidden \
-Wno-unused-parameter
-# gnuefi sometimes installs these under a gnuefi/ directory, and sometimes not
-CRT0 := $(shell find $(LIBDIR) -name crt0-efi-$(EFI_SUBARCH).o 2>/dev/null | tail -n1)
-LDSCRIPT := $(shell find $(LIBDIR) -name elf_$(EFI_SUBARCH)_efi.lds 2>/dev/null | tail -n1)
+CRT0 := $(LIBDIR)/crt0-efi-$(EFI_SUBARCH).o
+LDSCRIPT := $(LIBDIR)/elf_$(EFI_SUBARCH)_efi.lds
LDFLAGS = -T $(SRC)/$(ARCH)/syslinux.ld -Bsymbolic -pie -nostdlib -znocombreloc \
-L$(LIBDIR) --hash-style=gnu -m elf_$(ARCH) $(CRT0) -E