1#!/bin/sh 2# Generate version automatically. 3 4version_file=version.h 5 6if test -d .git; then 7 version=$(git describe --always --match "v[0-9]*" | sed -r -e 's/-([^-]+)$/.\1/g' | sed -e 's/^v//g') 8 if test -f "$version_file"; then 9 VC=$(perl -ne 'print "$1" if m/.*the_version = "(.*)".*/' $version_file) 10 else 11 VC=unset 12 fi 13 14 if test "$VC" != "$version"; then 15 echo "/* Automatically generated by $0 */ 16#ifndef VERSION_H 17#define VERSION_H 18 19const char *the_version = \"$version\"; 20 21#endif" > $version_file 22 fi 23fi 24