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