Mercurial > hg > toybox
comparison scripts/make.sh @ 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 | 878b94b32866 |
children | 8a88a9e3c30b |
comparison
equal
deleted
inserted
replaced
565:44abf4d901f3 | 566:05617db1a337 |
---|---|
23 } | 23 } |
24 echo "NEWTOY(toybox, NULL, 0)" > generated/newtoys.h | 24 echo "NEWTOY(toybox, NULL, 0)" > generated/newtoys.h |
25 newtoys | sed 's/\(.*TOY(\)\([^,]*\),\(.*\)/\2 \1\2,\3/' | sort -k 1,1 \ | 25 newtoys | sed 's/\(.*TOY(\)\([^,]*\),\(.*\)/\2 \1\2,\3/' | sort -k 1,1 \ |
26 | sed 's/[^ ]* //' >> generated/newtoys.h | 26 | sed 's/[^ ]* //' >> generated/newtoys.h |
27 | 27 |
28 # Extract global structure definitions from toys/*.c | 28 # Extract global structure definitions and flag definitions from toys/*.c |
29 | 29 |
30 function getglobals() | 30 function getglobals() |
31 { | 31 { |
32 for i in toys/*.c | 32 for i in toys/*.c |
33 do | 33 do |
35 | 35 |
36 echo -e "// $i\n" | 36 echo -e "// $i\n" |
37 sed -n -e '/^DEFINE_GLOBALS(/,/^)/b got;b;:got' \ | 37 sed -n -e '/^DEFINE_GLOBALS(/,/^)/b got;b;:got' \ |
38 -e 's/^DEFINE_GLOBALS(/struct '"$NAME"'_data {/' \ | 38 -e 's/^DEFINE_GLOBALS(/struct '"$NAME"'_data {/' \ |
39 -e 's/^)/};/' -e 'p' $i | 39 -e 's/^)/};/' -e 'p' $i |
40 | |
41 # And get flag definitions | |
42 FLAGS="$(sed -n \ | |
43 -e "s/.*TOY($NAME"',[ \t]*"\([^"]*\)"[ \t]*,.*)/\1/' \ | |
44 -e 't keep;d;:keep' \ | |
45 -e 's/[><=][0-9][0-9]*//g' \ | |
46 -e 's/+.//g' \ | |
47 -e 's/([^)]*)//g' \ | |
48 -e 's/[-?^:&#|@*]//g' \ | |
49 -e 'p' \ | |
50 generated/newtoys.h)" | |
51 X=0 | |
52 while [ $X -lt ${#FLAGS} ] | |
53 do | |
54 echo -ne "#define OPTFLAG_${NAME}_${FLAGS:$X:1}\t" | |
55 X=$(($X+1)) | |
56 echo "(1<<$((${#FLAGS}-$X)))" | |
57 done | |
40 done | 58 done |
41 } | 59 } |
42 | 60 |
43 GLOBSTRUCT="$(getglobals)" | 61 GLOBSTRUCT="$(getglobals)" |
44 ( | 62 ( |