[syslinux:firmware] efi: Make the gnu-efi build scripts more portable

syslinux-bot for Matt Fleming matt.fleming at intel.com
Wed Jan 8 03:06:07 PST 2014


Commit-ID:  9ab3608ba4a51e234f251d84f764f39f20e4ded3
Gitweb:     http://www.syslinux.org/commit/9ab3608ba4a51e234f251d84f764f39f20e4ded3
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Wed, 8 Jan 2014 10:10:36 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Wed, 8 Jan 2014 10:57:37 +0000

efi: Make the gnu-efi build scripts more portable

Not all distributions point /bin/sh at /bin/bash, so remove some
bashisms (pushd/popd) and require that build-gnu-efi.sh be run from the
Syslinux object directory.

Also, swap realpath(1) for readlink(1) because the former isn't
available on Debian.

Reported-by: Ferenc Wagner <wferi at niif.hu>
Reported-by: Celelibi <celelibi at gmail.com>
Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 efi/build-gnu-efi.sh | 17 ++++++++++-------
 efi/check-gnu-efi.sh | 13 +++++--------
 mk/efi.mk            |  3 +--
 3 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/efi/build-gnu-efi.sh b/efi/build-gnu-efi.sh
index 3844e75..f9bab98 100755
--- a/efi/build-gnu-efi.sh
+++ b/efi/build-gnu-efi.sh
@@ -5,14 +5,13 @@ set -e
 # Initialise the gnu-efi submodule and ensure the source is up-to-date.
 # Then build and install it for the given architecture.
 
-if [ $# -lt 3 ]; then
+if [ $# -lt 2 ]; then
 cat <<EOF
-Usage: $0: <arch> <srcdir> <objdir>
+Usage: $0: <arch> <objdir>
 
 Build the <arch> gnu-efi libs and header files and install in <objdir>.
 
   <arch>   - A gnu-efi \$ARCH argument, i.e. ia32, x86_64
-  <srcdir> - The top-level directory of the Syslinux source
   <objdir> - The Syslinux object directory
 
 EOF
@@ -20,10 +19,14 @@ EOF
 fi
 
 ARCH=$1
-srcdir=`realpath $2`
-objdir=`realpath $3`
+objdir=`readlink -f $2`
 
-pushd $srcdir
+if [ ! -e ../version.h ]; then
+    printf "build-gnu-efi.sh: Cannot be run outside Syslinux object tree\n"
+    exit 1
+fi
+
+cd ../..
 git submodule init
 git submodule update
 
@@ -34,4 +37,4 @@ make ARCH=$ARCH
 make ARCH=$ARCH PREFIX=$objdir install
 make ARCH=$ARCH clean
 
-popd
+cd $objdir/efi
diff --git a/efi/check-gnu-efi.sh b/efi/check-gnu-efi.sh
index fcf5fd4..dc3b691 100755
--- a/efi/check-gnu-efi.sh
+++ b/efi/check-gnu-efi.sh
@@ -3,15 +3,14 @@
 # Verify that gnu-efi is installed in the object directory for our
 # firmware. If it isn't, build it.
 
-if [ $# -lt 3 ]; then
+if [ $# -lt 2 ]; then
 cat <<EOF
-Usage: $0: <arch> <srcdir> <objdir>
+Usage: $0: <arch> <objdir>
 
 Check for gnu-efi libraries and header files in <objdir> and, if none
 exist, build and install them.
 
   <arch>   - A gnu-efi \$ARCH argument, i.e. ia32, x86_64
-  <srcdir> - The top-level directory of the Syslinux source
   <objdir> - The Syslinux object directory
 
 EOF
@@ -19,20 +18,18 @@ EOF
 fi
 
 ARCH=$1
-srcdir=`realpath $2`
-objdir=`realpath $3`
+objdir=$2
 
 if [ ! -f $objdir/include/efi/$ARCH/efibind.h ]; then
     # Build the external project with a clean make environment, as
     # Syslinux disables built-in implicit rules.
     export MAKEFLAGS=
 
-    build=$srcdir/efi/build-gnu-efi.sh
-    $build $ARCH $srcdir $objdir &> /dev/null
+    ../../efi/build-gnu-efi.sh $ARCH $objdir &> /dev/null
     if [ $? -ne 0 ]; then
 	printf "Failed to build gnu-efi. "
 	printf "Execute the following command for full details: \n\n"
-	printf "$build $ARCH $srcdir $objdir\n\n"
+	printf "build-gnu-efi.sh $ARCH $objdir\n\n"
 
 	exit 1
     fi
diff --git a/mk/efi.mk b/mk/efi.mk
index 82bd51f..9377637 100644
--- a/mk/efi.mk
+++ b/mk/efi.mk
@@ -21,8 +21,7 @@ ifeq ($(ARCH),x86_64)
 	EFI_SUBARCH = $(ARCH)
 endif
 
-output = $(shell $(topdir)/efi/check-gnu-efi.sh $(EFI_SUBARCH) \
-		$(topdir) $(objdir))
+output = $(shell $(topdir)/efi/check-gnu-efi.sh $(EFI_SUBARCH) $(objdir))
 ifneq ($(output),)
 $(error Failed to build gnu-efi for $(EFI_SUBARCH))
 endif


More information about the Syslinux-commits mailing list