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