diff options
author | midipix <writeonce@midipix.org> | 2017-11-18 03:27:43 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2017-11-18 18:16:36 -0500 |
commit | ea5470e0a34f7154531b857413b39b25588193e8 (patch) | |
tree | 1e78107234842510f439a7ca1c9efbc36072cca2 /sysinfo/version.sh | |
parent | b6c684b4f6323104fac9c8f8ec9be6f6856e904e (diff) | |
download | w32lib-ea5470e0a34f7154531b857413b39b25588193e8.tar.bz2 w32lib-ea5470e0a34f7154531b857413b39b25588193e8.tar.xz |
created skeleton.
Diffstat (limited to 'sysinfo/version.sh')
-rwxr-xr-x | sysinfo/version.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/sysinfo/version.sh b/sysinfo/version.sh new file mode 100755 index 0000000..0b948bc --- /dev/null +++ b/sysinfo/version.sh @@ -0,0 +1,62 @@ +#!/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 +mkdir -p `dirname "$output"` || exit 2 +printf "#define $macro\t\"$gitver\"\n" > "$output" + +# all done +exit 0 |