aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitattributes1
-rw-r--r--Makefile4
-rwxr-xr-xhash.sh25
3 files changed, 28 insertions, 2 deletions
diff --git a/.gitattributes b/.gitattributes
index 7799c58..9c6b849 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,2 @@
examples/data/uzbl/forms/bbs.archlinux.org whitespace=-trailing-space
+hash.sh export-subst
diff --git a/Makefile b/Makefile
index e13d684..cf55989 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
# first entries are for gnu make, 2nd for BSD make. see http://lists.uzbl.org/pipermail/uzbl-dev-uzbl.org/2009-July/000177.html
-CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic
-CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DCOMMIT='"\""'`git log | head -n1 | sed "s/.* //"`'"\""' $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic
+CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DCOMMIT="\"$(shell ./hash.sh)\"" $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic
+CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DCOMMIT='"\""'`./hash.sh`'"\""' $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic
LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -pthread $(LDFLAGS)
LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -pthread $(LDFLAGS)
diff --git a/hash.sh b/hash.sh
new file mode 100755
index 0000000..0c97722
--- /dev/null
+++ b/hash.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# script to determine git hash of current source tree
+
+# set a variable when running `git --archive <hash/tag>` (this is what github does)
+# alternatively, you could also git get-tar-commit-id < tarball (but that's a bit dirtier)
+FROM_ARCHIVE=$Format:%H$
+
+# ... but try to use whatever git tells us if there is a .git folder
+if [ -d .git -a -r .git ]
+then
+ hash=$(git log 2>/dev/null | head -n1 2>/dev/null | sed "s/.* //" 2>/dev/null)
+fi
+
+if [ x"$hash" != x ]
+then
+ echo $hash
+elif [ "$FROM_ARCHIVE" != ':%H$' ]
+then
+ echo $FROM_ARCHIVE
+else
+ echo "commit hash detection fail. Dear packager, please figure out what goes wrong or get in touch with us" >&2
+ echo UNKNOWN
+ exit 2
+fi
+exit 0