Diff options
Diffstat (limited to 'source/cgit.mk')
| -rw-r--r-- | source/cgit.mk | 25 |
1 file changed, 17 insertions, 8 deletions
diff --git a/source/cgit.mk b/source/cgit.mk index a4b9758..d0c9e68 100644 --- a/source/cgit.mk +++ b/source/cgit.mk @@ -9,13 +9,11 @@ # ../../build. include Makefile -# TOOLSDIR and BUILDDIR are named relative to the project root because the -# version recipe changes into the root before using them. CGIT_SRC and -# CGIT_BUILD lead to the sources and the output from vendor/git, where -# everything else here runs. +# BUILDDIR is named relative to the project root because the version recipe +# changes into the root before using it. CGIT_SRC and CGIT_BUILD lead to the +# sources and the output from vendor/git, where everything else here runs. CGIT_ROOT = ../.. SRCDIR = source -TOOLSDIR = tools BUILDDIR = build CGIT_SRC = $(CGIT_ROOT)/$(SRCDIR) CGIT_BUILD = $(CGIT_ROOT)/$(BUILDDIR) @@ -24,11 +22,22 @@ CGIT_BUILD = $(CGIT_ROOT)/$(BUILDDIR) # Makefile exports, which leaves out the build options this file reads. -include $(CGIT_ROOT)/cgit.conf -# The CGIT_ values used below are exported by the top level Makefile. +# The CGIT_ values used below are exported by the top level Makefile. git +# describe names the version when it runs at the top of the cgit working tree, +# rather than in the bundled git, and CGIT_VERSION stands in for a tarball or +# a clone with no tags. The file is left alone when its line is unchanged, +# since everything that includes it would otherwise rebuild. $(CGIT_BUILD)/VERSION: force-version @mkdir -p $(CGIT_BUILD)/ - @cd $(CGIT_ROOT) && \ - '$(SHELL_PATH_SQ)' $(TOOLSDIR)/gen-version.sh "$(CGIT_VERSION)" $(BUILDDIR)/VERSION + @cd $(CGIT_ROOT) && version='$(CGIT_VERSION)' && \ + if test "$$(git rev-parse --git-dir 2>/dev/null)" = .git && \ + described=$$(git describe --abbrev=4 HEAD 2>/dev/null); then \ + version=$$described; \ + fi && \ + line="CGIT_VERSION = $$version" && \ + if test "$$(cat $(BUILDDIR)/VERSION 2>/dev/null)" != "$$line"; then \ + echo "$$line" >$(BUILDDIR)/VERSION && echo "$$line"; \ + fi -include $(CGIT_BUILD)/VERSION .PHONY: force-version |
