All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: "Loïc Minier" <lool@dooz.org>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: Stop using "which" in ./configure
Date: Wed, 20 Jan 2010 13:49:54 +0100	[thread overview]
Message-ID: <m3pr55aqkt.fsf@neno.neno> (raw)
In-Reply-To: <20100120113741.GA31679@pig.zood.org> ("Loïc Minier"'s message of "Wed, 20 Jan 2010 12:37:41 +0100")

Loïc Minier <lool@dooz.org> wrote:
> On Tue, Jan 19, 2010, Måns Rullgård 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.quintela@redhat.com>
In-Reply-To: <cover.1263991676.git.quintela@redhat.com>
References: <cover.1263991676.git.quintela@redhat.com>
From: Juan Quintela <quintela@redhat.com>
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 <quintela@redhat.com>
---
 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="$1"
+    type $1 > /dev/null 2> /dev/null
+}
+
 # default parameters
 cpu=""
 prefix=""
@@ -763,21 +768,19 @@ fi
 # Solaris specific configure tool chain decisions
 #
 if test "$solaris" = "yes" ; then
-  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
-  if test -z "$solinst" ; then
+  if ! prog_exist "$install" ; then
     echo "Solaris install program not found. Use --install=/usr/ucb/install or"
     echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
     echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
     exit 1
   fi
-  if test "$solinst" = "/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 program."
     echo "try ginstall from the GNU fileutils available from www.blastwave.org"
     echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
     exit 1
   fi
-  sol_ar=`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="${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=pkg-config
 fi
@@ -977,7 +980,7 @@ fi
 ##########################################
 # Sparse probe
 if test "$sparse" != "no" ; then
-  if test -x "$(which cgcc 2>/dev/null)"; then
+  if prog_exist "cgcc" ; then
     sparse=yes
   else
     if test "$sparse" = "yes" ; then
@@ -1419,8 +1422,8 @@ EOF
     fi
   else
     if test "$kvm" = "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=`LANG=C $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" != "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=yes
   else
     if test "$docs" = "yes" ; then
-- 
1.6.6

  parent reply	other threads:[~2010-01-20 12:50 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-17 12:45 [Qemu-devel] [PATCH] Check for sdl-config before calling it Loïc Minier
2010-01-17 13:17 ` [Qemu-devel] " Måns Rullgård
2010-01-17 13:43   ` Stefan Weil
2010-01-17 14:39     ` Måns Rullgård
2010-01-19 10:11       ` [Qemu-devel] Stop using "which" in ./configure Loïc Minier
2010-01-19 11:47         ` Loïc Minier
2010-01-19 17:42           ` Stefan Weil
2010-01-20  9:02             ` Loïc Minier
2010-01-19 18:09           ` [Qemu-devel] " Måns Rullgård
2010-01-20 11:37             ` Loïc Minier
2010-01-20 12:19               ` Paolo Bonzini
2010-01-20 13:49                 ` Loïc Minier
2010-01-20 14:18                   ` Paolo Bonzini
2010-01-20 16:51                     ` Loïc Minier
2010-01-20 18:11                       ` Måns Rullgård
2010-01-21  8:44                         ` Loïc Minier
2010-01-21  9:48                           ` Juan Quintela
2010-01-21 12:14                             ` Måns Rullgård
2010-01-26 16:47                               ` Loïc Minier
2010-01-26 19:16                                 ` Blue Swirl
2010-01-27 12:10                                   ` [Qemu-devel] [PATCH 1/3] Check for sdl-config before calling it Loïc Minier
2010-01-27 12:10                                     ` [Qemu-devel] [PATCH 2/3] Add and use has() and path_of() funcs Loïc Minier
2010-01-27 12:10                                       ` [Qemu-devel] [PATCH 3/3] Solaris: test for presence of commands with has() Loïc Minier
2010-01-27 12:47                                     ` [Qemu-devel] [PATCH 1/3] Check for sdl-config before calling it Ben Taylor
2010-01-27 13:02                                       ` [Qemu-devel] " Paolo Bonzini
2010-01-27 12:41                                   ` [Qemu-devel] Re: Stop using "which" in ./configure Loïc Minier
2010-01-27 17:54                                     ` Blue Swirl
2010-01-28 20:33                                       ` Loïc Minier
2010-01-28 21:30                                         ` Blue Swirl
2010-01-21 16:53                         ` Jamie Lokier
2010-01-21 20:12                           ` Paolo Bonzini
2010-01-20 12:49               ` Juan Quintela [this message]
2010-01-20 13:16                 ` Paolo Bonzini
2010-01-20 13:54                 ` Loïc Minier
2010-01-20 14:06               ` Loïc Minier
2010-01-17 13:36 ` [Qemu-devel] [PATCH] Check for sdl-config before calling it Stefan Weil
2010-01-17 16:06   ` Loïc Minier
2010-01-18 11:35     ` [Qemu-devel] " Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2010-01-19 10:35 [Qemu-devel] Stop using "which" in ./configure Laurent Vivier
2010-01-19 18:01 ` [Qemu-devel] " Måns Rullgård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3pr55aqkt.fsf@neno.neno \
    --to=quintela@redhat.com \
    --cc=lool@dooz.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.