Makefile: fix builddata when building from tarball
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 10 Jul 2013 15:50:38 +0000 (17:50 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 10 Jul 2013 16:06:25 +0000 (18:06 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Makefile
make/hash_source.sh

index c7f8d83..c6a219a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -79,7 +79,7 @@ switch:
 src/builddata.c:
        $(MAKECMDPREFIX)$(RM) "$@"
        $(MAKECMDPREFIX)echo "#include \"defs.h\"" >> "$@" 
-       $(MAKECMDPREFIX)echo "const char olsrd_version[] = \"olsr.org -  $(VERS)-git_`git log -1 --pretty=%h`-hash_`./make/hash_source.sh`\";"  >> "$@"
+       $(MAKECMDPREFIX)echo "const char olsrd_version[] = \"olsr.org -  $(VERS)`./make/hash_source.sh`\";"  >> "$@"
        $(MAKECMDPREFIX)date +"const char build_date[] = \"%Y-%m-%d %H:%M:%S\";" >> "$@" 
        $(MAKECMDPREFIX)echo "const char build_host[] = \"$(shell hostname)\";" >> "$@" 
 
index 2267985..9b41fe6 100755 (executable)
@@ -1,7 +1,15 @@
 #!/bin/sh
+
+sha="`git log -1 --pretty=%h 2> /dev/null`"
+if [ -z "$sha" ]; then
+  sha="0000000"
+fi
+echo -n "-git_$sha"
+
 md5cmd=md5sum
 os=$(uname)
 if [ "xDarwin" = "x$os" ] ; then
   md5cmd=md5
 fi
+echo -n "-hash_"
 cat `find . -name *.[ch] | grep -v -E '[/\\]?builddata.c$'`| $md5cmd | awk '{ print $1; }'