summaryrefslogtreecommitdiff
path: root/sysinfo/version.sh
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-03-04 13:32:05 -0500
committermidipix <writeonce@midipix.org>2016-03-08 14:21:05 -0500
commit9ca8c4c3c1b2cb1b22a3ff04c1c37b0863dd87f6 (patch)
treed1659a6814efef596730d6da5247b3fdd58d179b /sysinfo/version.sh
parent0ff546cab29192407bf991bf915dce52c049c387 (diff)
downloadslibtool-9ca8c4c3c1b2cb1b22a3ff04c1c37b0863dd87f6.tar.bz2
slibtool-9ca8c4c3c1b2cb1b22a3ff04c1c37b0863dd87f6.tar.xz
created skeleton.
Diffstat (limited to 'sysinfo/version.sh')
-rwxr-xr-xsysinfo/version.sh61
1 files changed, 61 insertions, 0 deletions
diff --git a/sysinfo/version.sh b/sysinfo/version.sh
new file mode 100755
index 0000000..8157765
--- /dev/null
+++ b/sysinfo/version.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+usage()
+{
+cat << EOF >&2
+
+Usage:
+ -h show this HELP message
+ -s SRCDIR set source directory
+ -o OUTPUT set output header
+ -p PREFIX set macro prefix
+
+EOF
+exit 1
+}
+
+
+# one
+workdir=$(pwd)
+srcdir=
+output=
+prefix=
+
+
+while getopts "hs:o:p:" opt; do
+ case $opt in
+ h)
+ usage
+ ;;
+ s)
+ srcdir="$OPTARG"
+ ;;
+ o)
+ output="$OPTARG"
+ ;;
+ p)
+ prefix="$OPTARG"
+ ;;
+ \?)
+ printf "Invalid option: -%s" "$OPTARG" >&2
+ usage
+ ;;
+ esac
+done
+
+
+# two
+if [ -z "$srcdir" ] || [ -z "$output" ] || [ -z "$prefix" ]; then
+ usage
+fi
+
+cd "$srcdir" || exit 2
+
+gitver=`git rev-parse --verify HEAD 2>/dev/null` || gitver="unknown"
+macro=`echo "$prefix"_GIT_VERSION | tr '[:lower:]' '[:upper:]'`
+
+cd "$workdir" || exit 2
+printf "#define $macro\t\"$gitver\"\n" > "$output"
+
+# all done
+exit 0