Browse code

makefile: REPO_VER: try to detect dirty local repo

- add -dirty to the git sha if when autover.h is generated the local
repository contains locally modified files.
- make tar forces autover.h generation

Andrei Pelinescu-Onciul authored on 24/06/2009 20:25:33
Showing 1 changed files
... ...
@@ -62,6 +62,8 @@
62 62
 #               $(MAKE) invocation (andrei)
63 63
 #  2009-04-22  don't rebuild config.mak or modules.lst if not needed
64 64
 #              (e.g. on clean) (andrei)
65
+#  2009-06-24  auto-generate autover.h, containing the REPO_VER macro, defined
66
+#               to the top git commit sha (if git is found) (andrei)
65 67
 #
66 68
 
67 69
 # check make version
... ...
@@ -452,14 +454,18 @@ modules-cfg modules-list modules-lst:
452 452
 
453 453
 ifneq ($(wildcard .git),)
454 454
 # if .git/ exists
455
-repo_ver=$(shell git rev-parse --short=6 HEAD 2>/dev/null || echo "unknown" )
455
+repo_ver=$(shell  RV=`git rev-parse --verify --short=6 HEAD 2>/dev/null`;\
456
+					[ -n "$$RV" ] && \
457
+					test -n "`git diff-index --name-only HEAD >/dev/null`" && \
458
+						RV="$$RV"-dirty; echo "$$RV")
456 459
 autover_h_dep=.git
457 460
 else
458 461
 # else if .git/ does not exist
459
-repo_ver="unknown"
462
+repo_ver=
460 463
 autover_h_dep=
461 464
 endif
462 465
 
466
+
463 467
 autover.h: $(autover_h_dep)
464 468
 	@echo  "generating autover.h ($(autover_h_dep)) ..."
465 469
 	@echo "/* this file is autogenerated by make autover.h" >$@
... ...
@@ -651,7 +657,7 @@ dbg: sip-router
651 651
 
652 652
 dist: tar
653 653
 
654
-tar: 
654
+tar: autover.h
655 655
 	$(TAR) -C .. \
656 656
 		--exclude=$(notdir $(CURDIR))/test* \
657 657
 		--exclude=$(notdir $(CURDIR))/tmp* \