2 # Usage: gentvals.sh target type dir files pattern cpp
7 # FIXME: Would be nice to process #include's in these files.
12 # FIXME: need trap to remove tmp files.
14 rm -f tmpvals.list tmpvals.uniq
17 if test -f $dir/$f ; then
18 grep "#define[ ]$pattern" $dir/$f | sed -e "s/^.*#define[ ]\($pattern\)[ ]*\([^ ][^ ]*\).*$/\1/" >> tmpvals.list
22 sort <tmpvals.list | uniq >tmpvals.uniq
27 if test -f $dir/$f ; then
28 echo "#include <$f>" >>tmpvals.h
35 echo "#ifdef $sym" >>tmpvals.h
36 echo 'DEFVAL { "'$sym'", '$sym ' },' >>tmpvals.h
37 echo "#endif" >>tmpvals.h
42 echo "#ifdef ${type}_defs"
44 echo "#ifdef NL_TARGET_$target"
45 echo "#ifdef ${type}_defs"
50 if test -f $dir/$f ; then
57 echo "/* begin $type target macros */"
59 echo "/* begin $target $type target macros */"
62 $cpp -I$dir tmpvals.h | grep DEFVAL | sed -e 's/DEFVAL//' -e 's/ / /'
66 echo "/* end $type target macros */"
69 echo "/* end $target $type target macros */"
74 rm -f tmpvals.list tmpvals.uniq tmpvals.h