Makefile: use git-describe to mark the git version.
Note: with this commit, the GIT maintainer workflow must change. GIT-VERSION-GEN is now the file to munge when the default version needs to be changed, not Makefile. The tag needs to be pushed into the repository to build the official tarball and binary package beforehand. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Dec 27, 2005 at 14:40 UTC
9b88fcef7dd6327cc3aba3927e56fef6f6c4d628
3 files changed
+34
-5
.gitignore
+1
@@ -1,3 +1,4 @@
1
+GIT-VERSION-FILE
2
git
3
git-add
4
git-am
GIT-VERSION-GEN
new
+18
@@ -0,0 +1,18 @@
1
+#!/bin/sh
2
+
3
+GVF=GIT-VERSION-FILE
4
+
5
+VN=$(git describe --abbrev=4 HEAD 2>/dev/null) || VN=v1.0.GIT
6
+VN=$(expr "$VN" : v'\(.*\)')
7
+if test -r $GVF
8
+then
9
+ VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
10
+else
11
+ VC=unset
12
+fi
13
+test "$VN" = "$VC" || {
14
+ echo >&2 "GIT_VERSION = $VN"
15
+ echo "GIT_VERSION = $VN" >$GVF
16
+}
17
+
18
+
Makefile
+15
-5
@@ -55,7 +55,9 @@ all:
55
# Define USE_STDEV below if you want git to care about the underlying device
56
# change being considered an inode change from the update-cache perspective.
57
58
-GIT_VERSION = 1.0.GIT
58
+GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
59
+ @sh ./GIT-VERSION-GEN
60
+-include GIT-VERSION-FILE
61
62
# CFLAGS and LDFLAGS are for the users to override from the command line.
63
@@ -369,7 +371,7 @@ all: $(ALL_PROGRAMS)
371
all:
372
$(MAKE) -C templates
373
372
-git$X: git.c $(LIB_FILE) Makefile
374
+git$X: git.c $(LIB_FILE)
375
$(CC) -DGIT_EXEC_PATH='"$(bindir)"' -DGIT_VERSION='"$(GIT_VERSION)"' \
376
$(CFLAGS) $(COMPAT_CFLAGS) -o $@ $(filter %.c,$^) $(LIB_FILE)
377
@@ -398,8 +400,12 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
400
git-cherry-pick: git-revert
401
cp $< $@
402
401
-# format-patch records GIT_VERSION
402
-git-format-patch: Makefile
403
+# These can record GIT_VERSION
404
+git$X git.spec \
405
+ $(patsubst %.sh,%,$(SCRIPT_SH)) \
406
+ $(patsubst %.perl,%,$(SCRIPT_PERL)) \
407
+ $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
408
+ : GIT-VERSION-FILE
409
410
%.o: %.c
411
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
@@ -475,7 +481,7 @@ install-doc:
481
482
### Maintainer's dist rules
483
478
-git.spec: git.spec.in Makefile
484
+git.spec: git.spec.in
485
sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
486
487
GIT_TARNAME=git-$(GIT_VERSION)
@@ -510,4 +516,8 @@ clean:
516
$(MAKE) -C Documentation/ clean
517
$(MAKE) -C templates clean
518
$(MAKE) -C t/ clean
519
+ rm -f GIT-VERSION-FILE
520
+
521
+.PHONY: all install clean
522
+.PHONY: .FORCE-GIT-VERSION-FILE
523