]> git.donarmstrong.com Git - lilypond.git/blob - make/website.make
Add '-dcrop' option to ps and svg backends
[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 BIB_ITEXI=$(LILYPOND_WEB_MEDIA_GIT)/bib-itexi
81
82 SERVER_FILES=$(top-src-dir)/Documentation/web/server
83
84 # don't include web
85 MANUALS = $(MANUALS_TELY) $(MANUALS_TEXI) $(MANUALS_TRANSLATION)
86 MANUALS_TELY := $(notdir $(wildcard $(top-src-dir)/Documentation/*.tely))
87 MANUALS_TEXI := contributor.texi
88
89 # Harvest the translated manuals.
90 #   - Store each manual in a language-specific macro, e.g. when we find
91 #     de/learning.tely we add learning.tely to MANUALS_de,
92 #   - Store each manual with an added language suffix in MANUALS_TRANSLATION,
93 #     e.g. learning.de.tely for the German learning manual.
94 $(eval $(foreach l,$(WEB_LANGS),\
95         $(eval MANUALS_$(l) := $(notdir $(wildcard $(top-src-dir)/Documentation/$(l)/*.tely))) \
96         $(eval MANUALS_TRANSLATION += $(MANUALS_$(l):%.tely=%.$(l).tely)) \
97 ))
98
99 # The web.texi manuals, English and translated
100 MANUALS_WEB := web.texi $(WEB_LANGS:%=web.%.texi)
101
102 # The basename of all manuals (basename includes the language suffix)
103 MANUALS_BASE = $(basename $(MANUALS) $(MANUALS_WEB))
104
105
106 #######################
107 ### Dependency tracking
108
109 # Find the file $(1) within the texinfo include dirs and return its path.
110 # If not found, i.e. it is a generated file, then the file is ignored.
111 find-texi = \
112 $(firstword \
113         $(wildcard $(dir $<)$(1)) \
114         $(wildcard $(top-src-dir)/Documentation/$(1)) \
115 )
116
117 # Recursively scan the file $(1) for @include, search for included files
118 # within the texinfo include dirs, and return all dependencies.
119 scan-texi = \
120         $(foreach f, $(shell echo | sed -ne "/^@include[[:space:]]/s/@include//p" $(1)), \
121         $(call find-texi,$(f)) \
122         $(call scan-texi,$(call find-texi,$(f))) \
123 )
124
125 # Find dependencies for the target $@, based on the texinfo source file $<,
126 # and write the dependencies to a .dep file.
127 DO_TEXI_DEP = ( mkdir -p $(dir $@) && echo ./$@: $(call scan-texi,$<) > $@.dep ) &&
128
129 # This is where we import the .dep files so that `make' knows about
130 # the various dependencies.
131 -include dummy.dep $(wildcard $(OUT)/*.dep) $(wildcard $(OUT)/*/*.dep)
132
133
134 ###################
135 ### Generated files
136
137 bib-itexi-src-files := $(notdir $(wildcard $(BIB_ITEXI)/*.itexi))
138 bib-itexi-files = $(bib-itexi-src-files:%=$(OUT)/%)
139
140 css-src-files := $(notdir $(wildcard $(top-src-dir)/Documentation/css/*.css))
141 css-files = $(css-src-files:%=$(OUT)/website/css/%)
142
143 example-src-files := $(notdir $(wildcard $(EXAMPLES)/*))
144 example-files = $(example-src-files:%=$(OUT)/website/ly-examples/%)
145
146 misc-src-files := $(notdir $(wildcard $(top-src-dir)/Documentation/misc/*.*))
147 misc-files += $(misc-src-files:%=$(OUT)/website/misc/%)
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 root-files = $(OUT)/.htaccess \
158              $(OUT)/website/.htaccess \
159              $(OUT)/website/favicon.ico \
160              $(OUT)/website/tweets.xml \
161              $(OUT)/website/robots.txt
162
163 texinfo-files = $(OUT)/index.html $(WEB_LANGS:%=$(OUT)/%/index.html)
164
165 version-files = $(OUT)/version.itexi $(OUT)/weblinks.itexi
166
167 xref-files = $(MANUALS_BASE:%=$(OUT)/%.xref-map)
168
169
170 ###########
171 ### Targets
172
173 .PHONY: website website-bibs website-css website-examples website-misc \
174         website-pictures website-post website-test website-texinfo \
175         website-version website-xrefs check-setup website-pdf
176
177 check-setup:
178 ifeq ($(LILYPOND_WEB_MEDIA_GIT),)
179         echo "Need a LILYPOND_WEB_MEDIA_GIT environment variable!"
180         exit 1
181 endif
182
183 website: check-setup website-post website-examples website-pictures website-css website-misc website-pdf
184
185 website-bibs: website-version $(OUT) $(bib-itexi-files)
186
187 website-css: $(OUT)/website/css $(css-files)
188
189 website-examples: $(OUT)/website/ly-examples $(example-files)
190
191 website-misc: $(OUT)/website $(OUT)/website/misc $(misc-files) $(root-files)
192
193 website-pictures: $(OUT)/website/pictures $(OUT)/pictures $(picture-files)
194
195 website-pdf: $(OUT)/website/pdf $(pdf-files)
196
197 website-post: website-texinfo $(post-files)
198
199 website-test:
200         echo $(TEXI2HTML)
201
202 website-texinfo: website-version website-xrefs website-bibs $(texinfo-files)
203
204 website-version: $(OUT) $(version-files)
205
206 website-xrefs: website-version $(OUT) $(xref-files)
207
208
209 #########
210 ### Rules
211
212 # Directories
213 $(OUT) $(OUT)/website $(OUT)/website/css $(OUT)/website/ly-examples $(OUT)/website/misc $(OUT)/website/pdf $(OUT)/website/pictures: %:
214         mkdir -p $@
215
216 $(OUT)/pictures: $(OUT)/website/pictures
217         ln -sf website/pictures $(OUT)/pictures
218
219 # Generated itexi files
220 $(OUT)/version.itexi: $(top-src-dir)/VERSION
221         $(CREATE_VERSION) $(top-src-dir) > $(OUT)/version.itexi
222
223 $(OUT)/weblinks.itexi: $(top-src-dir)/VERSION
224         $(CREATE_WEBLINKS) $(top-src-dir) > $(OUT)/weblinks.itexi
225
226 # Get xrefs for English tely manuals
227 $(MANUALS_TELY:%.tely=$(OUT)/%.xref-map): $(OUT)/%.xref-map: $(top-src-dir)/Documentation/%.tely
228         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) $<
229
230 # Get xrefs for English texi manuals
231 $(MANUALS_TEXI:%.texi=$(OUT)/%.xref-map): $(OUT)/%.xref-map: $(top-src-dir)/Documentation/%.texi
232         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) $<
233
234 # Get xrefs for translated tely manuals
235 $(eval $(foreach l,$(WEB_LANGS),\
236 $(eval $(MANUALS_$(l):%.tely=$(OUT)/%.$(l).xref-map): $(OUT)/%.$(l).xref-map: $(top-src-dir)/Documentation/$(l)/%.tely; \
237         $$(DO_TEXI_DEP) $$(EXTRACT_TEXI_FILENAMES) $$< ) \
238 ))
239
240 # Get xrefs for the English web.texi manual
241 $(OUT)/web.xref-map: $(top-src-dir)/Documentation/web.texi
242         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) --split=node $<
243
244 # Get xrefs for translated web.texi manuals
245 $(OUT)/web.%.xref-map: $(top-src-dir)/Documentation/%/web.texi
246         $(DO_TEXI_DEP) $(EXTRACT_TEXI_FILENAMES) --split=node $<
247
248 # Build the English website
249 $(OUT)/index.html: $(top-src-dir)/Documentation/web.texi $(version-files) $(xref-files)
250         $(DO_TEXI_DEP) $(TEXI2HTML) $<
251
252 # Build translated websites
253 $(eval $(foreach l,$(WEB_LANGS),\
254 $(eval $(OUT)/$(l)/index.html: $(top-src-dir)/Documentation/$(l)/web.texi $(version-files) $(xref-files); \
255         $$(DO_TEXI_DEP) $$(TEXI2HTML) --lang="$(l)" $$<; ) \
256 ))
257
258 # Website post-processing
259 $(OUT)/website/index.html: $(wildcard $(OUT)/*.html)
260         ls $(OUT)/*.html | sed 's!$(OUT)/!!g' | xargs $(MASS_LINK) --prepend-suffix="" hard $(OUT)/ $(OUT)/website/
261         $(foreach l,$(WEB_LANGS), \
262                 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/; )
263         $(WEB_POST) $(OUT)/website
264
265 # Simple copy
266 $(bib-itexi-files): $(OUT)/%: $(BIB_ITEXI)/%
267         cp $< $@
268
269 $(css-files): $(OUT)/website/css/%: $(top-src-dir)/Documentation/css/%
270         cp $< $@
271
272 $(example-files): $(OUT)/website/ly-examples/%: $(EXAMPLES)/%
273         cp $< $@
274
275 $(misc-files): $(OUT)/website/misc/%: $(top-src-dir)/Documentation/misc/%
276         cp $< $@
277
278 $(picture-files): $(OUT)/website/pictures/%: $(PICTURES)/%
279         cp $< $@
280
281 $(pdf-files): $(OUT)/website/pdf/%: $(PDFS)/%
282         cp $< $@
283
284 $(OUT)/website/favicon.ico: $(SERVER_FILES)/favicon.ico
285         cp $< $@
286
287 $(OUT)/website/robots.txt: $(SERVER_FILES)/robots.txt
288         cp $< $@
289
290 $(OUT)/website/tweets.xml: $(SERVER_FILES)/tweets.xml
291         cp $< $@
292
293 $(OUT)/.htaccess: $(top-htaccess)
294         cp $< $@
295
296 $(OUT)/website/.htaccess: $(dir-htaccess)
297         cp $< $@