From patchwork Sat Jan 25 14:11:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Forsman?= X-Patchwork-Id: 314144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 074A32C009C for ; Sun, 26 Jan 2014 01:12:12 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 19C932F9BF; Sat, 25 Jan 2014 14:12:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0todDE0ImW3H; Sat, 25 Jan 2014 14:12:09 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id D403F266A5; Sat, 25 Jan 2014 14:12:08 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 139AC1BF94F for ; Sat, 25 Jan 2014 14:12:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 083438AFBE for ; Sat, 25 Jan 2014 14:12:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SSMaiNN66XTR for ; Sat, 25 Jan 2014 14:12:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ea0-f180.google.com (mail-ea0-f180.google.com [209.85.215.180]) by whitealder.osuosl.org (Postfix) with ESMTPS id B26D089CB9 for ; Sat, 25 Jan 2014 14:12:06 +0000 (UTC) Received: by mail-ea0-f180.google.com with SMTP id o10so926199eaj.39 for ; Sat, 25 Jan 2014 06:12:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=+Wg1czUfgaX3cQxT6Tk7yPvhGPPtUZDevftZFI+vCnE=; b=SyQXBLbijvtG1TkNiReRQQG84FEddH3dKG6w6RvwSKxKBd+7j5XNHLwlWNCCyULxV7 lTbgV0zm39fJAHrxzdLPBGpUt4Ngw9J3Vt8K1rqZxCuwFnNM7eqobKETiezmWlAjAqPA +ew7Wk3/1MpnofmE0+Bq8XLfMKwC2JNRHd2TmWN85GXAu6CR4X7ftGGS6DMtPJBXIS6L VRB3Sm67PrhwtuIkLZg8MNbWZ7F3sxsKHpS1xPV+dOHXWurXT9G4DXg4AjRgTuAYRy5o SHDvoaI5EuYppJ9U/wSyygsFFr+F4WZFWr5cTb6GiuEuRkOBXAvSiwPuoXiAxfMQlS5s x7hg== X-Received: by 10.15.32.73 with SMTP id z49mr17497493eeu.27.1390659125281; Sat, 25 Jan 2014 06:12:05 -0800 (PST) Received: from localhost (cm-84.208.207.142.getinternet.no. [84.208.207.142]) by mx.google.com with ESMTPSA id v7sm16461124eel.2.2014.01.25.06.12.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Jan 2014 06:12:04 -0800 (PST) From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= To: buildroot@busybox.net Date: Sat, 25 Jan 2014 15:11:56 +0100 Message-Id: <1390659116-18865-1-git-send-email-bjorn.forsman@gmail.com> X-Mailer: git-send-email 1.8.5.2 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 1/1] Prefer 'command -v' over 'which' (for portability) X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net 'command -v' is defined by POSIX (and is available "everywhere"), 'which' is not. This is improves user experience when 'which' isn't installed so that there won't be error messages about missing 'which' *before* the Buildroot dependency check is run. Current behaviour: $ make /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found /bin/sh: which: command not found support/dependencies/check-host-tar.sh: line 5: which: command not found support/dependencies/check-host-tar.sh: line 7: which: command not found /home/bfo/buildroot/support/dependencies/dependencies.sh: line 56: which: command not found You must install 'which' on your build machine make: *** [core-dependencies] Error 1 New behaviour: $ make You must install 'which' on your build machine make: *** [core-dependencies] Error 1 Signed-off-by: Bjørn Forsman --- Makefile | 22 +++++++++++----------- package/Makefile.in | 10 +++++----- support/dependencies/check-host-tar.sh | 4 ++-- support/dependencies/dependencies.sh | 20 ++++++++++---------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 9dfb1e0..e06bfe1 100644 --- a/Makefile +++ b/Makefile @@ -192,12 +192,12 @@ HOSTAS:=as endif ifndef HOSTCC HOSTCC:=gcc -HOSTCC:=$(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc) +HOSTCC:=$(shell command -v $(HOSTCC) || type -p $(HOSTCC) || echo gcc) endif HOSTCC_NOCCACHE:=$(HOSTCC) ifndef HOSTCXX HOSTCXX:=g++ -HOSTCXX:=$(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++) +HOSTCXX:=$(shell command -v $(HOSTCXX) || type -p $(HOSTCXX) || echo g++) endif HOSTCXX_NOCCACHE:=$(HOSTCXX) ifndef HOSTFC @@ -221,15 +221,15 @@ endif ifndef HOSTRANLIB HOSTRANLIB:=ranlib endif -HOSTAR:=$(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar) -HOSTAS:=$(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as) -HOSTFC:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran) -HOSTCPP:=$(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp) -HOSTLD:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld) -HOSTLN:=$(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln) -HOSTNM:=$(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm) -HOSTOBJCOPY:=$(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy) -HOSTRANLIB:=$(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib) +HOSTAR:=$(shell command -v $(HOSTAR) || type -p $(HOSTAR) || echo ar) +HOSTAS:=$(shell command -v $(HOSTAS) || type -p $(HOSTAS) || echo as) +HOSTFC:=$(shell command -v $(HOSTLD) || type -p $(HOSTLD) || echo || command -v g77 || type -p g77 || echo gfortran) +HOSTCPP:=$(shell command -v $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp) +HOSTLD:=$(shell command -v $(HOSTLD) || type -p $(HOSTLD) || echo ld) +HOSTLN:=$(shell command -v $(HOSTLN) || type -p $(HOSTLN) || echo ln) +HOSTNM:=$(shell command -v $(HOSTNM) || type -p $(HOSTNM) || echo nm) +HOSTOBJCOPY:=$(shell command -v $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy) +HOSTRANLIB:=$(shell command -v $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib) export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE diff --git a/package/Makefile.in b/package/Makefile.in index 2e433fd..115049a 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -4,7 +4,7 @@ endif ifndef HOSTMAKE HOSTMAKE=$(MAKE) endif -HOSTMAKE :=$(shell which $(HOSTMAKE) || type -p $(HOSTMAKE) || echo make) +HOSTMAKE :=$(shell command -v $(HOSTMAKE) || type -p $(HOSTMAKE) || echo make) # If BR2_LEVEL is 0, scale the maximum concurrency with the number of # CPUs. An additional job is used in order to keep processors busy @@ -190,10 +190,10 @@ TARGET_STRIP=true STRIPCMD=$(TARGET_STRIP) KSTRIPCMD=$(TARGET_STRIP) endif -INSTALL:=$(shell which install || type -p install) -FLEX:=$(shell which flex || type -p flex) -BISON:=$(shell which bison || type -p bison) -SED:=$(shell which sed || type -p sed) -i -e +INSTALL:=$(shell command -v install || type -p install) +FLEX:=$(shell command -v flex || type -p flex) +BISON:=$(shell command -v bison || type -p bison) +SED:=$(shell command -v sed || type -p sed) -i -e HOST_CPPFLAGS = -I$(HOST_DIR)/usr/include HOST_CFLAGS ?= -O2 diff --git a/support/dependencies/check-host-tar.sh b/support/dependencies/check-host-tar.sh index 2cfc2b3..a406bd5 100755 --- a/support/dependencies/check-host-tar.sh +++ b/support/dependencies/check-host-tar.sh @@ -2,9 +2,9 @@ candidate="$1" -tar=`which $candidate` +tar=`command -v $candidate` if [ ! -x "$tar" ]; then - tar=`which tar` + tar=`command -v tar` if [ ! -x "$tar" ]; then # echo nothing: no suitable tar found exit 1 diff --git a/support/dependencies/dependencies.sh b/support/dependencies/dependencies.sh index 47d4d10..335c976 100755 --- a/support/dependencies/dependencies.sh +++ b/support/dependencies/dependencies.sh @@ -53,20 +53,20 @@ if test -n "$PERL_MM_OPT" ; then fi # Verify that which is installed -if ! which which > /dev/null ; then +if ! command -v which > /dev/null ; then echo echo "You must install 'which' on your build machine"; exit 1; fi; -if ! which sed > /dev/null ; then +if ! command -v sed > /dev/null ; then echo echo "You must install 'sed' on your build machine" exit 1 fi # Check make -MAKE=$(which make 2> /dev/null) +MAKE=$(command -v make 2> /dev/null) if [ -z "$MAKE" ] ; then echo echo "You must install 'make' on your build machine"; @@ -87,9 +87,9 @@ if [ $MAKE_MAJOR -lt 3 ] || [ $MAKE_MAJOR -eq 3 -a $MAKE_MINOR -lt 81 ] ; then fi; # Check host gcc -COMPILER=$(which $HOSTCC_NOCCACHE 2> /dev/null) +COMPILER=$(command -v $HOSTCC_NOCCACHE 2> /dev/null) if [ -z "$COMPILER" ] ; then - COMPILER=$(which cc 2> /dev/null) + COMPILER=$(command -v cc 2> /dev/null) fi; if [ -z "$COMPILER" ] ; then echo @@ -113,9 +113,9 @@ if [ $COMPILER_MAJOR -lt 3 -o $COMPILER_MAJOR -eq 2 -a $COMPILER_MINOR -lt 95 ] fi; # check for host CXX -CXXCOMPILER=$(which $HOSTCXX_NOCCACHE 2> /dev/null) +CXXCOMPILER=$(command -v $HOSTCXX_NOCCACHE 2> /dev/null) if [ -z "$CXXCOMPILER" ] ; then - CXXCOMPILER=$(which c++ 2> /dev/null) + CXXCOMPILER=$(command -v c++ 2> /dev/null) fi if [ -z "$CXXCOMPILER" ] ; then echo @@ -149,7 +149,7 @@ fi; # Check that a few mandatory programs are installed missing_progs="no" for prog in patch perl tar wget cpio python unzip rsync bc ${DL_TOOLS} ; do - if ! which $prog > /dev/null ; then + if ! command -v $prog > /dev/null ; then echo "You must install '$prog' on your build machine"; missing_progs="yes" if test $prog = "svn" ; then @@ -170,7 +170,7 @@ fi if grep ^BR2_TOOLCHAIN_BUILDROOT=y $BUILDROOT_CONFIG > /dev/null && \ grep ^BR2_ENABLE_LOCALE=y $BUILDROOT_CONFIG > /dev/null ; then - if ! which locale > /dev/null ; then + if ! command -v locale > /dev/null ; then echo echo "You need locale support on your build machine to build a toolchain supporting locales" exit 1 ; @@ -184,7 +184,7 @@ fi if grep -q ^BR2_PACKAGE_CLASSPATH=y $BUILDROOT_CONFIG ; then for prog in javac jar; do - if ! which $prog > /dev/null ; then + if ! command -v $prog > /dev/null ; then echo >&2 echo "You must install '$prog' on your build machine" >&2 exit 1