]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/contributor/build-notes.itexi
DOC -- Contributor: Add notes on make doc
[lilypond.git] / Documentation / contributor / build-notes.itexi
1 @c -*- coding: utf-8; mode: texinfo; -*-
2
3
4 @node Build system notes
5 @chapter Build system notes
6
7 @warning{This chapter is in high flux, and is being run in a
8 @qq{wiki-like} fashion.  Do not trust anything you read in this
9 chapter.}
10
11 @menu
12 * Build system overview::
13 * Tips for working on the build system::
14 * General build system notes::
15 * Doc build::
16 * Website build::
17 * Building an Ubuntu distro::
18 @end menu
19
20
21 @node Build system overview
22 @section Build system overview
23
24 Build system is currently GNU make, with an extra "stepmake" layer
25 on top.  Look at files in @file{make/} and @file{stepmake/} and
26 all @file{GNUmakefile}s.
27
28 There is wide-spread dissatisfaction with this system, and we are
29 considering changing.  This would be a huge undertaking (estimated
30 200+ hours).  This change will probably involve not using GNU make
31 any more -- but a discussion about the precise build system will
32 have to wait.  Before we reach that point, we need to figure out
33 (at least approximately) what the current build system does.
34
35 Fundamentally, a build system does two things:
36
37 @enumerate
38 @item
39 Constructs command-line commands, for example:
40
41 @example
42 lilypond-book \
43   --tons --of --options \
44   pitches.itely
45 texi2pdf \
46   --more --imperial --and --metric --tons --of --options \
47   pitches.texi
48 @end example
49
50 @item
51 If there was a previous build, it decides which parts of the
52 system need to be rebuilt.
53
54 @end enumerate
55
56 When I try to do anything in the build system, it helps to remind
57 myself of this.  The "end result" is just a series of command-line
58 commands.  All the black magick is just an attempt to construct
59 those commands.
60
61 @node Tips for working on the build system
62 @section Tips for working on the build system
63
64 @itemize
65 @item
66 Add:
67
68 @example
69 echo "aaa"
70
71 echo "bbb"
72 @end example
73
74 to the build system files in various places.  This will let you
75 track where the program is, in various points of the build.
76
77 PH note.  There are lots of places where Make doesn't let you put
78 echo commands.  My top tip for tracing how make runs is to put
79
80 @example
81 $(error Some Text to display)
82 @end example
83
84 This will stop make running and print the text @code{Some Text to
85 display}.
86
87 End PH note.
88
89 @item
90 First task: understand how @code{make website} works,
91 @emph{without} the translations.  Looking at the english-only
92 website is the best introduction to the build system... it only
93 covers about 5% of the whole thing, but even that will likely take
94 10 hours or more.
95
96 @end itemize
97
98
99 @node General build system notes
100 @section General build system notes
101
102 @menu
103 * How stepmake works::
104 @end menu
105
106 @node How stepmake works
107 @subsection How stepmake works
108
109 Typing make website runs the file @file{GNUmakefile} from the
110 build directory.  This only contains 3 lines:
111
112 @example
113 depth = .
114 include config$(if $(conf),-$(conf),).make
115 include $(configure-srcdir)/GNUmakefile.in
116 @end example
117
118 The variable @code{depth} is used throughout the make system to
119 track how far down the directory structure the make is.  The first
120 include sets lots of variables but doesn't "do" anything.  The
121 second runs the file @file{GNUmakefile.in} from the top level
122 source directory.
123
124 This sets another load of variables, and then includes (i.e.
125 immediately runs) @file{stepmake.make} from the @file{make}
126 subdirectory.  This sets a load of other variables, does some
127 testing to see if SCONS (another build tool?) is being used, and
128 then runs @file{make/config.make} - which doesn't seem to exist...
129
130 GP: scons is indeed a different build tool; I think that Jan
131 experimented with it 5 years ago or something.  It seems like we
132 still have bits and pieces of it floating around.
133
134 Next, it runs @file{make/toplevel-version.make}, which sets the
135 version variables for major, minor, patch, stable, development and
136 mypatchlevel (which seems to be used for patch numbers for
137 non-stable versions only?).
138
139 Next - @file{make/local.make}, which doesn't exist.
140
141 Then a few more variable and the interesting comment:
142
143 @example
144 # Don't try to outsmart us, you puny computer!
145 # Well, UGH.  This only removes builtin rules from
146 @end example
147
148 and then tests to see whether BUILTINS_REMOVED is defined.  It
149 appears to be when I run make, and so
150 @file{stepmake/stepmake/no-builtin-rules.make} is run.  The
151 comment at the head of this file says:
152
153 @example
154 # UGH.  GNU make comes with implicit rules.
155 # We don't want any of them, and can't force users to run
156 # --no-builtin-rules
157 @end example
158
159 I've not studied that file at length, but assume it removes all
160 make's build-in rules (e.g. @file{*.c} files are run through the
161 GNU C compiler) - there's a lot of them in here, and a lot of
162 comments, and I'd guess most of it isn't needed.
163
164 We return to @file{stepmake.make}, where we hit the make rule all:
165 The first line of this is:
166
167 @example
168 -include $(addprefix $(depth)/make/,$(addsuffix -inclusions.make, $(LOCALSTEPMAKE_TEMPLATES)))
169 @end example
170
171 which, when the variables are substituted, gives:
172
173 @example
174 ./make/generic-inclusions.make
175 ./make/lilypond-inclusions.make.
176 @end example
177
178 (Note - according to the make documentation, -include is only
179 different from include in that it doesn't produce any kind of
180 error message when the included file doesn't exist).
181
182 And the first file doesn't exist.  Nor the second.  Next:
183
184 @example
185 -include $(addprefix $(stepdir)/,$(addsuffix -inclusions.make, $(STEPMAKE_TEMPLATES)))
186 @end example
187
188 which expands to the following files:
189
190 @example
191 /home/phil/lilypond-git/stepmake/stepmake/generic-inclusions.make
192 /home/phil/lilypond-git/stepmake/stepmake/toplevel-inclusions.make
193 /home/phil/lilypond-git/stepmake/stepmake/po-inclusions.make
194 /home/phil/lilypond-git/stepmake/stepmake/install-inclusions.make.
195 @end example
196
197 One little feature to notice here - these are all absolute file
198 locations - the line prior to this used relative locations.  And
199 none of these files exist, either.  (Further note - I'm assuming
200 all these lines of make I'm following are autogenerated, but
201 that'll be something else to discover.)
202
203 Next in @file{stepmake.make}:
204
205 @example
206 include $(addprefix $(stepdir)/,$(addsuffix -vars.make, $(STEPMAKE_TEMPLATES)))
207 @end example
208
209 which expands to:
210
211 @example
212 /home/phil/lilypond-git/stepmake/stepmake/generic-vars.make
213 /home/phil/lilypond-git/stepmake/stepmake/toplevel-vars.make
214 /home/phil/lilypond-git/stepmake/stepmake/po-vars.make
215 /home/phil/lilypond-git/stepmake/stepmake/install-vars.make.
216 @end example
217
218 Woo.  They all exist (they should as there's no - in front of the
219 include).  @file{generic-vars.make} sets loads of variables
220 (funnily enough).  @file{toplevel-vars.make} is very short - one
221 line commented as @code{# override Generic_vars.make:} and 2 as
222 follows:
223
224 @example
225 # urg?
226 include $(stepdir)/documentation-vars.make
227 @end example
228
229 I assume the urg comment refers to the fact that this should
230 really just create more variables, but it actually sends us off to
231 @file{/home/phil/lilypond-git/stepmake/stepmake/documentation-vars.make}.
232
233 That file is a 3 line variable setting one.
234
235 @file{po-vars.make} has the one-line comment @code{# empty}, as
236 does @file{install-vars.make}.
237
238 So now we're back to @file{stepmake.make}.
239
240 The next lines are
241 :
242 @example
243 # ugh. need to do this because of PATH :=$(top-src-dir)/..:$(PATH)
244 include $(addprefix $(depth)/make/,$(addsuffix -vars.make, $(LOCALSTEPMAKE_TEMPLATES)))
245 @end example
246
247 and the include expands to:
248
249 @example
250 include ./make/generic-vars.make ./make/lilypond-vars.make.
251 @end example
252
253 These again set variables, and in some cases export them to allow
254 child @code{make} processes to use them.
255
256 The final 4 lines of @file{stepmake.make} are:
257
258 @example
259 include $(addprefix $(depth)/make/,$(addsuffix -rules.make, $(LOCALSTEPMAKE_TEMPLATES)))
260 include $(addprefix $(stepdir)/,$(addsuffix -rules.make, $(STEPMAKE_TEMPLATES)))
261 include $(addprefix $(depth)/make/,$(addsuffix -targets.make, $(LOCALSTEPMAKE_TEMPLATES)))
262 include $(addprefix $(stepdir)/,$(addsuffix -targets.make, $(STEPMAKE_TEMPLATES)))
263 @end example
264
265 which expand as follows:
266
267 @example
268 include ./make/generic-rules.make ./make/lilypond-rules.make
269 include
270   /home/phil/lilypond-git/stepmake/stepmake/generic-rules.make
271   /home/phil/lilypond-git/stepmake/stepmake/toplevel-rules.make
272   /home/phil/lilypond-git/stepmake/stepmake/po-rules.make
273   /home/phil/lilypond-git/stepmake/stepmake/install-rules.make
274 include ./make/generic-targets.make ./make/lilypond-targets.make
275 include
276   /home/phil/lilypond-git/stepmake/stepmake/generic-targets.make
277   /home/phil/lilypond-git/stepmake/stepmake/toplevel-targets.make
278   /home/phil/lilypond-git/stepmake/stepmake/po-targets.make
279   /home/phil/lilypond-git/stepmake/stepmake/install-targets.make
280 @end example
281
282 @file{lilypond-rules.make} is @code{#empty}
283
284 @file{generic-rules.make} does seem to have 2 rules in it.  They
285 are:
286
287 @example
288 $(outdir)/%.ly: %.lym4
289         $(M4) $< | sed "s/\`/,/g" > $@
290
291 $(outdir)/%: %.in
292         rm -f $@
293         cat $< | sed $(sed-atfiles) | sed $(sed-atvariables) > $@
294 @end example
295
296 I believe the first rule is for *.ly files, and has a prerequisite
297 that *.lym4 files must be built first.  The recipe is @code{m4  |
298 sed "s/\`/,/g" >}.  Perhaps someone with more Unix/make knowledge
299 can comment on exactly what the rules mean/do.
300
301 @file{toplevel-rules.make} is @code{#empty}
302
303 @file{po-rules.make} is @code{#empty}
304
305 @file{install-rules.make} is @code{#empty}
306
307 @file{generic-targets.make} contains 2 lines of comments.
308
309 @file{lilypond-targets.make} contains only:
310
311 @example
312 ## TODO: fail dist or web if no \version present.
313 check-version:
314         grep -L version $(LY_FILES)
315 @end example
316
317 @file{stepmake/generic-targets.make} contains lots of rules - too
318 many to list here - it seems to be the main file for rules. (FWIW
319 I haven't actually found a rule for website: anywhere, although
320 it clearly exists.  I have also found that you can display a rule
321 in the terminal by typing, say @code{make -n website}.  This is
322 probably common knowledge.
323
324 @file{stepmake/toplevel-targets.make} adds a load of other (and
325 occasionally the same) rules to the gernric-targets.
326
327 @file{stepmake/po-targets.make} is rules for po* makes.
328
329 @file{stepmake/install-targets.make} has rules for local-install*.
330
331 And that's the end of stepmake.make.  Back to
332 @file{GNUmakefile.in}.
333
334 A bit more info from 27 March.  I've put some error traces into
335 @code{GNUmakefile} in the build directory, and it looks like the
336 following lines actually cause the make to run (putting an error
337 call above them - no make; below them - make):
338
339 @example
340 ifeq ($(out),www)
341 # All web targets, except info image symlinks and info docs are
342 # installed in non-recursing target from TOP-SRC-DIR
343 install-WWW:
344         -$(INSTALL) -m 755 -d $(DESTDIR)$(webdir)
345         rsync -rl --exclude='*.signature' $(outdir)/offline-root $(DESTDIR)$(webdir)
346         $(MAKE) -C Documentation omf-local-install
347 @end example
348
349 I don't currently understand the @code{ifeq}, since @code{$(out)}
350 is empty at this point, but the line starting @code{-$(INSTALL)}
351 translates to:
352
353 @example
354 -/usr/bin/python /home/phil/lilypond-git/stepmake/bin/install.py -c -m 755 -d /usr/local/share/doc/lilypond/html
355 @end example
356
357 End of work for Sunday 27th.
358
359 Another alterative approach to understanding the website build
360 would be to redirect @code{make -n website} and @code{make website}
361 to a text file and work through a) what it does and b) where the
362 errors are occurring.
363
364 GP: wow, all the above is much more complicated than I've ever
365 looked at stuff -- I tend to do a "back first" approach (where I
366 begin from the command-line that I want to modify, figure out
367 where it's generated, and then figure out how to change the
368 generated command-line), rather than a "front first" (where you
369 begin from the "make" command).
370
371
372 @node Doc build
373 @section Doc build
374
375 @menu
376 * The function of make doc::
377 * Building a bibliography::
378 @end menu
379
380 @node The function of make doc
381 @subsection The function of make doc
382
383 The following is a set of notes on how make doc functions.
384
385 Preliminary question to be answered some time: where do all the
386 GNUmakefiles come from.  They're in the build directory, but this
387 is not part of source.  Must be the configure script.  And it
388 looks like this comes from autogen.sh.  Must at some point kill
389 the whole git directory, repull and see what is created when.
390
391 Anyway, here's how make doc progresses:
392
393 This is the build dependency tree from
394 @file{stepmake/stepmake/generic-targets.make}:
395
396 @example
397 doc: doc-stage-1
398   doc-stage-1:
399         $(MAKE) -C $(depth)/scripts/build out=
400         $(MAKE) out=www WWW-1
401           WWW-1: local-WWW-1
402         $(LOOP)
403           $(MAKE) out=www WWW-2
404           WWW-2: local-WWW-2
405             $(LOOP)
406           $(MAKE) out=www WWW-post
407 @end example
408
409 @example
410 MAKE = make --no-builtin-rules
411 -C = Change to directory before make
412 @end example
413
414 doc-stage-1 does lots of opening and looking in files, but no
415 processing.
416
417 @example
418 Variable LOOP =
419
420 + make PACKAGE=LILYPOND package=lilypond -C python
421 && make PACKAGE=LILYPOND package=lilypond -C scripts
422 &&  make PACKAGE=LILYPOND package=lilypond -C flower
423 &&  make PACKAGE=LILYPOND package=lilypond -C lily
424 &&  make PACKAGE=LILYPOND package=lilypond -C mf
425 &&  make PACKAGE=LILYPOND package=lilypond -C ly
426 &&  make PACKAGE=LILYPOND package=lilypond -C tex
427 &&  make PACKAGE=LILYPOND package=lilypond -C ps
428 &&  make PACKAGE=LILYPOND package=lilypond -C scm
429 &&  make PACKAGE=LILYPOND package=lilypond -C po
430 &&  make PACKAGE=LILYPOND package=lilypond -C make
431 &&  make PACKAGE=LILYPOND package=lilypond -C elisp
432 &&  make PACKAGE=LILYPOND package=lilypond -C vim
433 &&  make PACKAGE=LILYPOND package=lilypond -C input
434 &&  make PACKAGE=LILYPOND package=lilypond -C stepmake
435 &&  make PACKAGE=LILYPOND package=lilypond -C Documentation
436 && true
437 @end example
438
439 From git grep:
440
441 stepmake/stepmake/generic-vars.make has this:
442
443 @example
444 LOOP=+$(foreach i, $(SUBDIRS), $(MAKE) PACKAGE=$(PACKAGE) package=$(package) -C $(i) $@ &&) true
445 @end example
446
447 $@ is the name of the target - WWW-1 in this case.
448
449 In GNUmakefile.in we find:
450
451 @example
452 SUBDIRS = python scripts \
453         flower lily \
454         mf ly \
455         tex ps scm \
456         po make \
457         elisp vim \
458         input \
459         stepmake $(documentation-dir)
460 @end example
461
462 So that's how we get the main make loop...
463
464 That loop expands like this:
465
466 @example
467 make PACKAGE=LILYPOND package=lilypond -C python WWW-1 &&
468 make PACKAGE=LILYPOND package=lilypond -C scripts WWW-1 &&
469 make PACKAGE=LILYPOND package=lilypond -C flower WWW-1 &&
470 make PACKAGE=LILYPOND package=lilypond -C lily WWW-1 &&
471 make PACKAGE=LILYPOND package=lilypond -C mf WWW-1 &&
472 make PACKAGE=LILYPOND package=lilypond -C ly WWW-1 &&
473 make PACKAGE=LILYPOND package=lilypond -C tex WWW-1 &&
474 make PACKAGE=LILYPOND package=lilypond -C ps WWW-1 &&
475 make PACKAGE=LILYPOND package=lilypond -C scm WWW-1 &&
476 make PACKAGE=LILYPOND package=lilypond -C po WWW-1 &&
477 make PACKAGE=LILYPOND package=lilypond -C make WWW-1 &&
478 make PACKAGE=LILYPOND package=lilypond -C elisp WWW-1 &&
479 make PACKAGE=LILYPOND package=lilypond -C vim WWW-1 &&
480 make PACKAGE=LILYPOND package=lilypond -C input WWW-1 &&
481 make PACKAGE=LILYPOND package=lilypond -C stepmake WWW-1 &&
482 make PACKAGE=LILYPOND package=lilypond -C Documentation WWW-1 &&
483 true
484 @end example
485
486 The directories up to and including vim produce no effect with
487 make in non-debug mode, although debug does show lots of action.
488
489 @file{git/build/input/GNUmakefile} is:
490
491 @example
492 depth=../
493 include $(depth)/config$(if $(conf),-$(conf),).make
494 include $(configure-srcdir)/./input/GNUmakefile
495 MODULE_INCLUDES += $(src-dir)/$(outbase)
496 @end example
497
498 The first include is:
499
500 @example
501 ..//config.make
502 @end example
503
504 (note the // which is strictly wrong)
505
506 which has lots of variables to set, but no action occurs.
507
508 The second is:
509
510 @example
511 lilypond-git/./input/GNUmakefile
512 @end example
513
514 which similarly doesn't create any actual action.
515
516 An error message at the end of build/input/GNUmakefile stops
517 make processing before it moves on to regression - so where does
518 that come from?
519
520 And the answer is - make processes all directories in the
521 directory it's entered (with some exceptions like out and out-www)
522 and so it changes to /regression.
523
524 It then seems to consider whether it needs to make/remake loads of
525 makefiles.  Don't understand this yet.  Possibly these are all the
526 makefiles it's processing, and it always checks they're up to date
527 before processing other files?
528
529 Could be correct - some of this output is:
530
531 @example
532 Must remake target `../../make/ly-inclusions.make'.
533 Failed to remake target file `../../make/ly-inclusions.make'.
534 @end example
535
536 Having decided that, it then leaves the directory and re-executes:
537
538 @example
539 make PACKAGE=LILYPOND package=lilypond -C regression WWW-1
540 @end example
541
542 The top of this make is:
543
544 @example
545 This program built for i486-pc-linux-gnu
546 Reading makefiles...
547 Reading makefile `GNUmakefile'...
548 Reading makefile `../..//config.make' (search path) (no ~ expansion)...
549 @end example
550
551 which looks like it's re-reading all its known makefiles to check
552 they're up to date.
553
554 (From the make manual:
555
556 To this end, after reading in all makefiles, make will consider each as a goal target and
557 attempt to update it. If a makefile has a rule which says how to update it (found either
558 in that very makefile or in another one) or if an implicit rule applies to it (see Chapter 10
559 [Using Implicit Rules], page 103), it will be updated if necessary. After all makefiles have
560 been checked, if any have actually been changed, make starts with a clean slate and reads
561 all the makefiles over again. (It will also attempt to update each of them over again, but
562 normally this will not change them again, since they are already up to date.)
563
564 So my assumption seems correct)
565
566 There appear to be about 74 of them.  After all the makefile
567 checking, we get this:
568
569 @example
570 Updating goal targets....
571 Considering target file `WWW-1'.
572  File `WWW-1' does not exist.
573   Considering target file `local-WWW-1'.
574    File `local-WWW-1' does not exist.
575     Considering target file `out-www/collated-files.texi'.
576      File `out-www/collated-files.texi' does not exist.
577      Looking for an implicit rule for `out-www/collated-files.texi'.
578      Trying pattern rule with stem `collated-files.texi'.
579      Trying implicit prerequisite `collated-files.texi.in'.
580      Trying pattern rule with stem `collated-files.texi'.
581      Trying implicit prerequisite `collated-files.texi.in'.
582      Trying pattern rule with stem `collated-files'.
583      Trying implicit prerequisite `collated-files.tely'.
584      Trying pattern rule with stem `collated-files'.
585      Trying implicit prerequisite `out-www/collated-files.tely'.
586      Trying rule prerequisite `out-www/version.itexi'.
587      Found prerequisite `out-www/version.itexi' as VPATH `/home/phil/lilypond-git/input/regression/out-www/version.itexi'
588 @end example
589
590 grep finds this if searching for local-WWW-1:
591
592 @example
593 make/lysdoc-targets.make:
594   local-WWW-1: $(outdir)/collated-files.texi $(outdir)/collated-files.pdf
595 @end example
596
597 which means that local-WWW-1 depends on coll*.texi and coll*.pdf
598 and so these will need to be checked to see if they're up to date.
599 So make needs to find rules for both of those and (as it says) it
600 certainly needs to make coll*.texi, since it doesn't exist.
601
602 In ly-rules.make we have:
603
604 @example
605 .SUFFIXES: .doc .tely .texi .ly
606 @end example
607
608 which I'll work out at some point, and also this rule:
609
610 @example
611 $(outdir)/%.texi: $(outdir)/%.tely $(outdir)/version.itexi $(DOCUMENTATION_LOCALE_TARGET) $(INIT_LY_SOURCES) $(SCHEME_SOURCES)
612         LILYPOND_VERSION=$(TOPLEVEL_VERSION) $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS) $(LILYPOND_BOOK_INCLUDES) $(LILYPOND_BOOK_LILYPOND_FLAGS)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS) $<
613 @end example
614
615 Note that the recipe is a very long line - it could probably
616 benefit from splitting.  The same makefile also has:
617
618 @example
619 $(outdir)/%.texi: $(outdir)/%.tely $(outdir)/version.itexi $(DOCUMENTATION_LOCALE_TARGET) $(INIT_LY_SOURCES) $(SCHEME_SOURCES)
620         LILYPOND_VERSION=$(TOPLEVEL_VERSION) $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS) $(LILYPOND_BOOK_INCLUDES) $(LILYPOND_BOOK_LILYPOND_FLAGS)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS) $<
621 @end example
622
623 @noindent
624 which seems to be an almost exact duplicate.  Whatever, the first
625 one is executed first.  Have not checked if the second executes.
626
627 The first recipe translates as this:
628
629 @example
630 LILYPOND_VERSION=2.15.0 /usr/bin/python   --process=' ' --output=./out-www --format= --lily-output-dir /home/phil/lilypond-git/build/out/lybook-db
631 @end example
632
633 @noindent
634 if we stop the build with an $(error), but I think this is because
635 we need to allow it to process the dependencies first.  It looks
636 like foo.texi is shown as being dependent on foo.tely, plus a load
637 of other files.
638
639 @example
640 DOCUMENTATION_LOCALE_TARGET is blank
641 INIT_LY_SOURCES = /home/phil/lilypond-git/scm/auto-beam.scm /home/phil/lilypond-git/scm/autochange.scm
642 @end example
643
644 plus 10s (100s?) of other .scm files.
645
646 @example
647 SCHEME_SOURCES = /home/phil/lilypond-git/ly/Welcome-to-LilyPond-MacOS.ly /home/phil/lilypond-git/ly/Welcome_to_LilyPond.ly
648 @end example
649
650 ditto .ly files.  This does seem a teency bit wrong - it looks like
651 the .ly and .scm files have been interchanged.  ly-vars.make has
652 these 2 lines:
653
654 @example
655 INIT_LY_SOURCES = $(wildcard $(top-src-dir)/scm/*.scm)
656 SCHEME_SOURCES = $(wildcard $(top-src-dir)/ly/*.ly)
657 @end example
658
659 Looks like a bug.....
660
661 So it now works its way through all these files, checking if they
662 need to be remade.  This is 100s of lines of the debug listing,
663 although none in the normal list.  Clearly none has to be made
664 since they're source files.  It concludes:
665
666 @example
667 Must remake target `out-www/collated-files.tely'
668 @end example
669
670 @file{lysdoc-rules.make} has this:
671
672 @example
673 $(outdir)/collated-files.tely: $(COLLATED_FILES)
674         $(LYS_TO_TELY) --name=$(outdir)/collated-files.tely --title="$(TITLE)" --author="$(AUTHOR)" $^
675 @end example
676
677 @file{lysdoc-vars.make} has:
678
679 @example
680 COLLATED_FILES = $(sort $(TEXINFO_SOURCES) $(LY_FILES) $(OUT_LY_FILES) )
681 @end example
682
683 We find that:
684
685 @example
686 TEXINFO_SOURCES = AAA-intro-regression.tely
687 OUT_LY_FILES is empty
688 @end example
689
690 so LY_FILES has the big long list of all the .ly files in the
691 regression directory.
692
693 This kicks off
694
695 @example
696 /home/phil/lilypond-git/build/scripts/build/out/lys-to-tely
697 @end example
698
699 with a list of all the files in the regression test directory. This
700 should (I believe) create the file collated-files.tely.
701
702 So the next rule in make is for @file{version.itexi}, and make duly
703 checks this.  There's a rule in @file{doc-i18n-root-rules.make} that this
704 depends on @file{git/VERSION}:
705
706 @example
707 $(outdir)/version.%: $(top-src-dir)/VERSION
708         $(PYTHON) $(top-src-dir)/scripts/build/create-version-itexi.py > $@
709 @end example
710
711 This causes create-version-itexi.py to run and create
712 version.itexi.
713
714 Once that's done, all the other *.scm and *.ly files are checked
715 and since they have no rules associated, they aren't remade (just
716 as well for source files, really).  Since version.itexi was remade
717 make concludes that collated-files.texi must be remade.  To do
718 this, it runs lilypond-book.py on collated-files.tely, as below:
719
720 @example
721 LILYPOND_VERSION=2.15.0
722   /usr/bin/python
723   /home/phil/lilypond-git/scripts/lilypond-book.py
724     -I /home/phil/lilypond-git/input/regression/
725     -I ./out-www -I /home/phil/lilypond-git/input
726     -I /home/phil/lilypond-git/Documentation
727     -I /home/phil/lilypond-git/Documentation/snippets
728     -I /home/phil/lilypond-git/input/regression/
729     -I /home/phil/lilypond-git/Documentation/included/
730     -I /home/phil/lilypond-git/build/mf/out/
731     -I /home/phil/lilypond-git/build/mf/out/
732     -I /home/phil/lilypond-git/Documentation/pictures
733     -I /home/phil/lilypond-git/build/Documentation/pictures/./out-www
734     --process='/home/phil/lilypond-git/build/out/bin/lilypond
735     -I /home/phil/lilypond-git/input/regression/
736     -I ./out-www
737     -I /home/phil/lilypond-git/input
738     -I /home/phil/lilypond-git/Documentation
739     -I /home/phil/lilypond-git/Documentation/snippets
740     -I /home/phil/lilypond-git/input/regression/
741     -I /home/phil/lilypond-git/Documentation/included/
742     -I /home/phil/lilypond-git/build/mf/out/
743     -I /home/phil/lilypond-git/build/mf/out/
744     -I /home/phil/lilypond-git/Documentation/pictures
745     -I /home/phil/lilypond-git/build/Documentation/pictures/./out-www
746     -dbackend=eps
747     --formats=ps,png,pdf
748     -dinclude-eps-fonts
749     -dgs-load-fonts
750     --header=doctitle
751     --header=doctitlecs
752     --header=doctitlede
753     --header=doctitlees
754     --header=doctitlefr
755     --header=doctitlehu
756     --header=doctitleit
757     --header=doctitleja
758     --header=doctitlenl
759     --header=doctitlezh
760     --header=texidoc
761     --header=texidoccs
762     --header=texidocde
763     --header=texidoces
764     --header=texidocfr
765     --header=texidochu
766     --header=texidocit
767     --header=texidocja
768     --header=texidocnl
769     --header=texidoczh
770     -dcheck-internal-types
771     -ddump-signatures
772     -danti-alias-factor=2'
773     --output=./out-www
774     --format=texi-html
775     --verbose
776     --lily-output-dir /home/phil/lilypond-git/build/out/lybook-db
777     out-www/collated-files.tely
778 @end example
779
780 So - lilypond-book runs on:
781
782 @example
783 input/regression/out-www/collated-files.tely
784 @end example
785
786
787 Note the --verbose flag - this is from the make variable
788 LILYPOND_BOOK_VERBOSE which is added to the make variable
789 LILYPOND_BOOK_FLAGS.
790
791 Now found the invocation to write some of the image files.  It's
792 like this:
793
794 @example
795 /home/phil/lilypond-git/build/out/bin/lilypond
796   -I /home/phil/lilypond-git/input/regression/
797   -I ./out-www -I /home/phil/lilypond-git/input
798   -I /home/phil/lilypond-git/Documentation
799   -I /home/phil/lilypond-git/Documentation/snippets
800   -I /home/phil/lilypond-git/input/regression/
801   -I /home/phil/lilypond-git/Documentation/included/
802   -I /home/phil/lilypond-git/build/mf/out/
803   -I /home/phil/lilypond-git/build/mf/out/
804   -I /home/phil/lilypond-git/Documentation/pictures
805   -I /home/phil/lilypond-git/build/Documentation/pictures/./out-www
806   -dbackend=eps
807   --formats=ps,png,pdf
808   -dinclude-eps-fonts
809   -dgs-load-fonts
810   --header=doctitle
811   --header=doctitlecs
812   --header=doctitlede
813   --header=doctitlees
814   --header=doctitlefr
815   --header=doctitlehu
816   --header=doctitleit
817   --header=doctitleja
818   --header=doctitlenl
819   --header=doctitlezh
820   --header=texidoc
821   --header=texidoccs
822   --header=texidocde
823   --header=texidoces
824   --header=texidocfr
825   --header=texidochu
826   --header=texidocit
827   --header=texidocja
828   --header=texidocnl
829   --header=texidoczh
830   -dcheck-internal-types
831   -ddump-signatures
832   -danti-alias-factor=2
833   -I  "/home/phil/lilypond-git/build/out/lybook-db"
834   -I  "/home/phil/lilypond-git/build/input/regression"
835   -I  "/home/phil/lilypond-git/input/regression"
836   -I  "/home/phil/lilypond-git/build/input/regression/out-www"
837   -I  "/home/phil/lilypond-git/input"
838   -I  "/home/phil/lilypond-git/Documentation"
839   -I  "/home/phil/lilypond-git/Documentation/snippets"
840   -I  "/home/phil/lilypond-git/input/regression"
841   -I  "/home/phil/lilypond-git/Documentation/included"
842   -I  "/home/phil/lilypond-git/build/mf/out"
843   -I  "/home/phil/lilypond-git/build/mf/out"
844   -I  "/home/phil/lilypond-git/Documentation/pictures"
845   -I  "/home/phil/lilypond-git/build/Documentation/pictures/out-www"
846   --formats=eps
847   --verbose
848   -deps-box-padding=3.000000
849   -dread-file-list
850   -dno-strip-output-dir
851   "/home/phil/lilypond-git/build/out/lybook-db/snippet-names--415419468.ly"'
852 @end example
853
854 Note the --verbose.  This causes 100s of lines of Lily debug output.
855 But at present I can't work out where the flag comes from. Later.
856
857
858 @node Building a bibliography
859 @subsection Building a bibliography
860
861 Bibliography files contain a list of citations, like this:
862
863 @example
864 @@Book@{vinci,
865   author = @{Vinci, Albert C.@},
866   title = @{Fundamentals of Traditional Music Notation@},
867   publisher = @{Kent State University Press@},
868   year = @{1989@}
869 @}
870 @end example
871
872 There are a variety of types of citation (e.g. Book (as above),
873 article, publication).  Each cited publication has a list of
874 entries that can be used to identify the publication.
875 Bibliograpies are normally stored as files with a .bib
876 extension.  One part of the doc-build process is transforming the
877 bibliography information into @code{texinfo} files.  The commands
878 to do this are in the @file{GNUmakefile} in the
879 @file{Documentation} directory.
880
881 A typical line of the makefile to translate a single bibliography
882 is:
883
884 @example
885 $(outdir)/colorado.itexi:
886         BSTINPUTS=$(src-dir)/essay $(buildscript-dir)/bib2texi \
887                 -s $(top-src-dir)/Documentation/lily-bib \
888                 -o $(outdir)/colorado.itexi \
889                 $(src-dir)/essay/colorado.bib
890 @end example
891
892 Line by line:
893
894 @example
895 $(outdir)/colorado.itexi:
896 @end example
897
898 We're making the file @file{colorado.itexi} and so this is the
899 make instruction.
900
901 @example
902         BSTINPUTS=$(src-dir)/essay $(buildscript-dir)/bib2texi \
903 @end example
904
905 It's in the @file{essay} directory and we want to run the
906 bib2texi.py script against it.
907
908 @example
909                 -s $(top-src-dir)/Documentation/lily-bib \
910 @end example
911
912 The style template is @file{lily-bib.bst} and is found in the
913 @file{Documentation} directory.
914
915 @example
916                 -o $(outdir)/colorado.itexi \
917 @end example
918
919 The output file in @file{colorado.itexi}.
920
921 @example
922                 $(src-dir)/essay/colorado.bib
923 @end example
924
925 The input file is @file{colorado.bib} in the @file{essay}
926 directory.
927
928 The @code{bib2texi} Python script used to be used with a variety
929 of options, but now is always called using the same options, as
930 above.  Its job is to create the file containing the options for
931 @code{bibtex} (the program that actually does the translation),
932 run bibtex, and then clean up some temporary files.  Its main
933 "value add" is the creation of the options file, using this code:
934
935 @example
936 open (tmpfile + '.aux', 'w').write (r'''
937 \relax
938 \citation@{*@}
939 \bibstyle@{%(style)s@}
940 \bibdata@{%(files)s@}''' % vars ())
941 @end example
942
943 The key items are the style file (now always lily-bib for us) and
944 the input file.
945
946 The style file is written in its own specialised language,
947 described to some extent at
948
949 @example
950 @uref{http://amath.colorado.edu/documentation/LaTeX/reference/faq/bibtex.pdf}
951 @end example
952
953 The file @file{lily-bib.bst} also has fairly extensive commenting.
954
955 @node Website build
956 @section Website build
957
958 Start here: @file{make/website.make}
959
960 The overall build system begins with @ref{How stepmake works}.
961 Summary: when you type @code{make website} this ends up running
962 @file{GNUmakefile.in} in the @file{git} directory.  Right at the
963 bottom, this has the lines:
964
965 @example
966 # we want this separate for security; see CG 4.2.  -gp
967 website:
968         $(MAKE) config_make=$(config_make) \
969                 top-src-dir=$(top-src-dir) \
970                 -f $(top-src-dir)/make/website.make \
971                 website
972 @end example
973
974 On my system this expands to:
975
976 @example
977 make --no-builtin-rules config_make=./config.make \
978                 top-src-dir=/home/phil/lilypond-git \
979                 -f /home/phil/lilypond-git/make/website.make \
980                 website
981 @end example
982
983 We see that the @code{$(MAKE)} expands to
984 @code{make --no-builtin-rules} which is how @code{MAKE} is
985 defined higher up the makefile.  The -f switch defines the
986 makefile to be used - in this case
987 @file{git/make/website.make}.  That's where all the action
988 happens.
989
990 We believe that note that *none* of the variables that
991 are loaded (from depth to version numbers to whatever) are used in
992 @file{website.make}.  Instead, @file{website.make} sets up its own
993 variables at the top of the file.  If you're wondering if there's
994 some smart reason for this, then the answer is "no".  It's because
995 I (GP) didn't know/trust the original variables when I was writing
996 that file.
997
998 Website build includes @ref{Building a bibliography}.
999
1000 @subsubheading Output from @code{make -n website}
1001
1002 Sorry, including this output directly produces problems in the
1003 build system.  Please run:
1004
1005 @example
1006 make -n website &> my-file.txt
1007 @end example
1008
1009 to see the full output from the make.
1010
1011 @subsubheading website.make variables
1012
1013 The file begins by setting up some variables.  These
1014 may/might/probably mirror existing variables, but lacking any docs
1015 about those variables, I thought it would be simpler to keep
1016 everything in the same file.
1017
1018 Note that for security reasons, we @strong{don't} call scripts in
1019 the git dir when building on the web server.  See @ref{Uploading
1020 and security}.  So we definitely want to keep those definitions
1021 for the WEBSITE_ONLY_BUILD.
1022
1023 After some split WEBSITE_ONLY_BUILD vs. normal build definitions,
1024 there's another bunch of lines setting up generic variables.
1025
1026 @subsubheading website.make building parts
1027
1028 Parts of @file{website.make}:
1029
1030 @itemize
1031
1032 @item
1033 @code{website:}
1034 this is the "master" rule.  It calls the other rules in order,
1035 then copies some extra files around - see below for further
1036 of the process it produces.
1037
1038 @item
1039 @code{website-version}:
1040 this calls the python scripts below:
1041
1042 @itemize
1043 @item
1044 @example
1045 scripts/build/create-version-itexi.py
1046 @end example
1047
1048 This writes a @@version, @@versionStable, and @@versionDevel based
1049 on the top-level VERSIONS file, to
1050 @code{out-website/version.itexi}
1051
1052 @item
1053 @example
1054 scripts/build/create-weblinks-itexi.py
1055 @end example
1056
1057 This creates a ton of macros in @code{out-website/weblinks.itexi}.
1058 Stuff like @@downloadStableLinuxNormal, @@downloadStableWidows,
1059 @code{@@stableDocsNotationPdf@{@}}, @@downloadDevelSourch-zh.
1060
1061 It's quite monstrous because it deals with combinations of
1062 stable/devel, source/docs, lang/lang/lang*10, etc.
1063
1064 @end itemize
1065
1066
1067 @item
1068 @code{website-xrefs:}
1069 creates files used for complicated "out-of-build" references to
1070 @code{out-website/*.xref-map}
1071
1072 If you just write @@ref@{@}, then all's groovy and we wouldn't
1073 need this.  But if you write @@rlearning@{@}, then our custom
1074 texi2html init file needs to know about our custom xref file
1075 format, which tells our custom texi2html init file how to create
1076 the link.
1077
1078 GP: we should have a separate @@node to discuss xrefs.  Also, take a
1079 quick look at a generated xref file -- it's basically just a list
1080 of @@node's [sic teenager pluralization rule] from the file.
1081
1082 @item
1083 @code{website-bib:}
1084 generates the bibliography texinfo files from the .bib files - in
1085 the case of the website build these are @file{others-did.bib} and
1086 @file{we-wrote.bib}.
1087
1088 @item
1089 @code{website-texinfo:}
1090 this is the main part; it calles texi2html to generate the actual
1091 html.  It also has a ton of options to texi2html to pass info to
1092 our custom init file.
1093
1094 The file actually built is called @file{web.texi}, and is either
1095 in the @file{Documentation} directory, or a sub-directory specific
1096 to the language.
1097
1098 The options file is @file{/Documentation/lilypond-texi2html.init}.
1099 This contains *lots* of option and configuration stuff, and also
1100 includes the line:
1101
1102 @example
1103 print STDERR "Initializing settings for web site: [$Texi2HTML::THISDOC@{current_lang@}]\n";
1104 @end example
1105
1106 This is where one of the console messages is generated.
1107
1108 We have somewhere between 2-4 different ways "to pass info to our
1109 custom init file".  This is highly Not Good (tm), but that's how
1110 things work at the moment.
1111
1112 After texi2html, it does some black magick to deal with
1113 untranslated nodes in the translations.  Despite writing that
1114 part, I can't remember how it works.  But in theory, you could
1115 figure it out by copy&pasting each part of the command (by "part",
1116 I mean "stuff before each | pipe"), substituting the variables,
1117 then looking at the text that's output.  For example,
1118
1119 @example
1120   ls $(OUT)/$$l/*.html
1121 @end example
1122
1123 is going to print a list of all html files, in all languages, in
1124 the build directory.  Then more stuff happens to each of those
1125 files (that's what xargs does).
1126
1127 @item
1128 @code{website-css:}
1129 just copies files to the build dir.
1130
1131 @item
1132 @code{website-pictures, website-examples:}
1133 more file copies, with an if statement to handle if you don't have
1134 any generated pictures/examples.
1135
1136 @item
1137 @code{web-post:}
1138 runs:
1139
1140 @example
1141 scripts/build/website_post.py
1142 @end example
1143
1144 which, it adds the "this page is translated in klingon" to the
1145 bottom of html pages, and adds the google analytics javascript.
1146 It also has hard-coded lilypond version numbers, which is Bad
1147 (tm).
1148
1149 @end itemize
1150
1151 Here's a summary of what gets called, in what order, when we run
1152 @code{make website}
1153
1154 @example
1155 website:
1156   website-texinfo:
1157     website-version:
1158       creates version.itexi and weblinks.itexi
1159     website-xrefs:
1160       runs extract_texi_filenames.py
1161     website-bibs:
1162       creates bibliography files, described above
1163   website-css:
1164     copies css files
1165   website-pictures:
1166     copies pictures
1167   website-examples:
1168     copies examples
1169   web-post:
1170     runs website_post.py
1171   Then some file copying
1172 @end example
1173
1174 @node Building an Ubuntu distro
1175 @section Building an Ubuntu distro
1176
1177
1178 Here's the short instruction on how to create lilybuntu iso image
1179 (Jonathan Kulp did this on a spare drive,
1180 but he supposes it can be done in a VM too):
1181
1182 @enumerate
1183
1184 @item
1185 Install ubuntu, reboot.
1186 @item
1187 Run all updates, reboot if asked.
1188 @item
1189 Enable src repos, refresh package lists.
1190 @item
1191 Install LilyPond build deps:
1192 @example
1193 sudo apt-get build-dep lilypond
1194 @end example
1195 @item
1196 Install git and autoconf:
1197 @example
1198 sudo apt-get install git-core gitk autoconf
1199 @end example
1200
1201 @item
1202 Test to see whether everything works fine now:
1203 @enumerate
1204 @item
1205 use @command{lily-git.tcl} to grab source files
1206 @item
1207 go to source dir and do
1208 @example
1209 "./autogen.sh" ; make ; make doc
1210 @end example
1211 @item
1212 if all compiles, move on to iso creation...
1213 @end enumerate
1214
1215 @item
1216 Download & install "remastersys":
1217 @uref{http://sourceforge.net/projects/remastersys/, http://sourceforge.net/projects/remastersys/}
1218 @item
1219 Copy @command{lily-git.tcl} script file into @file{/etc/skel/}.
1220 @item
1221 Modify @file{/etc/remastersys.conf} as desired (change @code{.iso} name,
1222 default live session username, etc).
1223 @item
1224 Remove non-essential desktop software as desired.
1225 @item
1226 Create iso:
1227 @example
1228 sudo remastersys dist
1229 @end example
1230 New iso is in @file{/home/remastersys/remastersys/}.
1231 @item
1232 Test iso by installing in VM and repeating steps above for
1233 getting source files and building lp and docs.
1234
1235 @end enumerate