]>
Commit | Line | Data |
---|---|---|
58b72d7e DE |
1 | #!/bin/sh |
2 | # Usage: gentvals.sh type dir files pattern cpp | |
3 | ||
4 | type=$1 | |
5 | dir=$2 | |
6 | # FIXME: Would be nice to process #include's in these files. | |
7 | files=$3 | |
8 | pattern=$4 | |
9 | cpp=$5 | |
10 | ||
11 | # FIXME: need trap to remove tmp files. | |
12 | ||
13 | rm -f tmpvals.list tmpvals.uniq | |
14 | for f in $files | |
15 | do | |
16 | if test -f $dir/$f ; then | |
17 | grep "#define[ ]$pattern" $dir/$f | sed -e "s/^.*#define[ ]\($pattern\)[ ]*\([^ ][^ ]*\).*$/\1/" >> tmpvals.list | |
18 | fi | |
19 | done | |
20 | ||
21 | sort <tmpvals.list | uniq >tmpvals.uniq | |
22 | ||
23 | rm -f tmpvals.h | |
24 | for f in $files | |
25 | do | |
26 | if test -f $dir/$f ; then | |
27 | echo "#include <$f>" >>tmpvals.h | |
28 | fi | |
29 | done | |
30 | ||
31 | cat tmpvals.uniq | | |
32 | while read sym | |
33 | do | |
34 | echo "#ifdef $sym" >>tmpvals.h | |
35 | echo 'DEFVAL { "'$sym'", '$sym ' },' >>tmpvals.h | |
36 | echo "#endif" >>tmpvals.h | |
37 | done | |
38 | ||
39 | echo "#ifdef ${type}_defs" | |
40 | for f in $files | |
41 | do | |
42 | if test -f $dir/$f ; then | |
43 | echo "/* from $f */" | |
44 | fi | |
45 | done | |
46 | echo "/* begin $type target macros */" | |
47 | $cpp tmpvals.h | grep DEFVAL | sed -e 's/DEFVAL//' -e 's/ / /' | |
48 | echo "/* end $type target macros */" | |
49 | echo "#endif" | |
50 | ||
51 | rm -f tmpvals.list tmpvals.uniq tmpvals.h |