configure: avoid non-POSIX: local var=...
The vast majority of shells do support "local", but not all, notably AT&T ksh (default sh in illumos-based distros and Solaris), but also some other POSIX-compliant shells, so remove "local". print_str(), print_num() are modified trivially. default() now uses standard "Assign Default Value" - same semantics, and works in all shells (and POSIX). default_conf() is identical to before, but it had and still has few minor issues, which will be addressed in a future commit.
This commit is contained in:
parent
05ebe494dd
commit
6f4b384e79
1 changed files with 9 additions and 12 deletions
21
configure
vendored
21
configure
vendored
|
@ -206,17 +206,14 @@ EOF
|
|||
exit 1
|
||||
}
|
||||
|
||||
default() # set variable unless already set
|
||||
default() # set variable unless already set and not empty
|
||||
{
|
||||
local v
|
||||
eval v=\"\$$1\"
|
||||
test -z "$v" && test -n "$2" && eval $1=\"$2\"
|
||||
test -n "$2" && eval : \${$1:=\$2} # ': ${foo:=$2}'
|
||||
}
|
||||
|
||||
default_conf() # add to confvars unless already present
|
||||
{
|
||||
local v=${1%=*}
|
||||
test "${confvars%$v*}" = "${confvars}" && confvars="$confvars $1"
|
||||
test "${confvars%${1%=*}*}" = "${confvars}" && confvars="$confvars $1"
|
||||
}
|
||||
|
||||
if test -z "${source_path#.}" ; then
|
||||
|
@ -565,20 +562,20 @@ else
|
|||
echo 'TOPSRC=$(TOP)' >>config.mak
|
||||
fi
|
||||
|
||||
# $1: macro name, $2: val to set - quoted [, $3: non-empty for #ifndef]
|
||||
print_str() {
|
||||
local v="$2"
|
||||
if test -n "$v"; then
|
||||
if test -n "$2"; then
|
||||
test -n "$3" && echo "#ifndef $1" >> $TMPH
|
||||
echo "#define $1 \"$v\"" >> $TMPH
|
||||
echo "#define $1 \"$2\"" >> $TMPH
|
||||
test -n "$3" && echo "#endif" >> $TMPH
|
||||
fi
|
||||
}
|
||||
|
||||
# $1: macro name, $2: val to set [, $3: non-empty for #ifndef]
|
||||
print_num() {
|
||||
local v="$2"
|
||||
if test -n "$v"; then
|
||||
if test -n "$2"; then
|
||||
test -n "$3" && echo "#ifndef $1" >> $TMPH
|
||||
echo "#define $1 $v" >> $TMPH
|
||||
echo "#define $1 $2" >> $TMPH
|
||||
test -n "$3" && echo "#endif" >> $TMPH
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue