aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-04-14 22:31:53 -0500
committerRob Landley <rob@landley.net>2012-04-14 22:31:53 -0500
commit1bcdf538bead59ef4d0d6c9a47b7bc5153a21667 (patch)
tree5a157ac7e910284782e05fc0e68278acaf06496b /scripts
parenteb7ea22c7505f10928e104a9df39edc70a8f7036 (diff)
downloadtoybox-1bcdf538bead59ef4d0d6c9a47b7bc5153a21667.tar.gz
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/make.sh20
1 files changed, 19 insertions, 1 deletions
diff --git a/scripts/make.sh b/scripts/make.sh
index f5bf0fdb..52380ecf 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -25,7 +25,7 @@ echo "NEWTOY(toybox, NULL, 0)" > generated/newtoys.h
newtoys | sed 's/\(.*TOY(\)\([^,]*\),\(.*\)/\2 \1\2,\3/' | sort -k 1,1 \
| sed 's/[^ ]* //' >> generated/newtoys.h
-# Extract global structure definitions from toys/*.c
+# Extract global structure definitions and flag definitions from toys/*.c
function getglobals()
{
@@ -37,6 +37,24 @@ function getglobals()
sed -n -e '/^DEFINE_GLOBALS(/,/^)/b got;b;:got' \
-e 's/^DEFINE_GLOBALS(/struct '"$NAME"'_data {/' \
-e 's/^)/};/' -e 'p' $i
+
+ # And get flag definitions
+ FLAGS="$(sed -n \
+ -e "s/.*TOY($NAME"',[ \t]*"\([^"]*\)"[ \t]*,.*)/\1/' \
+ -e 't keep;d;:keep' \
+ -e 's/[><=][0-9][0-9]*//g' \
+ -e 's/+.//g' \
+ -e 's/([^)]*)//g' \
+ -e 's/[-?^:&#|@*]//g' \
+ -e 'p' \
+ generated/newtoys.h)"
+ X=0
+ while [ $X -lt ${#FLAGS} ]
+ do
+ echo -ne "#define OPTFLAG_${NAME}_${FLAGS:$X:1}\t"
+ X=$(($X+1))
+ echo "(1<<$((${#FLAGS}-$X)))"
+ done
done
}