Kevin O'Connor | 980b45a | 2012-03-24 11:42:53 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Script to generate a C file with version information. |
| 3 | OUTFILE="$1" |
| 4 | VAR16MODE="$2" |
| 5 | |
| 6 | # Extract version info |
| 7 | if [ -d .git ]; then |
| 8 | VERSION="`git describe --tags --long --dirty`" |
| 9 | elif [ -f .version ]; then |
| 10 | VERSION="`cat .version`" |
| 11 | else |
| 12 | VERSION="?" |
| 13 | fi |
| 14 | VERSION="${VERSION}-`date +"%Y%m%d_%H%M%S"`-`hostname`" |
| 15 | echo "Version: ${VERSION}" |
| 16 | |
| 17 | # Build header file |
Kevin O'Connor | 385a7d0 | 2012-04-15 22:02:15 -0400 | [diff] [blame] | 18 | if [ "$VAR16MODE" = "VAR16" ]; then |
Kevin O'Connor | 980b45a | 2012-03-24 11:42:53 -0400 | [diff] [blame] | 19 | cat > ${OUTFILE} <<EOF |
| 20 | #include "types.h" |
| 21 | char VERSION[] VAR16 = "${VERSION}"; |
| 22 | EOF |
| 23 | else |
| 24 | cat > ${OUTFILE} <<EOF |
| 25 | char VERSION[] = "${VERSION}"; |
| 26 | EOF |
| 27 | fi |