summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-11-26 21:43:06 -0500
committermidipix <writeonce@midipix.org>2016-11-10 23:35:27 -0500
commit4ab720b44ac5a98a9192d87a50630f964ab5eaa6 (patch)
tree49adfdc87e639265b6f9e80d3e5bd617a612d0a2
parent9c5807c7cadf7219a32f3b2c081a8d21aceb4837 (diff)
downloadperk-4ab720b44ac5a98a9192d87a50630f964ab5eaa6.tar.bz2
perk-4ab720b44ac5a98a9192d87a50630f964ab5eaa6.tar.xz
build system: version.sh: initial implementation.
-rw-r--r--Makefile.in16
-rwxr-xr-xsysinfo/version.sh61
2 files changed, 73 insertions, 4 deletions
diff --git a/Makefile.in b/Makefile.in
index 6c64a0e..df3113b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -128,11 +128,11 @@ shared-implib: shared-lib
-default-app: static $(DEFAULT_APP) $(APP)
+default-app: version.tag static $(DEFAULT_APP) $(APP)
-shared-app: shared $(SHARED_APP)
+shared-app: version.tag shared $(SHARED_APP)
-static-app: static $(STATIC_APP)
+static-app: version.tag static $(STATIC_APP)
@@ -172,6 +172,13 @@ host.tag: Makefile
$(PROJECT_DIR)/sysinfo/host/host.sh --compiler="$(CC)" --cflags="$(CFLAGS)"
touch host.tag
+version.tag:
+ $(PROJECT_DIR)/sysinfo/version.sh \
+ -s $(PROJECT_DIR) \
+ -o build/$(PACKAGE)_version.h \
+ -p $(PACKAGE)
+ touch version.tag
+
distclean: clean
rm -f Makefile
@@ -179,6 +186,7 @@ clean:
rm -f tree.tag
rm -f dirs.tag
rm -f host.tag
+ rm -f version.tag
rm -f $(SHARED_OBJS)
rm -f $(STATIC_OBJS)
rm -f $(APP_OBJS)
@@ -285,6 +293,6 @@ clean:
default-app shared-app static-app \
install-shared install-static install-implib \
install-headers install-app \
- clean distclean \
+ clean distclean version \
.display-env .display-tools .display-flags \
.display-pe .display-elf .display-dirs .display-build
diff --git a/sysinfo/version.sh b/sysinfo/version.sh
new file mode 100755
index 0000000..fb1e8c3
--- /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` || 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