infra: Add generic check_prog_host function

Avoid copy/pasting the same block of code to check if a program is
available on the host machine.

Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Reviewed-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
Maxime Hadjinlian 2014-05-04 00:45:43 +02:00 committed by Thomas Petazzoni
parent e244eb12df
commit 8575332f0d

View File

@ -51,18 +51,20 @@ if test -n "$PERL_MM_OPT" ; then
exit 1 exit 1
fi fi
# Verify that which is installed check_prog_host()
if ! which which > /dev/null ; then {
echo prog="$1"
echo "You must install 'which' on your build machine"; if ! which $prog > /dev/null ; then
exit 1; echo >&2
fi; echo "You must install '$prog' on your build machine" >&2
exit 1
fi
}
if ! which sed > /dev/null ; then # Verify that which is installed
echo check_prog_host "which"
echo "You must install 'sed' on your build machine" # Verify that sed is installed
exit 1 check_prog_host "sed"
fi
# Check make # Check make
MAKE=$(which make 2> /dev/null) MAKE=$(which make 2> /dev/null)
@ -196,11 +198,7 @@ if grep -q ^BR2_PACKAGE_CLASSPATH=y $BR2_CONFIG ; then
fi fi
if grep -q ^BR2_NEEDS_HOST_JAVA=y $BR2_CONFIG ; then if grep -q ^BR2_NEEDS_HOST_JAVA=y $BR2_CONFIG ; then
if ! which java > /dev/null ; then check_prog_host "java"
echo >&2
echo "You must install 'java' on your build machine" >&2
exit 1
fi
fi fi
if grep -q ^BR2_HOSTARCH_NEEDS_IA32_LIBS=y $BR2_CONFIG ; then if grep -q ^BR2_HOSTARCH_NEEDS_IA32_LIBS=y $BR2_CONFIG ; then