]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/contributor/build-notes.itexi
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[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 * Doc build::
15 * Website build::
16 * Building an Ubuntu distro::
17 @end menu
18
19
20 @node Build system overview
21 @section Build system overview
22
23 Build system is currently GNU make, with an extra "stepmake" layer
24 on top.  Look at files in @file{make/} and @file{stepmake/} and
25 all @file{GNUmakefile}s.
26
27 There is wide-spread dissatisfaction with this system, and we are
28 considering changing.  This would be a huge undertaking (estimated
29 200+ hours).  This change will probably involve not using GNU make
30 any more -- but a discussion about the precise build system will
31 have to wait.  Before we reach that point, we need to figure out
32 (at least approximately) what the current build system does.
33
34 Fundamentally, a build system does two things:
35
36 @enumerate
37 @item
38 Constructs command-line commands, for example:
39
40 @example
41 lilypond-book \
42   --tons --of --options \
43   pitches.itely
44 texi2pdf \
45   --more --imperial --and --metric --tons --of --options \
46   pitches.texi
47 @end example
48
49 @item
50 If there was a previous build, it decides which parts of the
51 system need to be rebuilt.
52
53 @end enumerate
54
55 When I try to do anything in the build system, it helps to remind
56 myself of this.  The "end result" is just a series of command-line
57 commands.  All the black magick is just an attempt to construct
58 those commands.
59
60 @node Tips for working on the build system
61 @section Tips for working on the build system
62
63 @itemize
64 @item
65 Add:
66
67 @example
68 echo "aaa"
69
70 echo "bbb"
71 @end example
72
73 to the build system files in various places.  This will let you
74 track where the program is, in various points of the build.
75
76 @item
77 First task: understand how @code{make website} works,
78 @emph{without} the translations.  Looking at the english-only
79 website is the best introduction to the build system... it only
80 covers about 5% of the whole thing, but even that will likely take
81 10 hours or more.
82
83 @end itemize
84
85
86
87 @node Doc build
88 @section Doc build
89
90 @menu
91 * Building a bibliography::
92 @end menu
93
94 @node Building a bibliography
95 @subsection Building a bibliography
96
97 Bibliography files contain a list of citations, like this:
98
99 @example
100 @@Book@{vinci,
101   author = @{Vinci, Albert C.@},
102   title = @{Fundamentals of Traditional Music Notation@},
103   publisher = @{Kent State University Press@},
104   year = @{1989@}
105 @}
106 @end example
107
108 There are a variety of types of citation (e.g. Book (as above),
109 article, publication).  Each cited publication has a list of
110 entries that can be used to identify the publication.
111 Bibliograpies are normally stored as files with a .bib
112 extension.  One part of the doc-build process is transforming the
113 bibliography information into @code{texinfo} files.  The commands
114 to do this are in the @file{GNUmakefile} in the
115 @file{Documentation} directory.
116
117 A typical line of the makefile to translate a single bibliography
118 is:
119
120 @example
121 $(outdir)/colorado.itexi:
122         BSTINPUTS=$(src-dir)/essay $(buildscript-dir)/bib2texi \
123                 -s $(top-src-dir)/Documentation/lily-bib \
124                 -o $(outdir)/colorado.itexi \
125                 $(src-dir)/essay/colorado.bib
126 @end example
127
128 Line by line:
129
130 @example
131 $(outdir)/colorado.itexi:
132 @end example
133
134 We're making the file @file{colorado.itexi} and so this is the
135 make instruction.
136
137 @example
138         BSTINPUTS=$(src-dir)/essay $(buildscript-dir)/bib2texi \
139 @end example
140
141 It's in the @file{essay} directory and we want to run the
142 bib2texi.py script against it.
143
144 @example
145                 -s $(top-src-dir)/Documentation/lily-bib \
146 @end example
147
148 The style template is @file{lily-bib.bst} and is found in the
149 @file{Documentation} directory.
150
151 @example
152                 -o $(outdir)/colorado.itexi \
153 @end example
154
155 The output file in @file{colorado.itexi}.
156
157 @example
158                 $(src-dir)/essay/colorado.bib
159 @end example
160
161 The input file is @file{colorado.bib} in the @file{essay}
162 directory.
163
164 The @code{bib2texi} Python script used to be used with a variety
165 of options, but now is always called using the same options, as
166 above.  Its job is to create the file containing the options for
167 @code{bibtex} (the program that actually does the translation),
168 run bibtex, and then clean up some temporary files.  Its main
169 "value add" is the creation of the options file, using this code:
170
171 @example
172 open (tmpfile + '.aux', 'w').write (r'''
173 \relax
174 \citation@{*@}
175 \bibstyle@{%(style)s@}
176 \bibdata@{%(files)s@}''' % vars ())
177 @end example
178
179 The key items are the style file (now always lily-bib for us) and
180 the input file.
181
182 The style file is written in its own specialised language,
183 described to some extent at
184
185 @example
186 @uref{http://amath.colorado.edu/documentation/LaTeX/reference/faq/bibtex.pdf}
187 @end example
188
189 The file @file{lily-bib.bst} also has fairly extensive commenting.
190
191 @node Website build
192 @section Website build
193
194 Start here: @file{make/website.make}
195
196 Typing make website runs the file @file{GNUmakefile} from the
197 build directory.  This only contains 3 lines:
198
199 @example
200 depth = .
201 include config$(if $(conf),-$(conf),).make
202 include $(configure-srcdir)/GNUmakefile.in
203 @end example
204
205 The variable @code{depth} is used throughout the make system to
206 track how far down the directory structure the make is.  The first
207 include sets lots of variables but doesn't "do" anything.  The
208 second runs the file @file{GNUmakefile.in} from the top level
209 source directory.
210
211 This sets another load of variables, and then includes (i.e.
212 immediately runs) @file{stepmake.make} from the @file{make}
213 subdirectory.  This sets a load of other variables, does some
214 testing to see if SCONS (another build tool?) is being used, and
215 then runs @file{make/config.make} - which doesn't seem to exist...
216
217 GP: scons is indeed a different build tool; I think that Jan
218 experimented with it 5 years ago or something.  It seems like we
219 still have bits and pieces of it floating around.
220
221 GP: note that *none* of the variables that are loaded (from depth
222 to version numbers to whatever) are used in website.make.
223 Instead, website.make sets up its own variables at the top of the
224 file.  If you're wondering if there's some smart reason for this,
225 then the answer is "no".  It's because I didn't know/trust the
226 original variables when I was writing that file.
227
228 Next, it runs @file{make/toplevel-version.make}, which sets the
229 version variables for major, minor, patch, stable, development and
230 mypatchlevel (which seems to be used for patch numbers for
231 non-stable versions only?).
232
233 Next - @file{make/local.make}, which doesn't exist.
234
235 Then a few more variable and the interesting comment:
236
237 @example
238 # Don't try to outsmart us, you puny computer!
239 # Well, UGH.  This only removes builtin rules from
240 @end example
241
242 and then tests to see whether BUILTINS_REMOVED is defined.  It
243 appears to be when I run make, and so
244 @file{stepmake/stepmake/no-builtin-rules.make} is run.  The
245 comment at the head of this file says:
246
247 @example
248 # UGH.  GNU make comes with implicit rules.
249 # We don't want any of them, and can't force users to run
250 # --no-builtin-rules
251 @end example
252
253 I've not studied that file at length, but assume it removes all
254 make's build-in rules (e.g. @file{*.c} files are run through the
255 GNU C compiler) - there's a lot of them in here, and a lot of
256 comments, and I'd guess most of it isn't needed.
257
258 We return to @file{stepmake.make}, where we hit the make rule all:
259 The first line of this is:
260
261 @example
262 -include $(addprefix $(depth)/make/,$(addsuffix -inclusions.make, $(LOCALSTEPMAKE_TEMPLATES)))
263 @end example
264
265 which, when the variables are substituted, gives:
266
267 @example
268 ./make/generic-inclusions.make
269 ./make/lilypond-inclusions.make.
270 @end example
271
272 (Note - according to the make documentation, -include is only
273 different from include in that it doesn't produce any kind of
274 error message when the included file doesn't exist).
275
276 And the first file doesn't exist.  Nor the second.  Next:
277
278 @example
279 -include $(addprefix $(stepdir)/,$(addsuffix -inclusions.make, $(STEPMAKE_TEMPLATES)))
280 @end example
281
282 which expands to the following files:
283
284 @example
285 /home/phil/lilypond-git/stepmake/stepmake/generic-inclusions.make
286 /home/phil/lilypond-git/stepmake/stepmake/toplevel-inclusions.make
287 /home/phil/lilypond-git/stepmake/stepmake/po-inclusions.make
288 /home/phil/lilypond-git/stepmake/stepmake/install-inclusions.make.
289 @end example
290
291 One little feature to notice here - these are all absolute file
292 locations - the line prior to this used relative locations.  And
293 none of these files exist, either.  (Further note - I'm assuming
294 all these lines of make I'm following are autogenerated, but
295 that'll be something else to discover.)
296
297 Next in @file{stepmake.make}:
298
299 @example
300 include $(addprefix $(stepdir)/,$(addsuffix -vars.make, $(STEPMAKE_TEMPLATES)))
301 @end example
302
303 which expands to:
304
305 @example
306 /home/phil/lilypond-git/stepmake/stepmake/generic-vars.make
307 /home/phil/lilypond-git/stepmake/stepmake/toplevel-vars.make
308 /home/phil/lilypond-git/stepmake/stepmake/po-vars.make
309 /home/phil/lilypond-git/stepmake/stepmake/install-vars.make.
310 @end example
311
312 Woo.  They all exist (they should as there's no - in front of the
313 include).  @file{generic-vars.make} sets loads of variables
314 (funnily enough).  @file{toplevel-vars.make} is very short - one
315 line commented as @code{# override Generic_vars.make:} and 2 as
316 follows:
317
318 @example
319 # urg?
320 include $(stepdir)/documentation-vars.make
321 @end example
322
323 I assume the urg comment refers to the fact that this should
324 really just create more variables, but it actually sends us off to
325 @file{/home/phil/lilypond-git/stepmake/stepmake/documentation-vars.make}.
326
327 That file is a 3 line variable setting one.
328
329 @file{po-vars.make} has the one-line comment @code{# empty}, as
330 does @file{install-vars.make}.
331
332 So now we're back to @file{stepmake.make}.
333
334 The next lines are
335 :
336 @example
337 # ugh. need to do this because of PATH :=$(top-src-dir)/..:$(PATH)
338 include $(addprefix $(depth)/make/,$(addsuffix -vars.make, $(LOCALSTEPMAKE_TEMPLATES)))
339 @end example
340
341 and the include expands to:
342
343 @example
344 include ./make/generic-vars.make ./make/lilypond-vars.make.
345 @end example
346
347 These again set variables, and in some cases export them to allow
348 child @code{make} processes to use them.
349
350 The final 4 lines of @file{stepmake.make} are:
351
352 @example
353 include $(addprefix $(depth)/make/,$(addsuffix -rules.make, $(LOCALSTEPMAKE_TEMPLATES)))
354 include $(addprefix $(stepdir)/,$(addsuffix -rules.make, $(STEPMAKE_TEMPLATES)))
355 include $(addprefix $(depth)/make/,$(addsuffix -targets.make, $(LOCALSTEPMAKE_TEMPLATES)))
356 include $(addprefix $(stepdir)/,$(addsuffix -targets.make, $(STEPMAKE_TEMPLATES)))
357 @end example
358
359 which expand as follows:
360
361 @example
362 include ./make/generic-rules.make ./make/lilypond-rules.make
363 include
364   /home/phil/lilypond-git/stepmake/stepmake/generic-rules.make
365   /home/phil/lilypond-git/stepmake/stepmake/toplevel-rules.make
366   /home/phil/lilypond-git/stepmake/stepmake/po-rules.make
367   /home/phil/lilypond-git/stepmake/stepmake/install-rules.make
368 include ./make/generic-targets.make ./make/lilypond-targets.make
369 include
370   /home/phil/lilypond-git/stepmake/stepmake/generic-targets.make
371   /home/phil/lilypond-git/stepmake/stepmake/toplevel-targets.make
372   /home/phil/lilypond-git/stepmake/stepmake/po-targets.make
373   /home/phil/lilypond-git/stepmake/stepmake/install-targets.make
374 @end example
375
376 @file{lilypond-rules.make} is @code{#empty}
377 @file{generic-rules.make} does seem to have 2 rules in it.  They
378 are:
379
380 @example
381 $(outdir)/%.ly: %.lym4
382         $(M4) $< | sed "s/\`/,/g" > $@
383
384 $(outdir)/%: %.in
385         rm -f $@
386         cat $< | sed $(sed-atfiles) | sed $(sed-atvariables) > $@
387 @end example
388
389 I believe the first rule is for *.ly files, and has a prerequisite
390 that *.lym4 files must be built first.  The recipe is @code{m4  |
391 sed "s/\`/,/g" >}.  Perhaps someone with more Unix/make knowledge
392 can comment on exactly what the rules mean/do.
393
394 @file{toplevel-rules.make} is @code{#empty}
395 @file{po-rules.make} is @code{#empty}
396 @file{install-rules.make} is @code{#empty}
397 @file{generic-targets.make} contains 2 lines of comments.
398 @file{lilypond-targets.make} contains only:
399
400 @example
401 ## TODO: fail dist or web if no \version present.
402 check-version:
403         grep -L version $(LY_FILES)
404 @end example
405
406 @file{stepmake/generic-targets.make} contains lots of rules - too
407 many to list here - it seems to be the main file for rules. (FWIW
408 I haven't actually found a rule for website: anywhere, although
409 it clearly exists.  I have also found that you can display a rule
410 in the terminal by typing, say @code{make -n website}.  This is
411 probably common knowledge.
412
413 @file{stepmake/toplevel-targets.make} adds a load of other (and
414 occasionally the same) rules to the gernric-targets.
415
416 @file{stepmake/po-targets.make} is rules for po* makes.
417
418 @file{stepmake/install-targets.make} has rules for local-install*.
419
420 And that's the end of stepmake.make.  Back to
421 @file{GNUmakefile.in}.  More some other time.
422
423 Another alterative approach to understanding the website build
424 would be to redirect @code{make -n website} and @code{make website}
425 to a text file and work through a) what it does and b) where the
426 errors are occurring.
427
428 GP: wow, all the above is much more complicated than I've ever
429 looked at stuff -- I tend to do a "back first" approach (where I
430 begin from the command-line that I want to modify, figure out
431 where it's generated, and then figure out how to change the
432 generated command-line), rather than a "front first" (where you
433 begin from the "make" command).  In the long term, we should
434 probably move it to a general "how stepmake works" section,
435 because it's not particularly relevant to the website build.
436
437 Website build includes @ref{Building a bibliography}.
438
439
440 @subsubheading website.make variables
441
442 The file begins by setting up some variables.  These
443 may/might/probably mirror existing variables, but lacking any docs
444 about those variables, I thought it would be simpler to keep
445 everything in the same file.
446
447 Note that for security reasons, we *don't* call scripts in the git
448 dir when building on the web server.  See @ref{Uploading and
449 security}.  So we definitely want to keep those definitions for
450 the WEBSITE_ONLY_BUILD.
451
452 After some split WEBSITE_ONLY_BUILD vs. normal build definitions,
453 there's another bunch of lines setting up generic variables.
454
455 @subsubheading website.make building parts
456
457 The website-version rule creates files that define macros for
458 commands like @@stableDocsNotationPdf@{@}, by calling python scripts.
459 Those scripts are scripts/build/create-version-itexi.py and
460 scripts/build/create-weblinks-itexi.py.
461
462 website-xrefs: creates files used for complicated "out-of-build"
463 references.  If you just write @@ref@{@}, then all's groovy.  But
464 if you do @@rlearning@{@}, then our custom texi2html init file
465 needs to know about our custom xref file format, which tells our
466 custom texi2html init file how to create the link.
467
468 We should have a separate @@node to discuss xrefs.  Also, take a
469 quick look at a generated xref file -- it's basically just a list
470 of @@node's [sic teenager pluralization rule] from the file.
471
472 website-bib: generates the bibliography texinfo files from the
473 .bib files.
474
475 website-texinfo: this is the money shot; it calles texi2html to
476 generate the actual html.  It also has a ton of options to
477 texi2html to pass info to our custom init file.
478
479 After texi2html, it does some black magick to deal with
480 untranslated nodes in the translations.  Despite writing that
481 part, I can't remember how it works.  But in theory, you could
482 figure it out by copy&pasting each part of the command (by "part",
483 I mean "stuff before each | pipe"), substituting the variables,
484 then looking at the text that's output.  For example,
485   ls $(OUT)/$$l/*.html
486 is going to print a list of all html files, in all languages, in
487 the build directory.  Then more stuff happens to each of those
488 files (that's what xargs does).
489
490 website-css: just copies files to the build dir.
491
492 website-pictures, website-examples: more file copies, with an if
493 statement to handle if you don't have any generated
494 pictures/examples.
495
496 web-post: buggered if I know.  Apparently it runs the
497 scripts/build/website_post.py  file, which despite writing, I
498 can't remember what it does.
499
500 ok, it adds the "this page is translated in klingon" to the bottom
501 of html pages, and adds the google analytics javascript.  It also
502 has hard-coded lilypond version numbers.
503
504 website: this is the "master" rule.  It calls the bits and pieces
505 in order, then copies some extra files around.
506
507
508 @node Building an Ubuntu distro
509 @section Building an Ubuntu distro
510
511 @enumerate
512 @item
513 Install ubuntu, reboot
514 @item
515 Run all updates, reboot if asked
516 @item
517 Enable src repos, refresh package lists
518 @item
519 Install LilyPond build deps:
520 @example
521   sudo apt-get build-dep lilypond
522 @end example
523 @item
524 Install git and autoconf:
525 @example
526   sudo apt-get install git-core gitk autoconf
527 @end example
528
529 @item
530 TEST TO SEE WHETHER EVERYTHING WORKS NOW:
531 @enumerate
532 @item
533 Use lily-git.tcl to grab source files
534 @item
535 Go to source dir and do "./autogen.sh" ; make ; make doc
536 @item
537 If all compiles, move on to iso creation...
538
539 @end enumerate
540
541 @item
542 Download & install "remastersys":
543 @example
544   http://sourceforge.net/projects/remastersys/
545 @end example
546 @item
547 Copy lily-git.tcl script file into /etc/skel/
548 @item
549 Modify /etc/remastersys.conf as desired (change .iso name, default
550 live session username, etc)
551 @item
552 Remove non-essential desktop software as desired
553 @item
554 Create iso:  sudo remastersys dist
555 @item
556 New iso is in /home/remastersys/remastersys/
557 @item
558 Test iso by installing in VM and repeating steps above for
559 getting source files and building lp and docs
560 @end enumerate
561
562
563