-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.release
81 lines (67 loc) · 2.51 KB
/
Makefile.release
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
# Makefile.release
# Build the release archives of an e-book project.
# By Marcos Cruz (programandala.net)
# http://ne.alinome.net
# Last modified 20210503T1816+0200.
# See change log at the end of the file.
# ==============================================================
# Input variables, set by <Makefile>:
#
# book = basename of the main Asciidoctor source (without the ".adoc"
# extension), in the <scr> directory. Example: "my_book".
#
# version_file = path to the Asciidoctor file containing the `:revnumber:`
# attribute with the version number of the book. Examples: "src/VERSION.adoc",
# "src/my_book.adoc".
#
# prerequisites = list of prerequisites of the release archive rules, usually
# just "*.adoc target/" to include de main documents and the target directory.
#
# branch = name of the directory containing the prerequisites (e.g. the
# <target> directory); in Git repositories it's usually "$(book)"; in Fossil
# repositories it's usually "trunk".
#
# release_dir = directory in the project tree where the release archives will
# be created; if not specified, its default value <tmp> will be used.
release=v$(shell grep ":revnumber:" $(version_file) | sed -e "s/:revnumber: \\+//" )
release_dir ?= tmp
.PHONY: release
release: tgz zip
.PHONY: tgz
tgz: $(release_dir)/$(book)_$(release).tar.gz
.PHONY: zip
zip: $(release_dir)/$(book)_$(release).zip
$(release_dir)/$(book)_$(release).tar.gz: $(prerequisites)
cd .. ; \
ln -sfn $(branch) $(book)_$(release) ; \
tar czf \
$(book)_$(release)/$@ \
--exclude="*.swp" \
--exclude=".gitignore" \
--exclude="*_cover.jpg" \
$(addprefix $(book)_$(release)/,$^) ; \
rm -f $(book)_$(release)
$(release_dir)/$(book)_$(release).zip: $(prerequisites)
cd .. ; \
ln -sfn $(branch) $(book)_$(release) ; \
zip -9r \
$(book)_$(release)/$@ \
$(addprefix $(book)_$(release)/,$^) \
--exclude "*.gitignore" "*.swp" "*_cover.jpg" ; \
rm -f $(book)_$(release)
# ==============================================================
# Change log {{{1
# 2020-11-05: Start.
#
# 2020-11-09: Exclude the cover image, but keep its thumb version. Add "v"
# prefix to the release version.
#
# 2020-11-14: Improve: move the setting of the "branch" and "prerequisites"
# variables to the main Makefile. This additional configuration makes the
# building of release archives compatible with Fossil repositories.
#
# 2021-04-24: Fix typo in comment. Fix the default branch name in Fossil
# repositories.
#
# 2021-05-03: Make the directory configurable, but use <tmp> by default to keep
# backwards compatibility.