-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
267 lines (231 loc) · 6.95 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# The Zilla::Dist Makefile
#
# This is the shared Zilla::Dist Makefile. Most of the `zild` commands simply
# invoke this Makefile from the installed share directory for Zilla::Dist.
#
# For instance, both of these commands:
#
# zild update
# zild make update
#
# just invoke:
#
# make -f `zild makefile` update
.PHONY: cpan test
SHELL := bash
MAKE_FILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
ROOT := $(shell dirname $(dir $(MAKE_FILE)))
BASE := $(shell pwd)
MAKE := make -f $(MAKE_FILE)
PERL ?= $(shell which perl)
ZILD := $(PERL) -S zild
LOG := $(PERL_ZILLA_DIST_RELEASE_LOG)
export PATH := $(BASE)/bin:$(PATH)
# XXX Change to `metaspec =zild libname`
NAMEPATH := $(shell $(ZILD) meta =zild/libname)
NAMEPATH := $(subst ::,/,$(NAMEPATH))
ifeq (,$(NAMEPATH))
NAMEPATH := $(shell $(ZILD) meta name)
endif
NAME := $(shell $(ZILD) meta name)
VERSION := $(shell $(ZILD) meta version)
RELEASE_BRANCH ?= $(shell $(ZILD) meta branch)
DISTDIR := $(NAME)-$(VERSION)
DIST := $(DISTDIR).tar.gz
NAMEPATH := $(subst -,/,$(NAMEPATH))
SUCCESS := "$(DIST) Released!!!"
README :=
ifeq (,$(shell zild meta =zild/no-readme))
ifneq (,$(wildcard $(BASE)/ReadMe.pod))
README := ReadMe.pod
endif
ifneq (,$(wildcard $(BASE)/ReadMe.md))
README := ReadMe.md
endif
endif
export TESTML_RUN := perl
default: help
help:
@echo 'Makefile targets:'
@echo ''
@echo ' make test - Run the repo tests'
@echo ' make test-dev - Run the developer only tests'
@echo ' make test-all - Run all tests'
@echo ' make test-cpan - Make cpan/ dir and run tests in it'
@echo ' make test-dist - Run the dist tests'
@echo ''
@echo ' make install - Install the dist from this repo'
@echo ' make prereqs - Install the CPAN prereqs'
@echo ' make update - Update generated files'
@echo ' make release - Release the dist to CPAN'
@echo ''
@echo ' make cpan - Make cpan/ dir with dist.ini'
@echo ' make cpanshell - Open new shell into new cpan/'
@echo ''
@echo ' make dist - Make CPAN distribution tarball'
@echo ' make distdir - Make CPAN distribution directory'
@echo ' make distshell - Open new shell into new distdir'
@echo ''
@echo ' make upgrade - Upgrade the build system (Makefile)'
@echo ' make readme - Make the ReadMe.pod file'
@echo ' make travis - Make a travis.yml file'
@echo ' make uninstall - Uninstall the dist from this repo'
@echo ''
@echo ' make clean - Clean up build files'
@echo ' make help - Show this help'
@echo ''
#------------------------------------------------------------------------------
# Test Targets:
#------------------------------------------------------------------------------
test:
ifeq ($(wildcard pkg/no-test),)
ifneq ($(wildcard test),)
$(PERL) -S prove -lv test
endif
else
@echo "Testing not available. Use 'test-dist' instead."
endif
test-dev:
ifneq ($(wildcard test/devel),)
$(PERL) -S prove -lv test/devel
endif
test-all: test test-dev
test-cpan cpantest: cpan
ifeq ($(wildcard pkg/no-test),)
@echo '***** Running tests in `cpan/` directory'
(cd cpan; $(PERL) -S prove -lv t) && make clean
else
@echo "Testing not available. Use 'test-dist' instead."
endif
test-dist disttest: cpan
@echo '***** Running tests in `$(DISTDIR)` directory'
(cd cpan; dzil test) && $(MAKE) clean
#------------------------------------------------------------------------------
# Installation Targets:
#------------------------------------------------------------------------------
install: distdir
@echo '***** Installing $(DISTDIR)'
(cd $(DISTDIR); $(PERL) Makefile.PL; make install)
$(MAKE) clean
prereqs:
cpanm `$(ZILD) meta requires`
update:
@echo '***** Updating/regenerating repo content'
$(MAKE) readme about travis version webhooks
#------------------------------------------------------------------------------
# Release and Build Targets:
#------------------------------------------------------------------------------
release:
ifneq ($(LOG),)
@echo "$$(date) - Release $(DIST) STARTED" >> $(LOG)
endif
$(MAKE) clean
$(MAKE) update
$(MAKE) check-release
$(MAKE) date
$(MAKE) test-all
RELEASE_TESTING=1 $(MAKE) test-dist
@echo '***** Releasing $(DISTDIR)'
$(MAKE) dist
ifneq ($(PERL_ZILLA_DIST_RELEASE_TIME),)
@echo $$(( ( $$PERL_ZILLA_DIST_RELEASE_TIME - $$(date +%s) ) / 60 )) \
minutes, \
$$(( ( $$PERL_ZILLA_DIST_RELEASE_TIME - $$(date +%s) ) % 60 )) \
seconds, until RELEASE TIME!
@echo sleep $$(( $$PERL_ZILLA_DIST_RELEASE_TIME - $$(date +%s) ))
@sleep $$(( $$PERL_ZILLA_DIST_RELEASE_TIME - $$(date +%s) ))
endif
cpan-upload $(DIST)
ifneq ($(LOG),)
@echo "$$(date) - Release $(DIST) UPLOADED" >> $(LOG)
endif
$(MAKE) clean
[ -z "$$(git status -s)" ] || zild-git-commit
git push
git tag $(VERSION)
git push --tag
$(MAKE) clean
ifneq ($(PERL_ZILLA_DIST_AUTO_INSTALL),)
@echo "***** Installing after release"
$(MAKE) install
endif
@echo
git status
@echo
@[ -n "$$(which cowsay)" ] && cowsay "$(SUCCESS)" || echo "$(SUCCESS)"
@echo
ifneq ($(LOG),)
@echo "$$(date) - Release $(DIST) COMPLETED" >> $(LOG)
endif
cpan:
@echo '***** Creating the `cpan/` directory'
zild-make-cpan
cpanshell: cpan
@echo '***** Starting new shell in `cpan/` directory'
(cd cpan; $$SHELL)
$(MAKE) clean
dist: clean cpan
@echo '***** Creating new dist: $(DIST)'
(cd cpan; dzil build)
mv cpan/$(DIST) .
rm -fr cpan
distdir: clean cpan
@echo '***** Creating new dist directory: $(DISTDIR)'
(cd cpan; dzil build)
mv cpan/$(DIST) .
tar xzf $(DIST)
rm -fr cpan $(DIST)
distshell: distdir
@echo '***** Starting new shell in `$(DISTDIR)` directory'
(cd $(DISTDIR); $$SHELL)
$(MAKE) clean
upgrade:
@echo '***** Checking that Zilla-Dist Makefile is up to date'
cp `$(ZILD) sharedir`/Makefile ./
readme: $(README)
ReadMe.pod:
ifneq (,$(wildcard doc/$(NAMEPATH).md))
cat doc/$(NAMEPATH).md | \
zild-markdown-plus \
pandoc --from=gfm --to=json | \
zild-pandoc-json-to-pod \
> $@
else
swim --to=pod --complete --wrap --meta=Meta \
doc/$(NAMEPATH).swim > $@
endif
ReadMe.md: doc/$(NAMEPATH).md force
zild-markdown-plus < $< > $@
about:
ifeq (,$(shell zild meta =zild/no-about))
$(PERL) -S zild-render-template About
endif
travis:
ifeq (,$(shell zild meta =zild/no-travis))
$(PERL) -S zild-render-template travis.yml .travis.yml
endif
uninstall: distdir
(cd $(DISTDIR); $(PERL) Makefile.PL; make uninstall)
$(MAKE) clean
clean:
rm -fr blib cpan .build .inline $(DIST) $(DISTDIR)
find . -type d | grep '\.testml' | xargs rm -fr
distclean purge: clean
force:
true
#------------------------------------------------------------------------------
# Non-pulic-facing targets:
#------------------------------------------------------------------------------
check-release:
@echo '***** Checking readiness to release $(DIST)'
RELEASE_BRANCH=$(RELEASE_BRANCH) zild-check-release
git stash
rm -fr .git/rebase-apply
git pull --rebase origin $(RELEASE_BRANCH)
git stash pop
date:
$(ZILD) changes date "`date`"
version:
$(PERL) -S zild-version-update
webhooks:
$(PERL) -S zild webhooks