For issue#2192. Run scripts though shellcheck. Put back configure.inc to use bash for now.

This commit is contained in:
Dreamcat4 2014-08-13 20:47:08 +01:00
parent f0b348d457
commit e679aefb4f
3 changed files with 45 additions and 45 deletions

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Generic/Simple configure script
#
@ -14,7 +14,7 @@ CONFIGURE_ARGS="$*"
# System setup
[ -z "$PLATFORM" ] && PLATFORM=$(uname -s | tr "[:upper:]" "[:lower:]")
[ -z "$CPU" ] && CPU=generic
[ -z "$ARCH" ] && ARCH=`uname -m`
[ -z "$ARCH" ] && ARCH=$(uname -m)
[ -z "$OSENV" ] && OSENV=posix
[ -z "$PYTHON" ] && PYTHON=python
@ -47,13 +47,13 @@ CONFIGURE_ARGS="$*"
TAB=" %-50s"
# Text conversion
function toupper
toupper ()
{
echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
}
# Terminate
function die
die ()
{
echo >&2 "ERROR: $@"
exit 1
@ -64,12 +64,12 @@ function die
# ###########################################################################
# Enable/Disable option
function _enable
_enable ()
{
local opt=$1 val=$2 ignore=$3 row= k= v=
for row in ${OPTIONS[*]}; do
k=${row%:*}
[ "$k" == "$opt" ] || continue
[ "$k" = "$opt" ] || continue
v=${row#*:}
if [ $v != "$val" ]; then
OPTIONS=(${OPTIONS[@]//$row/$k:$val})
@ -80,34 +80,34 @@ function _enable
}
# Enable option
function enable
enable ()
{
_enable $1 yes $2
}
# Disable option
function disable
disable ()
{
_enable $1 no $2
}
# Enable package
function enable_pkg
enable_pkg ()
{
local opt=$1 row= k= v=
for row in ${PACKAGES[*]}; do
[ "$row" == "$opt" ] && return
[ "$row" = "$opt" ] && return
done
PACKAGES=(${PACKAGES[@]} $opt)
}
# Get enabled state
function _enabled
_enabled ()
{
local opt=$1 row= k=
for row in ${OPTIONS[*]}; do
k=${row%:*}
[ "$k" == "$opt" ] || continue
[ "$k" = "$opt" ] || continue
echo ${row#*:}
return
done
@ -115,31 +115,31 @@ function _enabled
}
# Check if enabled
function enabled
enabled ()
{
local val=$(_enabled $1)
[ "$val" == "yes" ] && return 0 || return 1
[ "$val" = "yes" ] && return 0 || return 1
}
# Check if disabled
function disabled
disabled ()
{
local val=$(_enabled $1)
[ "$val" == "no" ] && return 0 || return 1
[ "$val" = "no" ] && return 0 || return 1
}
# Check if enabled (or auto)
function enabled_or_auto
enabled_or_auto ()
{
local val=$(_enabled $1)
[ "$val" == "yes" -o "$val" == "auto" ] && return 0 || return 1
[ "$val" = "yes" -o "$val" = "auto" ] && return 0 || return 1
}
# Check if disabled (or auto)
function disabled_or_auto
disabled_or_auto ()
{
local val=$(_enabled $1)
[ "$val" == "no" -o "$val" == "auto" ] && return 0 || return 1
[ "$val" = "no" -o "$val" = "auto" ] && return 0 || return 1
}
# ###########################################################################
@ -147,7 +147,7 @@ function disabled_or_auto
# ###########################################################################
# Show help
function show_help
show_help ()
{
local opt= val= fmt="%-30s"
echo "Usage: $0 [options]"
@ -174,9 +174,9 @@ function show_help
for opt in ${OPTIONS[*]}; do
val=${opt#*:}
opt=${opt%:*}
if [ "$val" == "yes" ]; then
if [ "$val" = "yes" ]; then
printf " $fmt Disable ${opt}\n" "--disable-${opt}"
elif [ "$val" == "no" ]; then
elif [ "$val" = "no" ]; then
printf " $fmt Enable ${opt}\n" "--enable-${opt}"
else
printf " $fmt Disable ${opt}\n" "--disable-${opt}"
@ -187,7 +187,7 @@ function show_help
}
# Process command line
function parse_args
parse_args ()
{
local opt= val=
for opt do
@ -202,7 +202,7 @@ function parse_args
eval "$opt=$val"
;;
cc|cflags|arch|cpu|platform|python)
eval "`toupper $opt`=$val"
eval "$(toupper $opt)=$val"
;;
enable-*)
opt=${opt#*-}
@ -222,7 +222,7 @@ function parse_args
# ###########################################################################
# Check package
function check_pkg
check_pkg ()
{
local pkg=$1; shift
local ver=$*
@ -249,7 +249,7 @@ function check_pkg
# ###########################################################################
# Check compiler
function check_cc
check_cc ()
{
local hdr=$1
local opt=$2
@ -263,14 +263,14 @@ int main() {
#endif
}
EOF
$CC $CFLAGS $LDFLAGS $TMPDIR/$$.c -o $TMPDIR/$$.bin $opt &> /dev/null
$CC $CFLAGS $LDFLAGS $TMPDIR/$$.c -o $TMPDIR/$$.bin $opt 2>&1 /dev/null
RET=$?
rm -f $TMPDIR/$$.{c,bin}
return $RET
}
# Check compiler header
function check_cc_header
check_cc_header ()
{
local hdr=$1
local nam=$2
@ -289,7 +289,7 @@ function check_cc_header
}
# Check some compiler snippet
function check_cc_snippet
check_cc_snippet ()
{
local nam=$1
local snp=$2
@ -308,7 +308,7 @@ function check_cc_snippet
}
# Check compiler option
function check_cc_option
check_cc_option ()
{
local opt=$1
local nam=$2
@ -327,7 +327,7 @@ function check_cc_option
}
# Check compiler library
function check_cc_lib
check_cc_lib ()
{
local opt=$1
local nam=$2
@ -350,20 +350,20 @@ function check_cc_lib
# ###########################################################################
# Check python
function check_py
check_py ()
{
local hdr=$1
cat >$TMPDIR/$$.py <<EOF
$hdr
EOF
$PYTHON $TMPDIR/$$.py &> /dev/null
$PYTHON $TMPDIR/$$.py 2>&1 /dev/null
RET=$?
rm -f $TMPDIR/$$.py
return $RET
}
# Check python import
function check_py_import
check_py_import ()
{
local hdr=$1
local nam=$2
@ -385,7 +385,7 @@ function check_py_import
# Binary checks
# ###########################################################################
function check_bin
check_bin ()
{
local bin=$1
local nam=$2
@ -406,7 +406,7 @@ function check_bin
# ###########################################################################
# Print config
function print_config
print_config ()
{
local pkg= fmt=" %-40s %s\n"
@ -429,7 +429,7 @@ function print_config
for opt in ${OPTIONS[*]}; do
k=${opt%:*}
v=${opt#*:}
if [ "$v" == "yes" ]; then
if [ "$v" = "yes" ]; then
printf "$fmt" "$k" "yes"
else
printf "$fmt" "$k" "no"
@ -455,13 +455,13 @@ function print_config
}
# Write configuration
function write_config
write_config ()
{
local pkg= opt= k= v=
# Create build directory
mkdir -p "${BUILDDIR}"
BUILDDIR=`cd "${BUILDDIR}" && pwd`
BUILDDIR=$(cd "${BUILDDIR}" && pwd)
# Create make include
CONFIG_MK=${ROOTDIR}/.config.mk
@ -511,7 +511,7 @@ EOF
for row in ${OPTIONS[*]}; do
k=$(toupper ${row%:*})
v=${row#*:}
if [ "$v" == "yes" ]; then
if [ "$v" = "yes" ]; then
cat >>"${CONFIG_H}" <<EOF
#define ENABLE_${k} 1
#define CONFIG_${k} 1

View file

@ -11,13 +11,13 @@ DIR=$1
if [ -d "${DIR}/.git" ]; then
LAST=$(pwd)
cd "${DIR}" || exit 1
git pull &> /dev/null || exit 1
git reset --hard &> /dev/null || exit 1
git pull 2>&1 /dev/null || exit 1
git reset --hard 2>&1 /dev/null || exit 1
cd "${LAST}" || exit 1
# Fetch
elif [ ! -d "${DIR}" ]; then
URL=http://linuxtv.org/git/dtv-scan-tables.git
git clone $URL "${DIR}" &> /dev/null || exit 1
git clone $URL "${DIR}" 2>&1 /dev/null || exit 1
fi
# Note: will not update existing set (if not .git)

View file

@ -4,7 +4,7 @@
#
# Terminate
function die
die ()
{
echo >&2 "ERROR: $@"
exit 1