changeset 566:05617db1a337

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...
author Rob Landley <rob@landley.net>
date Sat, 14 Apr 2012 22:31:53 -0500
parents 44abf4d901f3
children f1629eb63806
files scripts/make.sh
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/make.sh	Sat Apr 14 22:30:41 2012 -0500
+++ b/scripts/make.sh	Sat Apr 14 22:31:53 2012 -0500
@@ -25,7 +25,7 @@
 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 @@
     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
 }