Home | History | Annotate | Download | only in tools
      1 #!/usr/bin/env bash
      2 
      3 if [[ "" == "$2" ]]
      4 then
      5     echo "Usage: $0 <in-file> <out-file>"
      6     exit 1
      7 fi
      8 
      9 if [ ! -f "$1" ]
     10 then
     11     echo "Error: Can't find input file $1..."
     12     exit 2
     13 fi
     14 
     15 DATE=`/usr/bin/env date`
     16 BASE=`basename $2`
     17 BASE=`echo ${BASE} | tr "[:lower:]" "[:upper:]"`
     18 BASE=`echo ${BASE} | sed -e "s/\\./_/"`
     19 PROTECT="_${BASE}"
     20 
     21 echo "/* Auto-generated from $1 on ${DATE} */" > $2
     22 echo "#ifndef ${PROTECT}" >> $2
     23 echo "#define ${PROTECT}" >> $2
     24 sed -e '/^#/d' -e '/^$$/d' -e '/# Makefile only$$/d' -e 's/^/#define /' -e 's/=/ /' $1 >> $2
     25 echo "#endif" >> $2
     26 
     27