]> git.donarmstrong.com Git - lilypond.git/blob - make/website.make
Web-es: Really make Spanish Pondings work.
[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/tweets-es.xml \
160              $(OUT)/website/robots.txt
161
162 texinfo-files = $(OUT)/index.html $(WEB_LANGS:%=$(OUT)/%/index.html)
163
164 version-files = $(OUT)/version.itexi $(OUT)/weblinks.itexi
165
166 xref-files = $(MANUALS_BASE:%=$(OUT)/%.xref-map)
167
168
169 ###########
170 ### Targets
171
172 .PHONY: website website-bibs website-css website-examples website-misc \
173         website-pictures website-post website-test website-texinfo \
174         website-version website-xrefs check-setup website-pdf
175
176 check-setup:
177 ifeq ($(LILYPOND_WEB_MEDIA_GIT),)
178         echo "Need a LILYPOND_WEB_MEDIA_GIT environment variable!"
179         exit 1
180 endif
181
182 website: check-setup website-post website-examples website-pictures website-css website-misc website-pdf
183
184 website-bibs: website-version $(OUT) $(bib-files)
185
186 website-css: $(OUT)/website/css $(css-files)
187
188 website-examples: $(OUT)/website/ly-examples $(example-files)
189
190 website-misc: $(OUT)/website $(OUT)/website/misc $(misc-files) $(root-files)
191
192 website-pictures: $(OUT)/website/pictures $(OUT)/pictures $(picture-files)
193
194 website-pdf: $(OUT)/website/pdf $(pdf-files)
195
196 website-post: website-texinfo $(post-files)
197
198 website-test:
199         echo $(TEXI2HTML)
200
201 website-texinfo: website-version website-xrefs website-bibs $(texinfo-files)
202
203 website-version: $(OUT) $(version-files)
204
205 website-xrefs: website-version $(OUT) $(xref-files)
206
207
208 #########
209 ### Rules
210
211 # Directories
212 $(OUT) $(OUT)/website $(OUT)/website/css $(OUT)/website/ly-examples $(OUT)/website/misc $(OUT)/website/pdf $(OUT)/website/pictures: %:
213         mkdir -p $@
214
215 $(OUT)/pictures: $(OUT)/website/pictures
216         ln -sf website/pictures $(OUT)/pictures
217
218 # Generated itexi files
219 $(OUT)/version.itexi: $(top-src-dir)/VERSION
220         $(CREATE_VERSION) $(top-src-dir) > $(OUT)/version.itexi
221
222 $(OUT)/weblinks.itexi: $(top-src-dir)/VERSION
223         $(CREATE_WEBLINKS) $(top-src-dir) > $(OUT)/weblinks.itexi
224
225 $(bib-files): $(OUT)/%.itexi: $(top-src-dir)/Documentation/web/%.bib
226         BSTINPUTS=$(top-src-dir)/Documentation/web \
227                 $(WEB_BIBS) -s web \
228                 -s $(top-src-dir)/Documentation/lily-bib \
229                 -o $@ \
230                 $(quiet-flag) \
231                 $<
232
233 # Get xrefs for English tely manuals
234 $(MANUALS_TELY:%.tely=$(OUT)/%.xref-map): $(OUT)/%.xref-map: $(top-src-dir)/Documentation/%.tely
235         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) $<
236
237 # Get xrefs for English texi manuals
238 $(MANUALS_TEXI:%.texi=$(OUT)/%.xref-map): $(OUT)/%.xref-map: $(top-src-dir)/Documentation/%.texi
239         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) $<
240
241 # Get xrefs for translated tely manuals
242 $(eval $(foreach l,$(WEB_LANGS),\
243 $(eval $(MANUALS_$(l):%.tely=$(OUT)/%.$(l).xref-map): $(OUT)/%.$(l).xref-map: $(top-src-dir)/Documentation/$(l)/%.tely; \
244         $$(DO_TEXI_DEP) $$(EXTRACT_TEXI_FILENAMES) $$< ) \
245 ))
246
247 # Get xrefs for the English web.texi manual
248 $(OUT)/web.xref-map: $(top-src-dir)/Documentation/web.texi
249         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) --split=node $<
250
251 # Get xrefs for translated web.texi manuals
252 $(OUT)/web.%.xref-map: $(top-src-dir)/Documentation/%/web.texi
253         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) --split=node $<
254
255 # Build the English website
256 $(OUT)/index.html: $(top-src-dir)/Documentation/web.texi $(xref-files)
257         $(DO_TEXI_DEP) $(TEXI2HTML) $<
258
259 # Build translated websites
260 $(eval $(foreach l,$(WEB_LANGS),\
261 $(eval $(OUT)/$(l)/index.html: $(top-src-dir)/Documentation/$(l)/web.texi $(xref-files); \
262         $$(DO_TEXI_DEP) $$(TEXI2HTML) --lang="$(l)" $$<; ) \
263 ))
264
265 # Website post-processing
266 $(OUT)/website/index.html: $(wildcard $(OUT)/*.html)
267         ls $(OUT)/*.html | sed 's!$(OUT)/!!g' | xargs $(MASS_LINK) --prepend-suffix="" hard $(OUT)/ $(OUT)/website/
268         $(foreach l,$(WEB_LANGS), \
269                 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/; )
270         $(WEB_POST) $(OUT)/website
271
272 # Simple copy
273 $(css-files): $(OUT)/website/css/%: $(top-src-dir)/Documentation/css/%
274         cp $< $@
275
276 $(example-files): $(OUT)/website/ly-examples/%: $(EXAMPLES)/%
277         cp $< $@
278
279 $(misc-files): $(OUT)/website/misc/%: $(top-src-dir)/Documentation/misc/%
280         cp $< $@
281
282 $(picture-files): $(OUT)/website/pictures/%: $(PICTURES)/%
283         cp $< $@
284
285 $(pdf-files): $(OUT)/website/pdf/%: $(PDFS)/%
286         cp $< $@
287
288 $(OUT)/website/favicon.ico: $(SERVER_FILES)/favicon.ico
289         cp $< $@
290
291 $(OUT)/website/robots.txt: $(SERVER_FILES)/robots.txt
292         cp $< $@
293
294 $(OUT)/website/tweets.xml: $(SERVER_FILES)/tweets.xml
295         cp $< $@
296
297 $(OUT)/website/tweets-es.xml: $(SERVER_FILES)/tweets-es.xml
298         cp $< $@
299
300 $(OUT)/.htaccess: $(top-htaccess)
301         cp $< $@
302
303 $(OUT)/website/.htaccess: $(dir-htaccess)
304         cp $< $@