]> git.donarmstrong.com Git - lilypond.git/blob - make/website.make
Merge branch 'master' into translation
[lilypond.git] / make / website.make
1 ################################################################
2 # website (without the rest of the docs)
3
4 ################################################################
5 #####  SECURITY -- check these values for lilypond.org #########
6 ################################################################
7
8 ifeq ($(WEBSITE_ONLY_BUILD),1)
9   ### for lilypond.org
10   TOP_SRC_DIR=$(LILYPOND_GIT)
11   TRUSTED_DIR=$(HOME)/lilypond/trusted-scripts
12   top-src-dir=$(TOP_SRC_DIR)
13   depth=.
14   trusted-dir=$(TRUSTED_DIR)
15   script-dir=$(trusted-dir)
16   texi2html-init-file=$(trusted-dir)/lilypond-texi2html.init
17   top-htaccess=$(trusted-dir)/lilypond.org.htaccess
18   dir-htaccess=$(trusted-dir)/website-dir.htaccess
19   # grab it from PATH
20   TEXI2HTML_PROGRAM=texi2html
21   PYTHON=python
22   PYTHONPATH=$(TRUSTED_DIR)
23 else
24   ### for normal git
25   script-dir=$(top-src-dir)/scripts/build
26   texi2html-init-file=$(top-src-dir)/Documentation/lilypond-texi2html.init
27   top-htaccess=$(top-src-dir)/Documentation/web/server/lilypond.org.htaccess
28   dir-htaccess=$(top-src-dir)/Documentation/web/server/website-dir.htaccess
29   include $(config_make)
30 endif
31
32 include $(top-src-dir)/VERSION
33
34 ################################################################
35 #The 4 lines below present an option to force make website to run
36 # quietly only when it is run as make -s website.  However, we've
37 # decided not to use this switch, and run the scripts quietly all
38 # the time
39 ################################################################
40 #quiet-run = $(findstring s, $(MAKEFLAGS))
41 #ifeq ($(quiet-run),s)
42 #  quiet-flag=-q
43 #endif
44
45 #Nothing clever here - just allows the use of a boolean to control
46 #  quiet running
47 quiet-run = true
48 ifeq ($(quiet-run),true)
49   quiet-flag=-q
50 endif
51
52 ################################################################
53 OUT=out-website
54
55 WEB_LANGS := $(shell MAKEWEB=1 $(PYTHON) $(top-src-dir)/python/langdefs.py)
56
57 TEXI2HTML=ONLY_WEB_VERSION=v$(MAJOR_VERSION).$(MINOR_VERSION) TOP_SRC_DIR=$(top-src-dir) DEPTH=$(depth) PERL_UNICODE=SD \
58         $(TEXI2HTML_PROGRAM) -D web_version --prefix=index --split=section \
59                 --init-file=$(texi2html-init-file) \
60                 --I=$(dir $<) \
61                 --I=$(top-src-dir)/Documentation \
62                 --I=$(OUT) \
63                 --output=$(dir $@)
64
65 EXTRACT_TEXI_FILENAMES=$(PYTHON) $(script-dir)/extract_texi_filenames.py $(quiet-flag) \
66         --known-missing-files=$(top-src-dir)/scripts/build/website-known-missing-files.txt \
67                 -I $(top-src-dir)/Documentation \
68                 -I $(dir $<) \
69                 -I $(OUT) \
70                 -o $(OUT)
71 CREATE_VERSION=python $(script-dir)/create-version-itexi.py
72 CREATE_WEBLINKS=python $(script-dir)/create-weblinks-itexi.py
73 MASS_LINK=python $(script-dir)/mass-link.py
74 WEB_POST=python $(script-dir)/website_post.py
75 WEB_BIBS=python $(script-dir)/bib2texi.py
76
77 EXAMPLES=$(LILYPOND_WEB_MEDIA_GIT)/ly-examples
78 PICTURES=$(LILYPOND_WEB_MEDIA_GIT)/pictures
79 PDFS=$(LILYPOND_WEB_MEDIA_GIT)/pdf
80
81 SERVER_FILES=$(top-src-dir)/Documentation/web/server
82
83 # don't include web
84 MANUALS = $(MANUALS_TELY) $(MANUALS_TEXI) $(MANUALS_TRANSLATION)
85 MANUALS_TELY := $(notdir $(wildcard $(top-src-dir)/Documentation/*.tely))
86 MANUALS_TEXI := contributor.texi
87
88 # Harvest the translated manuals.
89 #   - Store each manual in a language-specific macro, e.g. when we find
90 #     de/learning.tely we add learning.tely to MANUALS_de,
91 #   - Store each manual with an added language suffix in MANUALS_TRANSLATION,
92 #     e.g. learning.de.tely for the German learning manual.
93 $(eval $(foreach l,$(WEB_LANGS),\
94         $(eval MANUALS_$(l) := $(notdir $(wildcard $(top-src-dir)/Documentation/$(l)/*.tely))) \
95         $(eval MANUALS_TRANSLATION += $(MANUALS_$(l):%.tely=%.$(l).tely)) \
96 ))
97
98 # The web.texi manuals, English and translated
99 MANUALS_WEB := web.texi $(WEB_LANGS:%=web.%.texi)
100
101 # The basename of all manuals (basename includes the language suffix)
102 MANUALS_BASE = $(basename $(MANUALS) $(MANUALS_WEB))
103
104
105 #######################
106 ### Dependency tracking
107
108 # Find the file $(1) within the texinfo include dirs and return its path.
109 # If not found, i.e. it is a generated file, then the file is ignored.
110 find-texi = \
111 $(firstword \
112         $(wildcard $(dir $<)$(1)) \
113         $(wildcard $(top-src-dir)/Documentation/$(1)) \
114 )
115
116 # Recursively scan the file $(1) for @include, search for included files
117 # within the texinfo include dirs, and return all dependencies.
118 scan-texi = \
119         $(foreach f, $(shell echo | sed -ne "/^@include[[:space:]]/s/@include//p" $(1)), \
120         $(call find-texi,$(f)) \
121         $(call scan-texi,$(call find-texi,$(f))) \
122 )
123
124 # Find dependencies for the target $@, based on the texinfo source file $<,
125 # and write the dependencies to a .dep file.
126 DO_TEXI_DEP = ( mkdir -p $(dir $@) && echo ./$@: $(call scan-texi,$<) > $@.dep ) &&
127
128 # This is where we import the .dep files so that `make' knows about
129 # the various dependencies.
130 -include dummy.dep $(wildcard $(OUT)/*.dep) $(wildcard $(OUT)/*/*.dep)
131
132
133 ###################
134 ### Generated files
135
136 bib-files = $(OUT)/others-did.itexi $(OUT)/we-wrote.itexi
137
138 css-src-files := $(notdir $(wildcard $(top-src-dir)/Documentation/css/*.css))
139 css-files = $(css-src-files:%=$(OUT)/website/css/%)
140
141 example-src-files := $(notdir $(wildcard $(EXAMPLES)/*))
142 example-files = $(example-src-files:%=$(OUT)/website/ly-examples/%)
143
144 misc-src-files := $(notdir $(wildcard $(top-src-dir)/Documentation/misc/*.*))
145 misc-files += $(misc-src-files:%=$(OUT)/website/misc/%)
146
147 picture-src-files := $(notdir $(wildcard $(PICTURES)/*))
148 picture-files = $(picture-src-files:%=$(OUT)/website/pictures/%)
149
150 pdf-src-files := $(notdir $(wildcard $(PDFS)/*))
151 pdf-files = $(pdf-src-files:%=$(OUT)/website/pdf/%)
152
153 post-files = $(OUT)/website/index.html
154
155 root-files = $(OUT)/.htaccess \
156              $(OUT)/website/.htaccess \
157              $(OUT)/website/favicon.ico \
158              $(OUT)/website/tweets.xml \
159              $(OUT)/website/robots.txt
160
161 texinfo-files = $(OUT)/index.html $(WEB_LANGS:%=$(OUT)/%/index.html)
162
163 version-files = $(OUT)/version.itexi $(OUT)/weblinks.itexi
164
165 xref-files = $(MANUALS_BASE:%=$(OUT)/%.xref-map)
166
167
168 ###########
169 ### Targets
170
171 .PHONY: website website-bibs website-css website-examples website-misc \
172         website-pictures website-post website-test website-texinfo \
173         website-version website-xrefs check-setup website-pdf
174
175 check-setup:
176 ifeq ($(LILYPOND_WEB_MEDIA_GIT),)
177         echo "Need a LILYPOND_WEB_MEDIA_GIT environment variable!"
178         exit 1
179 endif
180
181 website: check-setup website-post website-examples website-pictures website-css website-misc website-pdf
182
183 website-bibs: website-version $(OUT) $(bib-files)
184
185 website-css: $(OUT)/website/css $(css-files)
186
187 website-examples: $(OUT)/website/ly-examples $(example-files)
188
189 website-misc: $(OUT)/website $(OUT)/website/misc $(misc-files) $(root-files)
190
191 website-pictures: $(OUT)/website/pictures $(OUT)/pictures $(picture-files)
192
193 website-pdf: $(OUT)/website/pdf $(pdf-files)
194
195 website-post: website-texinfo $(post-files)
196
197 website-test:
198         echo $(TEXI2HTML)
199
200 website-texinfo: website-version website-xrefs website-bibs $(texinfo-files)
201
202 website-version: $(OUT) $(version-files)
203
204 website-xrefs: website-version $(OUT) $(xref-files)
205
206
207 #########
208 ### Rules
209
210 # Directories
211 $(OUT) $(OUT)/website $(OUT)/website/css $(OUT)/website/ly-examples $(OUT)/website/misc $(OUT)/website/pdf $(OUT)/website/pictures: %:
212         mkdir -p $@
213
214 $(OUT)/pictures: $(OUT)/website/pictures
215         ln -sf website/pictures $(OUT)/pictures
216
217 # Generated itexi files
218 $(OUT)/version.itexi: $(top-src-dir)/VERSION
219         $(CREATE_VERSION) $(top-src-dir) > $(OUT)/version.itexi
220
221 $(OUT)/weblinks.itexi: $(top-src-dir)/VERSION
222         $(CREATE_WEBLINKS) $(top-src-dir) > $(OUT)/weblinks.itexi
223
224 $(bib-files): $(OUT)/%.itexi: $(top-src-dir)/Documentation/web/%.bib
225         BSTINPUTS=$(top-src-dir)/Documentation/web \
226                 $(WEB_BIBS) -s web \
227                 -s $(top-src-dir)/Documentation/lily-bib \
228                 -o $@ \
229                 $(quiet-flag) \
230                 $<
231
232 # Get xrefs for English tely manuals
233 $(MANUALS_TELY:%.tely=$(OUT)/%.xref-map): $(OUT)/%.xref-map: $(top-src-dir)/Documentation/%.tely
234         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) $<
235
236 # Get xrefs for English texi manuals
237 $(MANUALS_TEXI:%.texi=$(OUT)/%.xref-map): $(OUT)/%.xref-map: $(top-src-dir)/Documentation/%.texi
238         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) $<
239
240 # Get xrefs for translated tely manuals
241 $(eval $(foreach l,$(WEB_LANGS),\
242 $(eval $(MANUALS_$(l):%.tely=$(OUT)/%.$(l).xref-map): $(OUT)/%.$(l).xref-map: $(top-src-dir)/Documentation/$(l)/%.tely; \
243         $$(DO_TEXI_DEP) $$(EXTRACT_TEXI_FILENAMES) $$< ) \
244 ))
245
246 # Get xrefs for the English web.texi manual
247 $(OUT)/web.xref-map: $(top-src-dir)/Documentation/web.texi
248         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) --split=node $<
249
250 # Get xrefs for translated web.texi manuals
251 $(OUT)/web.%.xref-map: $(top-src-dir)/Documentation/%/web.texi
252         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) --split=node $<
253
254 # Build the English website
255 $(OUT)/index.html: $(top-src-dir)/Documentation/web.texi $(xref-files)
256         $(DO_TEXI_DEP) $(TEXI2HTML) $<
257
258 # Build translated websites
259 $(eval $(foreach l,$(WEB_LANGS),\
260 $(eval $(OUT)/$(l)/index.html: $(top-src-dir)/Documentation/$(l)/web.texi $(xref-files); \
261         $$(DO_TEXI_DEP) $$(TEXI2HTML) --lang="$(l)" $$<; ) \
262 ))
263
264 # Website post-processing
265 $(OUT)/website/index.html: $(wildcard $(OUT)/*.html)
266         ls $(OUT)/*.html | sed 's!$(OUT)/!!g' | xargs $(MASS_LINK) --prepend-suffix="" hard $(OUT)/ $(OUT)/website/
267         $(foreach l,$(WEB_LANGS), \
268                 ls $(OUT)/$(l)/*.html | xargs grep -L 'UNTRANSLATED NODE: IGNORE ME' | sed 's!$(OUT)/$(l)/!!g' | xargs $(MASS_LINK) --prepend-suffix=".$(l)" hard $(OUT)/$(l)/ $(OUT)/website/; )
269         $(WEB_POST) $(OUT)/website
270
271 # Simple copy
272 $(css-files): $(OUT)/website/css/%: $(top-src-dir)/Documentation/css/%
273         cp $< $@
274
275 $(example-files): $(OUT)/website/ly-examples/%: $(EXAMPLES)/%
276         cp $< $@
277
278 $(misc-files): $(OUT)/website/misc/%: $(top-src-dir)/Documentation/misc/%
279         cp $< $@
280
281 $(picture-files): $(OUT)/website/pictures/%: $(PICTURES)/%
282         cp $< $@
283
284 $(pdf-files): $(OUT)/website/pdf/%: $(PDFS)/%
285         cp $< $@
286
287 $(OUT)/website/favicon.ico: $(SERVER_FILES)/favicon.ico
288         cp $< $@
289
290 $(OUT)/website/robots.txt: $(SERVER_FILES)/robots.txt
291         cp $< $@
292
293 $(OUT)/website/tweets.xml: $(SERVER_FILES)/tweets.xml
294         cp $< $@
295
296 $(OUT)/.htaccess: $(top-htaccess)
297         cp $< $@
298
299 $(OUT)/website/.htaccess: $(dir-htaccess)
300         cp $< $@