Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXa0i-0005ce-NS for qemu-devel@nongnu.org; Wed, 20 Jan 2010 07:50:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXa0e-0005ag-12 for qemu-devel@nongnu.org; Wed, 20 Jan 2010 07:50:12 -0500 Received: from [199.232.76.173] (port=54664 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXa0d-0005ad-SG for qemu-devel@nongnu.org; Wed, 20 Jan 2010 07:50:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58744) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NXa0d-0003Rx-CB for qemu-devel@nongnu.org; Wed, 20 Jan 2010 07:50:07 -0500 From: Juan Quintela In-Reply-To: <20100120113741.GA31679@pig.zood.org> (=?utf-8?Q?=22Lo=C3=AFc?= Minier"'s message of "Wed, 20 Jan 2010 12:37:41 +0100") References: <20100117124528.GA24106@bee.dooz.org> <4B531406.2070904@mail.berlios.de> <20100119101119.GA11358@bee.dooz.org> <20100119114750.GB11613@bee.dooz.org> <20100120113741.GA31679@pig.zood.org> Date: Wed, 20 Jan 2010 13:49:54 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: Stop using "which" in ./configure List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Lo=C3=AFc?= Minier Cc: qemu-devel@nongnu.org Lo=C3=AFc Minier wrote: > On Tue, Jan 19, 2010, M=C3=A5ns Rullg=C3=A5rd wrote: > [...] >> Why the extra variable? Using $1 directly seems just as obvious to me. > [...] > > I'm attaching an updated patch which doesn't use this variable. Should > be applied after the sdl-config patch. > >> Is the full path of these tools really important? Doesn't look like >> it to me. > > I'm attaching a new patch which changes the tests a bit; I would prefer > if someone with access to a Solaris build environment would do this > though. Hi could you test this patch? I did it concurrently with yours. my prog_exist() is equal to your has(), and path_of() is only needed in a single place, that I think it is better handled with a single grep in that place. What do you think? >From 4580f69b022e7861bf3be1c694222c0ee82889b7 Mon Sep 17 00:00:00 2001 Message-Id: <4580f69b022e7861bf3be1c694222c0ee82889b7.1263991676.git.quinte= la@redhat.com> In-Reply-To: References: From: Juan Quintela Date: Wed, 20 Jan 2010 13:24:59 +0100 Subject: [PATCH 1/3] substitute all uses of which by type Except in one case, we are only interested in knowing if a command exist, not is path. Just create prog_exists() function that does this check. Signed-off-by: Juan Quintela --- configure | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 5631bbb..c1c9bb4 100755 --- a/configure +++ b/configure @@ -27,6 +27,11 @@ compile_prog() { $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > = /dev/null 2> /dev/null } +prog_exist() { + prog=3D"$1" + type $1 > /dev/null 2> /dev/null +} + # default parameters cpu=3D"" prefix=3D"" @@ -763,21 +768,19 @@ fi # Solaris specific configure tool chain decisions # if test "$solaris" =3D "yes" ; then - solinst=3D`which $install 2> /dev/null | /usr/bin/grep -v "no $install i= n"` - if test -z "$solinst" ; then + if ! prog_exist "$install" ; then echo "Solaris install program not found. Use --install=3D/usr/ucb/inst= all or" echo "install fileutils from www.blastwave.org using pkg-get -i fileut= ils" echo "to get ginstall which is used by default (which lives in /opt/cs= w/bin)" exit 1 fi - if test "$solinst" =3D "/usr/sbin/install" ; then + if type install2 2> /dev/null | grep /usr/bin/install >/dev/null ; then echo "Error: Solaris /usr/sbin/install is not an appropriate install p= rogram." echo "try ginstall from the GNU fileutils available from www.blastwave= .org" echo "using pkg-get -i fileutils, or use --install=3D/usr/ucb/install" exit 1 fi - sol_ar=3D`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"` - if test -z "$sol_ar" ; then + if ! prog_exist "ar" ; then echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then echo "Add /usr/ccs/bin to your path and rerun configure" @@ -969,7 +972,7 @@ fi # pkgconfig probe pkgconfig=3D"${cross_prefix}pkg-config" -if ! test -x "$(which $pkgconfig 2>/dev/null)"; then +if ! prog_exist "$pkgconfig" ; then # likely not cross compiling, or hope for the best pkgconfig=3Dpkg-config fi @@ -977,7 +980,7 @@ fi ########################################## # Sparse probe if test "$sparse" !=3D "no" ; then - if test -x "$(which cgcc 2>/dev/null)"; then + if prog_exist "cgcc" ; then sparse=3Dyes else if test "$sparse" =3D "yes" ; then @@ -1419,8 +1422,8 @@ EOF fi else if test "$kvm" =3D "yes" ; then - if [ -x "`which awk 2>/dev/null`" ] && \ - [ -x "`which grep 2>/dev/null`" ]; then + if prog_exist "awk" -a \ + prog_exist "grep"; then kvmerr=3D`LANG=3DC $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&= 1 \ | grep "error: " \ | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'` @@ -1689,8 +1692,8 @@ fi # Check if tools are available to build documentation. if test "$docs" !=3D "no" ; then - if test -x "`which texi2html 2>/dev/null`" -a \ - -x "`which pod2man 2>/dev/null`" ; then + if prog_exist "texi2html" -a \ + prog_exist "pod2man" ; then docs=3Dyes else if test "$docs" =3D "yes" ; then --=20 1.6.6