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"
19 # The script should reside in the toplevel source directory which should contain
20 # all version control files.
32 REV
=`svnversion 2> /dev/null`
36 git status
>/dev
/null
# updates dirty state
37 REV
=`git show | grep '^ *git-svn-id:' | sed 's/.*@\([0-9]*\) .*/\1/'`
40 test -z "$(git diff-index --name-only HEAD)" || REV
="${REV}M"
42 REV
=0+`git rev-parse HEAD`
43 test -z "$(git diff-index --name-only HEAD)" || REV
="${REV}-dirty"
53 echo "#define ${DEFINE} \"${REV}\"" > "${TEMP_FILE}"
54 if test ! -f "${OUTPUT_FILE}"
56 echo "Generated ${OUTPUT_FILE} (${REV})"
57 cp "${TEMP_FILE}" "${OUTPUT_FILE}"
58 if test $?
-ne 0; then exit 1; fi
60 if ! cmp -s "${OUTPUT_FILE}" "${TEMP_FILE}"
61 then echo "Regenerated ${OUTPUT_FILE} (${REV})"
62 cp "${TEMP_FILE}" "${OUTPUT_FILE}"
63 if test $?
-ne 0; then exit 1; fi