blob: e5ce96c6a70c52389c25759835fdb148e5378940 [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
Gerd Hoffmannece025f2013-09-13 14:12:23 +02007if [ -d .git -o -f .git ]; then
Kevin O'Connor980b45a2012-03-24 11:42:53 -04008 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
Kevin O'Connor385a7d02012-04-15 22:02:15 -040018if [ "$VAR16MODE" = "VAR16" ]; then
Kevin O'Connor980b45a2012-03-24 11:42:53 -040019 cat > ${OUTFILE} <<EOF
20#include "types.h"
21char VERSION[] VAR16 = "${VERSION}";
22EOF
23else
24 cat > ${OUTFILE} <<EOF
25char VERSION[] = "${VERSION}";
26EOF
27fi