Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
configure: Set CFG_<FOO>_PROVIDED if it was supplied
This allows you to distinguish between an option that defaulted, and an
option selected by the user
  • Loading branch information
richo committed Apr 14, 2015
1 parent 71a4ea5 commit 87efd2c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions configure
Expand Up @@ -192,13 +192,15 @@ valopt_core() {
then
local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
local V="CFG_${UOP}"
local V_PROVIDED="${V}_PROVIDED"
eval $V="$DEFAULT"
for arg in $CFG_CONFIGURE_ARGS
do
if echo "$arg" | grep -q -- "--$OP="
then
val=$(echo "$arg" | cut -f2 -d=)
eval $V=$val
eval $V_PROVIDED=1
fi
done
if [ "$SAVE" = "save" ]
Expand Down Expand Up @@ -247,8 +249,10 @@ opt_core() {
if [ $DEFAULT -eq 0 ]
then
FLAG="enable"
DEFAULT_FLAG="disable"
else
FLAG="disable"
DEFAULT_FLAG="enable"
DOC="don't $DOC"
fi

Expand All @@ -261,11 +265,19 @@ opt_core() {
OP=$(echo $OP | tr 'a-z-' 'A-Z_')
FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
local V="CFG_${FLAG}_${OP}"
local V_PROVIDED="CFG_${FLAG}_${OP}_PROVIDED"
eval $V=1
eval $V_PROVIDED=1
if [ "$SAVE" = "save" ]
then
putvar $V
fi
elif [ "$arg" = "--${DEFAULT_FLAG}-${OP}" ]
then
OP=$(echo $OP | tr 'a-z-' 'A-Z_')
DEFAULT_FLAG=$(echo $DEFAULT_FLAG | tr 'a-z' 'A-Z')
local V_PROVIDED="CFG_${DEFAULT_FLAG}_${OP}_PROVIDED"
eval $V_PROVIDED=1
fi
done
else
Expand Down

0 comments on commit 87efd2c

Please sign in to comment.