[kvm-unit-tests PATCH v2 06/10] configure: Add an option to specify getopt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



macOS is shipped with an old non-enhanced version of getopt and it
doesn't support options used by run_tests.sh. Proper version of getopt
is available from homebrew but it has to be added to PATH before invoking
run_tests.sh. It's not convenient because it has to be done in each
shell instance and there could be many if a multiplexor is used.

The change provides a way to override getopt and halts ./configure if
enhanced getopt can't be found.

Cc: Cameron Esfahani <dirty@xxxxxxxxx>
Signed-off-by: Roman Bolshakov <r.bolshakov@xxxxxxxxx>
---
 configure    | 13 +++++++++++++
 run_tests.sh |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 4eb504f..b85420b 100755
--- a/configure
+++ b/configure
@@ -8,6 +8,7 @@ objcopy=objcopy
 objdump=objdump
 ar=ar
 addr2line=addr2line
+getopt=getopt
 arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'`
 host=$arch
 cross_prefix=
@@ -32,6 +33,7 @@ usage() {
 	    --cross-prefix=PREFIX  cross compiler prefix
 	    --cc=CC		   c compiler to use ($cc)
 	    --ld=LD		   ld linker to use ($ld)
+	    --getopt=GETOPT	   enhanced getopt to use ($getopt)
 	    --prefix=PREFIX        where to install things ($prefix)
 	    --endian=ENDIAN        endianness to compile for (little or big, ppc64 only)
 	    --[enable|disable]-pretty-print-stacks
@@ -77,6 +79,9 @@ while [[ "$1" = -* ]]; do
 	--ld)
 	    ld="$arg"
 	    ;;
+	--getopt)
+	    getopt="$arg"
+	    ;;
 	--enable-pretty-print-stacks)
 	    pretty_print_stacks=yes
 	    ;;
@@ -167,6 +172,13 @@ EOF
   rm -f lib-test.{o,S}
 fi
 
+# require enhanced getopt
+$getopt -T > /dev/null
+if [ $? -ne 4 ]; then
+    echo "Enchanced getopt is not available"
+    exit 1
+fi
+
 # Are we in a separate build tree? If so, link the Makefile
 # and shared stuff so that 'make' and run_tests.sh work.
 if test ! -e Makefile; then
@@ -209,6 +221,7 @@ OBJCOPY=$cross_prefix$objcopy
 OBJDUMP=$cross_prefix$objdump
 AR=$cross_prefix$ar
 ADDR2LINE=$cross_prefix$addr2line
+GETOPT=$getopt
 TEST_DIR=$testdir
 FIRMWARE=$firmware
 ENDIAN=$endian
diff --git a/run_tests.sh b/run_tests.sh
index 01e36dc..c4f436b 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -35,7 +35,7 @@ RUNTIME_arch_run="./$TEST_DIR/run"
 source scripts/runtime.bash
 
 only_tests=""
-args=`getopt -u -o ag:htj:v -l all,group:,help,tap13,parallel:,verbose -- $*`
+args=`$GETOPT -u -o ag:htj:v -l all,group:,help,tap13,parallel:,verbose -- $*`
 [ $? -ne 0 ] && exit 2;
 set -- $args;
 while [ $# -gt 0 ]; do
-- 
2.28.0




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux