5 if test $# -ne 1 -a $# -ne 2
7 echo "Usage: "`basename "$0"`" <file> [define_name]"
11 OUTPUT_FILE
="`pwd`/${1}"
12 TEMP_FILE
="${OUTPUT_FILE}.tmp"
31 REV
=`svnversion 2> /dev/null`
35 git status
>/dev
/null
# updates dirty state
36 REV
=`git show | grep '^ *git-svn-id:' | sed 's/.*@\([0-9]*\) .*/\1/'`
39 test -z "$(git diff-index --name-only HEAD)" || REV
="${REV}M"
41 REV
=0+`git rev-parse HEAD`
42 test -z "$(git diff-index --name-only HEAD)" || REV
="${REV}-dirty"
52 echo "#define ${DEFINE} \"${REV}\"" > ${TEMP_FILE}
53 if test ! -f ${OUTPUT_FILE}
55 echo "Generated
${OUTPUT_FILE} (${REV})"
56 cp ${TEMP_FILE} ${OUTPUT_FILE}
57 if test $? -ne 0; then exit 1; fi
59 if ! cmp -s ${OUTPUT_FILE} ${TEMP_FILE}
60 then echo "Regenerated
${OUTPUT_FILE} (${REV})"
61 cp ${TEMP_FILE} ${OUTPUT_FILE}
62 if test $? -ne 0; then exit 1; fi