1 .PHONY: check-versions reset-versions check-mono
5 # usage $(call CheckVersionTemplate (name,MAKEFILE VAR,repo name))
6 # usage $(call CheckVersionTemplate (mono,MONO,mono))
8 define CheckVersionTemplate
9 #$(eval REPOSITORY_$(2):=$(shell test -z $(3) && echo $(1) || echo "$(3)"))
10 #$(eval DIRECTORY_$(2):=$(shell ruby versions.rb get-dir $(1)))
11 #$(eval DIRECTORY_$(2):=$(shell test -z $(DIRECTORY_$(2)) && echo $(1) || echo $(DIRECTORY_$(2))))
12 #$(eval MODULE_$(2):=$(shell ruby versions.rb get-url $(1)))
13 #$(eval NEEDED_$(2)_VERSION:=$(shell ruby versions.rb get-rev $(1)))
14 #$(eval $(2)_BRANCH_AND_REMOTE:=$(shell ruby versions.rb get-remote-branch $(1)))
16 #$(eval $(2)_VERSION:=$$$$(shell cd $($(2)_PATH) 2>/dev/null && git rev-parse HEAD ))
18 #$(eval NEEDED_$(2)_BRANCH:=$(word 2, $(subst /, ,$($(2)_BRANCH_AND_REMOTE))))
19 #$(eval NEEDED_$(2)_REMOTE:=$(word 1, $(subst /, ,$($(2)_BRANCH_AND_REMOTE))))
20 #$(eval $(2)_BRANCH:=$$$$(shell cd $($(2)_PATH) 2>/dev/null && git symbolic-ref --short HEAD 2>/dev/null))
23 @if test x$$(IGNORE_$(2)_VERSION) = "x"; then \
24 if test ! -d $($(2)_PATH); then \
25 if test x$$(RESET_VERSIONS) != "x"; then \
26 make reset-$(1) || exit 1; \
28 echo "Your $(1) checkout is missing, please run 'make reset-$(1)'"; \
29 touch .check-versions-failure; \
32 if test "x$($(2)_VERSION)" != "x$(NEEDED_$(2)_VERSION)" ; then \
33 if test x$$(RESET_VERSIONS) != "x"; then \
34 make reset-$(1) || exit 1; \
36 echo "Your $(1) version is out of date, please run 'make reset-$(1)' (found $($(2)_VERSION), expected $(NEEDED_$(2)_VERSION))"; \
37 test -z "$(BUILD_REVISION)" || $(MAKE) test-$(1); \
38 touch .check-versions-failure; \
40 elif test "x$($(2)_BRANCH)" != "x$(NEEDED_$(2)_BRANCH)" ; then \
41 if test x$$(RESET_VERSIONS) != "x"; then \
42 test -z "$(BUILD_REVISION)" || $(MAKE) test-$(1); \
43 make reset-$(1) || exit 1; \
45 echo "Your $(1) branch is out of date, please run 'make reset-$(1)' (found $($(2)_BRANCH), expected $(NEEDED_$(2)_BRANCH))"; \
46 touch .check-versions-failure; \
54 @echo " REPOSITORY_$(2)=$(REPOSITORY_$(2))"
55 @echo " DIRECTORY_$(2)=$(DIRECTORY_$(2))"
56 @echo " MODULE_$(2)=$(MODULE_$(2))"
57 @echo " NEEDED_$(2)_VERSION=$(NEEDED_$(2)_VERSION)"
58 @echo " $(2)_VERSION=$($(2)_VERSION)"
59 @echo " $(2)_BRANCH_AND_REMOTE=$($(2)_BRANCH_AND_REMOTE)"
60 @echo " NEEDED_$(2)_BRANCH=$(NEEDED_$(2)_BRANCH)"
61 @echo " NEEDED_$(2)_REMOTE=$(NEEDED_$(2)_REMOTE)"
62 @echo " $(2)_BRANCH=$($(2)_BRANCH)"
63 @echo " $(2)_PATH=$($(2)_PATH) => $(abspath $($(2)_PATH))"
66 @if test -d $($(2)_PATH); then \
67 if ! (cd $($(2)_PATH) && git show $(NEEDED_$(2)_VERSION) >/dev/null 2>&1 && git log -1 $(NEEDED_$(2)_REMOTE) >/dev/null 2>&1) ; then \
68 echo "*** git fetch `basename $$($(2)_PATH)`" && (cd $($(2)_PATH) && git fetch); \
71 echo "*** git clone $(MODULE_$(2)) --recursive $(DIRECTORY_$(2))" && (cd `dirname $($(2)_PATH)` && git clone $(MODULE_$(2)) --recursive $(DIRECTORY_$(2))); \
73 @if test x$$(IGNORE_$(2)_VERSION) = "x"; then \
74 echo "*** [$(1)] git checkout -f" $(NEEDED_$(2)_BRANCH) && (cd $($(2)_PATH) ; git checkout -f $(NEEDED_$(2)_BRANCH) || git checkout -f -b $($(2)_BRANCH_AND_REMOTE)); \
75 echo "*** [$(1)] git reset --hard $(NEEDED_$(2)_VERSION)" && (cd $($(2)_PATH) && git reset --hard $(NEEDED_$(2)_VERSION)); \
77 @echo "*** [$(1)] git submodule update --init --recursive" && (cd $($(2)_PATH) && git submodule update --init --recursive)
80 @printf "*** %-16s %-45s %s (%s)\n" "$(DIRECTORY_$(2))" "$(MODULE_$(2))" "$(NEEDED_$(2)_VERSION)" "$(NEEDED_$(2)_BRANCH)"
82 .PHONY: check-$(1) reset-$(1) print-$(1)
84 reset-versions:: reset-$(1)
85 check-versions:: check-$(1)
86 print-versions:: print-$(1)
90 ifneq ($(findstring mono-extensions, $(CHECK_VERSIONS)),)
91 $(eval $(call CheckVersionTemplate,mono-extensions,MONO_EXTENSIONS))
97 @if test -e .check-versions-failure; then \
98 rm .check-versions-failure; \
99 echo One or more modules needs update; \
102 echo All dependent modules up to date; \
106 @make check-versions RESET_VERSIONS=1
108 XAMARIN_SUBMODULES=mono-extensions
110 check-versions-xamarin:
111 $(MAKE) check-versions CHECK_VERSIONS=$(XAMARIN_SUBMODULES)
113 reset-versions-xamarin:
114 $(MAKE) reset-versions CHECK_VERSIONS=$(XAMARIN_SUBMODULES)
117 $(MAKE) check-versions CHECK_VERSIONS=$(XAMARIN_SUBMODULES) RESET_VERSIONS=1
120 @if [ "$(REV)" == "" ]; then echo "Usage: make bump-version-$* REV=<ref>"; exit 1; fi
121 @if [ "$(COMMIT)" == "1" ]; then git pull; fi
122 ruby versions.rb set-rev $* $(REV)
123 @if [ "$(COMMIT)" == "1" ]; then echo "Bump $* to pick up $(REV)." > msg; echo >> msg; cat msg | git commit -F - $(README); rm -f msg; fi
126 @if [ "$(BRANCH)" == "" ]; then echo "Usage: make bump-branch-$* BRANCH=<branch> REMOTE_BRANCH=<remote branch>"; exit 1; fi
127 @if [ "$(REMOTE_BRANCH)" == "" ]; then echo "Usage: make bump-branch-$* BRANCH=<branch> REMOTE_BRANCH=<remote branch>"; exit 1; fi
128 @if [ "$(COMMIT)" == "1" ]; then git pull; fi
129 ruby versions.rb set-branch $* $(BRANCH)
130 ruby versions.rb set-remote-branch $* $(REMOTE_BRANCH)
131 @if [ "$(COMMIT)" == "1" ]; then echo "Bump $* to switch to $(BRANCH) $(REMOTE BRANCH)." > msg; echo >> msg; cat msg | git commit -F - $(README); rm -f msg; fi
133 __bump-current-version-%:
134 @if [ "$(COMMIT)" == "1" ]; then git pull; fi
135 REV=$(shell cd $(TOP)/../$* && git log -1 --pretty=format:%H); \
136 ruby versions.rb set-rev $* $$REV
137 if [ "$(COMMIT)" == "1" ]; then echo "Bump $* to pick up $$REV:" > msg; echo >> msg; cat msg | git commit -F - $(README); rm -f msg; fi
139 # Bump the given submodule to the revision given by the REV make variable
140 # If COMMIT is 1, commit the change
141 bump-mono-extensions: __bump-version-mono-extensions
142 bump-llvm: __bump-version-llvm
144 # Bump the given submodule to the branch given by the BRANCH/REMOTE_BRANCH make variables
145 # If COMMIT is 1, commit the change
146 bump-branch-mono-extensions: __bump-branch-mono-extensions
147 bump-branch-llvm: __bump-branch-llvm
149 # Bump the given submodule to its current GIT version
150 # If COMMIT is 1, commit the change
151 bump-current-mono-extensions: __bump-current-version-mono-extensions
152 bump-current-llvm: __bump-current-version-llvm
154 commit-bump-mono-extensions:
155 $(MAKE) bump-mono-extensions COMMIT=1
157 $(MAKE) bump-llvm COMMIT=1
159 commit-bump-current-mono-extensions:
160 $(MAKE) bump-current-mono-extensions COMMIT=1
161 commit-bump-current-llvm:
162 $(MAKE) bump-current-llvm COMMIT=1