summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2008-06-01 22:01:05 +0200
committerJonas Smedegaard <dr@jones.dk>2008-06-01 22:01:05 +0200
commit2f1163e14125ab7e9733473f735f221eb9d1aaeb (patch)
treef9f5706f76364a6eaa65b0e30581f83539cca7d6
parent9f07627f00c980d3e04f9c69c785a4f519e85a2d (diff)
Major improvements to git rules.
-rw-r--r--make/git.mk26
-rw-r--r--make/rules.mk26
2 files changed, 37 insertions, 15 deletions
diff --git a/make/git.mk b/make/git.mk
index 930e77a..b870f1b 100644
--- a/make/git.mk
+++ b/make/git.mk
@@ -1,11 +1,27 @@
+# main local branch (the one we want checked out)
+master = master
+
+# all local branches (including those needed by child clones)
+branches = $(master)
+
+# local name of origin
+origin = origin
+
+currentbranch := $(shell git branch | grep \* | awk '{ print $2 }')
+noncurrentbranches = $(filter-out $(currentbranch),$(branches))
+
update:
+ $(if $(filter $(currentbranch),$(master)),,git checkout "$(master)")
git pull
init:
- git init
- git remote add -f -t "$(master)" -m "$(master)" origin "$(origin)"
- git merge origin
- git branch -m "$(master)"
- git config remote.origin.push +"refs/heads/$(master)":"refs/heads/$(master)"
+# Assume that initial cloning is done already when invoking this target
+# git init
+# git remote add -f -t "$(master)" -m "$(master)" origin "$(origin)"
+# git merge origin
+# git config remote.origin.push +"refs/heads/$(master)":"refs/heads/$(master)"
+ $(if $(filter $(currentbranch),$(master)),,git branch -f "$(master)" "$(origin)/$(master)")
+ $(if $(noncurrentbranches),$(foreach branch,$(noncurrentbranches),git branch -f "$(branch)" "$(origin)/$(branch)" &&) true)
+ $(if $(filter $(currentbranch),$(master)),,git checkout -f "$(master)")
.PHONY: update init
diff --git a/make/rules.mk b/make/rules.mk
index 1c10382..2dcfc96 100644
--- a/make/rules.mk
+++ b/make/rules.mk
@@ -8,22 +8,27 @@ $(foreach source,$(SOURCES),$(eval $(call SOURCE_template,$(source),$($(source)_
+# Initially clone, and later pull, all Git repositories:
+# * Clone master branches from remote origin
+# * Clone each non-master from local master
+
# 1:moduledir 2:locale 3:mastermodule 4:source
define MODULE_template
+$(3)_BRANCHES += $$(subst -LOCALE,$(2:%=-$(2)),$$($(4)_BRANCH))
+
$(4): $(1)
+ifneq ($(2),)
+$(1): $$(subst module,$(3),$$(masterdir))
+endif
-$(1): origin = $$(subst MODULE,$(3),$$($(4)_ORIGIN))
+$(1): action = $$(if $(wildcard $(1)/.git),update,init)
+$(1): origin = $$(if $(2),$(3),$$(subst MODULE,$(3),$$($(4)_ORIGIN)))
$(1): master = $$(subst -LOCALE,$(2:%=-$(2)),$$($(4)_BRANCH))
+$(1): branches = $$(if $(2),,$$(filter-out $$(master),$$($(3)_BRANCHES)))
$(1):
- mkdir -p $$@
- @if [ -d "$$@/.git" ]; then \
- echo $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" update; \
- $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" update; \
- else \
- echo $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" master="$$(master)" origin="$$(origin)" init; \
- $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" master="$$(master)" origin="$$(origin)" init; \
- fi
-
+ @[ -d "$$(dir $$@)" ] || ( echo mkdir -p "$$(dir $$@)" && mkdir -p "$$(dir $$@)" )
+ @[ -d "$$@" ] || ( echo git clone "$$(origin)" "$$@" && git clone -o "$(4)" "$$(origin)" "$$@" )
+ @$(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" master="$$(master)" branches="$$(branches)" origin="$(4)" "$$(action)"
# WARNING: this may wipe unrelated files too!
ultraclean::
@@ -38,6 +43,7 @@ $(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(eval $(call
$(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(foreach locale,$($(source)_LOCALES),$(eval $(call MODULE_template,$(l10ndir),$(locale),$(module),$(source))))))
+
# Override po4a with local Markdown-supportive text module
export PERL5LIB = $(CURDIR)/perl