Skip to contentSkip to conversation

Get sh right on OpenSolaris/SPARC

PATCH In review Palle Lyckegaard 3 participants 4 messages Mar 4, 2009 – Mar 17, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Get sh right on OpenSolaris/SPARC

The patch below solves a problem when building qemu on OpenSolaris/SPARC.

"feature_to_c.sh: test: argument expected"

There seemes to be a problem with how "features_to_c.sh" is started from the makefile. On Solaris the shell in /bin/sh is not standards compliant according to http://docs.sun.com/app/docs/doc/816-5165/sh-1?a=view so the patch fixes the configure script so a proper sh in located in /usr/xpg4/bin when building on OpenSolaris. Other platforms defaults to whatever is in the path when configure is running.

Please consider this patch so qemu builds out-of-the-box for OpenSolaris...

Best regards
Palle

------ start of patch

configure (working copy) renamed from configure (revision 6657) +3 -0
Index: configure
===================================================================
@@ -34,6 +34,7 @@
 make="make"
 install="install"
 strip="strip"
+shell="`which sh`"
 
 # parse CC options first
 for opt do
@@ -263,6 +264,7 @@
 SunOS)
     solaris="yes"
     make="gmake"
+    shell="/usr/xpg4/bin/sh"
     install="ginstall"
     needs_libsunmath="no"
     solarisrev=`uname -r | cut -f2 -d.`
@@ -1178,6 +1180,7 @@
 echo "INSTALL=$install" >> $config_mak
 echo "CC=$cc" >> $config_mak
 echo "HOST_CC=$host_cc" >> $config_mak
+echo "SHELL=$shell" >> $config_mak
 echo "AR=$ar" >> $config_mak
 echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
 # XXX: only use CFLAGS and LDFLAGS ?

------ end of patch

#1 lore raw
Quoted 34 lines · Palle Lyckegaard

The patch below solves a problem when building qemu on OpenSolaris/SPARC.

"feature_to_c.sh: test: argument expected"

There seemes to be a problem with how "features_to_c.sh" is started from the makefile. On Solaris the shell in /bin/sh is not standards compliant according to
http://docs.sun.com/app/docs/doc/816-5165/sh-1?a=view so the patch fixes the configure script so a proper sh in located in /usr/xpg4/bin when building on OpenSolaris. Other platforms defaults to whatever is in the path when configure is running.

Please consider this patch so qemu builds out-of-the-box for OpenSolaris...

Best regards
Palle

------ start of patch

Index: configure
===================================================================

configure (working copy) renamed from configure (revision 6657) +1 -0
@@ -34,6 +34,7 @@
 make="make"
 install="install"
 strip="strip"
+shell="`which sh`"
 
 # parse CC options first
 for opt do

configure (working copy) line 267

Quoted 4 lines
configure (working copy) renamed from configure (revision 6657) +1 -0
@@ -263,6 +264,7 @@
 SunOS)
     solaris="yes"
     make="gmake"
+    shell="/usr/xpg4/bin/sh"

This shell is part of package SUNWxcu4. Is this a mandatory or optional package?
If it is optional, many installations won't provide /usr/xpg4/bin/sh.

Regards

Stefan Weil

#2 lore raw
In reply to Palle Lyckegaard
Quoted 8 lines · Palle Lyckegaard

The patch below solves a problem when building qemu on OpenSolaris/SPARC.

"feature_to_c.sh: test: argument expected"

There seemes to be a problem with how "features_to_c.sh" is started from the makefile. On Solaris the shell in /bin/sh is not standards compliant according to http://docs.sun.com/app/docs/doc/816-5165/sh-1?a=view so the patch fixes the configure script so a proper sh in located in /usr/xpg4/bin when building on OpenSolaris. Other platforms defaults to whatever is in the path when configure is running.

Please consider this patch so qemu builds out-of-the-box for OpenSolaris...

Why not change:

test -z "$output"

to

test "x$output" = "x"

Which I believe is a pretty common way to work around this problem.

Regards,

Anthony Liguori

Quoted 39 lines

Best regards
Palle

------ start of patch

Index: configure
===================================================================

configure (working copy) renamed from configure (revision 6657) +3 -1
@@ -34,6 +34,7 @@
 make="make"
 install="install"
 strip="strip"
+shell="`which sh`"
 
 # parse CC options first
 for opt do
@@ -263,6 +264,7 @@
 SunOS)
     solaris="yes"
     make="gmake"
+    shell="/usr/xpg4/bin/sh"
     install="ginstall"
     needs_libsunmath="no"
     solarisrev=`uname -r | cut -f2 -d.`
@@ -1178,6 +1180,7 @@
 echo "INSTALL=$install" >> $config_mak
 echo "CC=$cc" >> $config_mak
 echo "HOST_CC=$host_cc" >> $config_mak
+echo "SHELL=$shell" >> $config_mak
 echo "AR=$ar" >> $config_mak
 echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
 # XXX: only use CFLAGS and LDFLAGS ?
 
 
------ end of patch
#3 lore raw
Quoted 22 lines · Anthony Liguori

Date: Wed, 04 Mar 2009 16:08:51 -0600
From: Anthony Liguori <[email protected]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: [Qemu-devel] [PATCH] Get sh right on OpenSolaris/SPARC

Quoted 8 lines · Palle Lyckegaard

The patch below solves a problem when building qemu on OpenSolaris/SPARC.

"feature_to_c.sh: test: argument expected"

There seemes to be a problem with how "features_to_c.sh" is started from the makefile. On Solaris the shell in /bin/sh is not standards compliant according to http://docs.sun.com/app/docs/doc/816-5165/sh-1?a=view so the patch fixes the configure script so a proper sh in located in /usr/xpg4/bin when building on OpenSolaris. Other platforms defaults to whatever is in the path when configure is running.

Please consider this patch so qemu builds out-of-the-box for OpenSolaris...

Why not change:

test -z "$output"

to

Quoted 7 lines

test "x$output" = "x"

Which I believe is a pretty common way to work around this problem.

Regards,

Anthony Liguori

Hi,

The following patch fixes the feature_to_c.sh problems encountered on Solaris.

Tested on Ubuntu Linux as well...

Please consider applying the patch...

Regards
Palle

feature_to_c.sh (working copy) renamed from feature_to_c.sh (revision 6858) +4 -4
Index: feature_to_c.sh
===================================================================
@@ -24,17 +24,17 @@
 output=$1
 shift
 
-if test -z "$output" || test -z "$1"; then
+if test "x$output" = "x" || test "x$1" = "x"; then
   echo "Usage: $0 OUTPUTFILE INPUTFILE..."
   exit 1
 fi
 
-if test -e "$output"; then
+if test -f "$output"; then
   echo "Output file \"$output\" already exists; refusing to overwrite."
   exit 1
 fi
 
-for input; do
+for input do
   arrayname=xml_feature_`echo $input | sed 's,.*/,,; s/[-.]/_/g'`
 
   ${AWK:-awk} 'BEGIN { n = 0
@@ -68,7 +68,7 @@
 echo "extern const char *const xml_builtin[][2];" >> $output
 echo "const char *const xml_builtin[][2] = {" >> $output
 
-for input; do
+for input do
   basename=`echo $input | sed 's,.*/,,'`
   arrayname=xml_feature_`echo $input | sed 's,.*/,,; s/[-.]/_/g'`
   echo "  { \"$basename\", $arrayname }," >> $output
Quoted 44 lines
Quoted 40 lines

Best regards
Palle

------ start of patch

Index: configure
===================================================================

configure (working copy) renamed from configure (revision 6657) +3 -1
@@ -34,6 +34,7 @@
 make="make"
 install="install"
 strip="strip"
+shell="`which sh`"
 
 # parse CC options first
 for opt do
@@ -263,6 +264,7 @@
 SunOS)
     solaris="yes"
     make="gmake"
+    shell="/usr/xpg4/bin/sh"
     install="ginstall"
     needs_libsunmath="no"
     solarisrev=`uname -r | cut -f2 -d.`
@@ -1178,6 +1180,7 @@
 echo "INSTALL=$install" >> $config_mak
 echo "CC=$cc" >> $config_mak
 echo "HOST_CC=$host_cc" >> $config_mak
+echo "SHELL=$shell" >> $config_mak
 echo "AR=$ar" >> $config_mak
 echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
 # XXX: only use CFLAGS and LDFLAGS ?
 
 
------ end of patch