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