forked from openSUSE/release-notes-openSUSE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
173 lines (143 loc) · 5.75 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
#
# Copyright (c) 2014 Rick Salevsky <[email protected]>
# Copyright (c) 2016 Stefan Knorr <[email protected]>
#
# How to use this makefile:
# * After updating the XML: $ make po
# * When creating output: $ make linguas; make all
# * To clean up: $ make clean
.PHONY: clean po pot pdf text single-html yast-html translatedxml profile english
ifndef LANGS
LANGS := $(shell cat po/LINGUAS)
endif
LANGSEN := $(LANGS) en
ifndef STYLEROOT
STYLEROOT := /usr/share/xml/docbook/stylesheet/opensuse2013-ns
endif
ifndef VERSION
VERSION := unreleased
endif
ifndef DATE
DATE := $(shell date +%Y-%0m-%0d)
endif
# Allows for DocBook profiling (hiding/showing some text).
LIFECYCLE_VALID := beta pre maintained unmaintained
ifndef LIFECYCLE
LIFECYCLE := maintained
endif
ifneq "$(LIFECYCLE)" "$(filter $(LIFECYCLE),$(LIFECYCLE_VALID))"
override LIFECYCLE := maintained
endif
# Update all PO files
PO_FILES := $(wildcard po/*.po)
# For output, use only those files that have at least 60% translations
XML_FILES := $(foreach l, $(LANGS), xml/release-notes.$(l).xml)
PDF_FILES := $(foreach l, $(LANGSEN), build/release-notes.$(l)/release-notes.$(l)_color_$(l).pdf)
SINGLE_HTML_FILES := $(foreach l, $(LANGSEN), build/release-notes.$(l)/single-html/release-notes.$(l)/index.html)
YAST_PROFILED_FILES := $(foreach l, $(LANGSEN), build/.profiled/general_$(LIFECYCLE)/release-notes.$(l).xml)
YAST_HTML_FILES := $(foreach l, $(LANGSEN), build/release-notes.$(l)/yast-html/release-notes.$(l).html)
TXT_FILES := $(foreach l, $(LANGSEN), build/release-notes.$(l)/release-notes.$(l).txt)
DIRS := $(foreach l, $(LANGSEN), build/release-notes.$(l)/yast-html/)
# Gets the language code: release-notes.en.xml => en
LANG_COMMAND = `echo $@ | awk -F '.' '{gsub("/.*","",$$2); print($$2)}'`
LANG_COMMAND_PROFILE = `echo $@ | awk -F '.' '{gsub("/.*","",$$3); print($$3)}'`
DAPS_COMMAND_BASIC = daps -vv --styleroot $(STYLEROOT)
DAPS_COMMAND = $(DAPS_COMMAND_BASIC) -m xml/release-notes.$${lang}.xml
ITSTOOL = itstool -i /usr/share/itstool/its/docbook5.its
XSLTPROC_COMMAND = xsltproc \
--stringparam generate.toc "book toc" \
--stringparam generate.section.toc.level 0 \
--stringparam section.autolabel 1 \
--stringparam section.label.includes.component.label 2 \
--stringparam variablelist.as.blocks 1 \
--stringparam toc.max.depth 3 \
--stringparam show.comments 0 \
--stringparam generate.consistent.ids 1 \
--xinclude --nonet
# Fetch correct Report Bug link values, so translations get the correct
# version
XPATHPREFIX := //*[local-name()='docmanager']/*[local-name()='bugtracker']/*[local-name()
URL = `xmllint --noent --xpath "$(XPATHPREFIX)='url']/text()" xml/release-notes.xml`
PRODUCT = `xmllint --noent --xpath "$(XPATHPREFIX)='product']/text()" xml/release-notes.xml`
COMPONENT = `xmllint --noent --xpath "$(XPATHPREFIX)='component']/text()" xml/release-notes.xml`
ASSIGNEE = `xmllint --noent --xpath "$(XPATHPREFIX)='assignee']/text()" xml/release-notes.xml`
all: single-html yast-html pdf text
linguas: po/LINGUAS
po/LINGUAS: po/*.po po/po-selector
po/po-selector
pot: release-notes.pot
release-notes.pot: xml/release-notes.xml xml/release-notes.ent
$(DAPS_COMMAND_BASIC) -m $< validate
$(ITSTOOL) -o $@ $<
po: $(PO_FILES)
po/%.po: release-notes.pot
if [ -r $@ ]; then \
msgmerge --previous --update $@ $<; \
else \
msgen -o $@ $<; \
fi
po/%.mo: po/%.po
msgfmt $< -o $@
english: build/release-notes.en/single-html/release-notes.en/index.html \
build/release-notes.en/release-notes.en_color_en.pdf \
build/release-notes.en/release-notes.en.txt
# FIXME: Enable use of its:translate attribute in GeekoDoc/DocBook...
xml/release-notes.%.xml: po/%.mo xml/release-notes.ent xml/release-notes.xml
$(ITSTOOL) -m $< -o [email protected] xml/release-notes.xml
sed -i -r \
-e 's_\t+_ _' -e 's_\s+$$__' \
xsltproc \
--stringparam 'version' "$(VERSION)" \
--stringparam 'dmurl' "$(URL)" \
--stringparam 'dmproduct' "$(PRODUCT)" \
--stringparam 'dmcomponent' "$(COMPONENT)" \
--stringparam 'dmassignee' "$(ASSIGNEE)" \
--stringparam 'date' "$(DATE)" \
fix-up.xsl [email protected] \
> $@
daps-xmlformat -i $@
$(DAPS_COMMAND_BASIC) -m $@ validate
translatedxml: xml/release-notes.xml xml/release-notes.ent $(XML_FILES)
xsltproc \
--stringparam 'version' "$(VERSION)" \
--stringparam 'dmurl' "$(URL)" \
--stringparam 'dmproduct' "$(PRODUCT)" \
--stringparam 'dmcomponent' "$(COMPONENT)" \
--stringparam 'dmassignee' "$(ASSIGNEE)" \
--stringparam 'date' "$(DATE)" \
fix-up.xsl $< \
> xml/release-notes.en.xml
pdf: $(PDF_FILES)
$(PDF_FILES): po/LINGUAS translatedxml
lang=$(LANG_COMMAND) ; \
$(DAPS_COMMAND) pdf PROFCONDITION="general\;$(LIFECYCLE)" \
--param "generate.consistent.ids=1"
single-html: $(SINGLE_HTML_FILES)
$(SINGLE_HTML_FILES): po/LINGUAS translatedxml
lang=$(LANG_COMMAND) ; \
$(DAPS_COMMAND) html --single \
--stringparam "homepage='https://www.opensuse.org'" \
--param "generate.consistent.ids=1" \
PROFCONDITION="general\;$(LIFECYCLE)"
yast-html: | $(DIRS) $(YAST_HTML_FILES)
$(YAST_HTML_FILES): po/LINGUAS $(YAST_PROFILED_FILES)
lang=$(LANG_COMMAND) ; \
$(XSLTPROC_COMMAND) /usr/share/daps/daps-xslt/relnotes/yast.xsl build/.profiled/general_$(LIFECYCLE)/release-notes.$${lang}.xml > $@
# xsltproc by itself does not support profiling, so we need to do this
# beforehand for YaST HTML
profile: $(YAST_PROFILED_FILES)
$(YAST_PROFILED_FILES): po/LINGUAS translatedxml
lang=$(LANG_COMMAND_PROFILE) ; \
$(DAPS_COMMAND) profile \
PROFCONDITION="general\;$(LIFECYCLE)"
text: $(TXT_FILES)
$(TXT_FILES): po/LINGUAS translatedxml
lang=$(LANG_COMMAND) ; \
LANG=$${lang} $(DAPS_COMMAND) text \
PROFCONDITION="general\;$(LIFECYCLE)"
$(DIRS):
mkdir -p $@
clean:
rm -rf po/*~ po/*.mo po/LINGUAS build/ xml/release-notes.*.xml xml/release-notes.*.xml.0 release-notes.pot