forked from rabbitmq/rabbitmq-public-umbrella
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
232 lines (184 loc) · 6.45 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
.PHONY: default
default:
@echo No default target && false
REPOS:= \
rabbitmq-server \
rabbitmq-codegen \
rabbitmq-java-client \
rabbitmq-dotnet-client \
rabbitmq-test \
cowboy-wrapper \
eldap-wrapper \
mochiweb-wrapper \
rabbitmq-amqp1.0 \
rabbitmq-auth-backend-ldap \
rabbitmq-auth-mechanism-ssl \
rabbitmq-consistent-hash-exchange \
rabbitmq-erlang-client \
rabbitmq-federation \
rabbitmq-federation-management \
rabbitmq-management \
rabbitmq-management-agent \
rabbitmq-management-visualiser \
rabbitmq-metronome \
rabbitmq-web-dispatch \
rabbitmq-mqtt \
rabbitmq-shovel \
rabbitmq-shovel-management \
rabbitmq-stomp \
rabbitmq-toke \
rabbitmq-tracing \
rabbitmq-web-stomp \
rabbitmq-web-stomp-examples \
sockjs-erlang-wrapper \
toke \
webmachine-wrapper
BRANCH:=master
UMBRELLA_REPO_FETCH:=$(shell git remote -v 2>/dev/null | awk '/^origin\t.+ \(fetch\)$$/ { print $$2; }')
ifdef UMBRELLA_REPO_FETCH
GIT_CORE_REPOBASE_FETCH:=$(shell dirname $(UMBRELLA_REPO_FETCH))
GIT_CORE_SUFFIX_FETCH:=$(suffix $(UMBRELLA_REPO_FETCH))
else
GIT_CORE_REPOBASE_FETCH:=https://github.com/rabbitmq
GIT_CORE_SUFFIX_FETCH:=.git
endif
UMBRELLA_REPO_PUSH:=$(shell git remote -v 2>/dev/null | awk '/^origin\t.+ \(push\)$$/ { print $$2; }')
ifdef UMBRELLA_REPO_PUSH
GIT_CORE_REPOBASE_PUSH:=$(shell dirname $(UMBRELLA_REPO_PUSH))
GIT_CORE_SUFFIX_PUSH:=$(suffix $(UMBRELLA_REPO_PUSH))
else
GIT_CORE_REPOBASE_PUSH:[email protected]:rabbitmq
GIT_CORE_SUFFIX_PUSH:=.git
endif
VERSION:=0.0.0
#----------------------------------
all:
$(MAKE) -f all-packages.mk all-packages VERSION=$(VERSION)
test:
$(MAKE) -f all-packages.mk test-all-packages VERSION=$(VERSION)
release:
$(MAKE) -f all-packages.mk all-releasable VERSION=$(VERSION)
clean:
$(MAKE) -f all-packages.mk clean-all-packages
check-xref:
$(MAKE) -f all-packages.mk check-xref-packages
plugins-dist: release
rm -rf $(PLUGINS_DIST_DIR)
mkdir -p $(PLUGINS_DIST_DIR)
$(MAKE) -f all-packages.mk copy-releasable VERSION=$(VERSION) PLUGINS_DIST_DIR=$(PLUGINS_DIST_DIR)
plugins-srcdist:
rm -rf $(PLUGINS_SRC_DIST_DIR)
mkdir -p $(PLUGINS_SRC_DIST_DIR)/licensing
rsync -a --exclude '.git*' rabbitmq-erlang-client $(PLUGINS_SRC_DIST_DIR)/
touch $(PLUGINS_SRC_DIST_DIR)/rabbitmq-erlang-client/.srcdist_done
rsync -a --exclude '.git*' rabbitmq-server $(PLUGINS_SRC_DIST_DIR)/
touch $(PLUGINS_SRC_DIST_DIR)/rabbitmq-server/.srcdist_done
$(MAKE) -f all-packages.mk copy-srcdist VERSION=$(VERSION) PLUGINS_SRC_DIST_DIR=$(PLUGINS_SRC_DIST_DIR)
cp Makefile *.mk generate* $(PLUGINS_SRC_DIST_DIR)/
echo "This is the released version of rabbitmq-public-umbrella. \
You can clone the full version with: git clone https://github.com/rabbitmq/rabbitmq-public-umbrella.git" > $(PLUGINS_SRC_DIST_DIR)/README
PRESERVE_CLONE_DIR=1 $(MAKE) -C $(PLUGINS_SRC_DIST_DIR) clean
rm -rf $(PLUGINS_SRC_DIST_DIR)/rabbitmq-server
#----------------------------------
# Convenience aliases
.PHONY: co
co: checkout
.PHONY: ci
ci: checkin
.PHONY: up
up: update
.PHONY: st
st: status
.PHONY: up_c
up_c: named_update
#----------------------------------
$(REPOS):
retries=5; \
while ! git clone $(GIT_CORE_REPOBASE_FETCH)/$@$(GIT_CORE_SUFFIX_FETCH); do \
retries=$$((retries - 1)); \
if test "$$retries" = 0; then break; fi; \
sleep 1; \
done
test -d $@
global_user_name="$$(git config --global user.name)"; \
global_user_email="$$(git config --global user.email)"; \
user_name="$$(git config user.name)"; \
user_email="$$(git config user.email)"; \
cd $@ && \
git remote set-url --push origin $(GIT_CORE_REPOBASE_PUSH)/$@$(GIT_CORE_SUFFIX_PUSH) && \
if test "$$global_user_name" != "$$user_name"; then git config user.name "$$user_name"; fi && \
if test "$$global_user_email" != "$$user_email"; then git config user.email "$$user_email"; fi
.PHONY: checkout
checkout: $(REPOS)
.PHONY: list-repos
list-repos:
@for repo in $(REPOS); do echo $$repo; done
.PHONY: sync-gituser
sync-gituser:
@global_user_name="$$(git config --global user.name)"; \
global_user_email="$$(git config --global user.email)"; \
user_name="$$(git config user.name)"; \
user_email="$$(git config user.email)"; \
for repo in $(REPOS); do \
cd $$repo && \
git config --unset user.name && \
git config --unset user.email && \
if test "$$global_user_name" != "$$user_name"; then git config user.name "$$user_name"; fi && \
if test "$$global_user_email" != "$$user_email"; then git config user.email "$$user_email"; fi && \
cd ..; done
.PHONY: sync-gitremote
sync-gitremote:
@for repo in $(REPOS); do \
cd $$repo && \
git remote set-url --fetch origin $(GIT_CORE_REPOBASE_FETCH)/$$repo$(GIT_CORE_SUFFIX_FETCH) && \
git remote set-url --push origin $(GIT_CORE_REPOBASE_PUSH)/$$repo$(GIT_CORE_SUFFIX_PUSH) && \
cd ..; done
#----------------------------------
# Subrepository management
# $(1) is the target
# $(2) is the target dependency. Can use % to get current REPO
# $(3) is the target body. Can use % to get current REPO
define repo_target
.PHONY: $(1)
$(1): $(2)
$(3)
endef
# $(1) is the list of repos
# $(2) is the suffix
# $(3) is the target dependency. Can use % to get current REPO
# $(4) is the target body. Can use % to get current REPO
define repo_targets
$(foreach REPO,$(1),$(call repo_target,$(REPO)+$(2),\
$(patsubst %,$(3),$(REPO)),$(patsubst %,$(4),$(REPO))))
endef
# Do not allow status to fork with -j otherwise output will be garbled
.PHONY: status
status: checkout
@for repo in . $(REPOS); do \
echo "$$repo:"; \
cd "$$repo" && git status -s && cd - >/dev/null; \
done
.PHONY: pull
pull: $(foreach DIR,. $(REPOS),$(DIR)+pull)
$(eval $(call repo_targets,. $(REPOS),pull,| %,\
(cd % && git pull --ff-only)))
.PHONY: update
update: pull
.PHONY: named_update
named_update: $(foreach DIR,. $(REPOS),$(DIR)+named_update)
$(eval $(call repo_targets,. $(REPOS),named_update,| %,\
(cd % && git fetch -p && git checkout $(BRANCH) && \
(test "$$$$(git branch | grep '^*')" = "* (detached from $(BRANCH))" || \
git pull --ff-only))))
.PHONY: tag
tag: $(foreach DIR,. $(REPOS),$(DIR)+tag)
$(eval $(call repo_targets,. $(REPOS),tag,| %,\
(cd % && git tag $(TAG))))
.PHONY: push
push: $(foreach DIR,. $(REPOS),$(DIR)+push)
$(eval $(call repo_targets,. $(REPOS),push,| %,\
(cd % && git push && git push --tags)))
.PHONY: checkin
checkin: $(foreach DIR,. $(REPOS),$(DIR)+checkin)
$(eval $(call repo_targets,. $(REPOS),checkin,| %,\
(cd % && (test -z "$$$$(git status -s -uno)" || git commit -a))))