]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/SConscript
* SConstruct: Configure only pristine build tree or on user
[lilypond.git] / Documentation / user / SConscript
1 # -*-python-*-
2
3 import os
4 import string
5
6 Import ('env')
7 sources = env['src_glob'] (env, '*.tely')
8 pngs = env['src_glob'] (env, '*.png')
9
10 mfbuild = os.path.join (env['absbuild'], 'mf', env['out'])
11 lilybuild = os.path.join (env['absbuild'], 'lily', env['out'])
12 userbuild = os.path.join (env['absbuild'], 'Documentation/user', env['out'])
13
14 env.Depends ('lilypond.texi', env['LILYPOND_BIN'])
15 env.Depends ('lilypond.texi', 'lilypond-internals.texi')
16
17 png_stems = map (lambda x: os.path.splitext (x)[0], pngs)
18 epss = map (env.Png2eps, png_stems)
19 env.Depends ('lilypond.texi', epss)
20
21 lydir = Dir ('.').srcnode ().abspath + '/../../ly'
22 env.Command ('lilypond-internals.texi', env['LILYPOND_BIN'],
23              'cd ${TARGET.dir} \
24              && LILYPONDPREFIX=$LILYPONDPREFIX $LILYPOND_BIN $__verbose \
25              $lydir/generate-documentation')
26
27 doc_stems = map (lambda x: os.path.splitext (x)[0], sources)
28 texis = map (env.TELY, doc_stems)
29 dvis = map (env.Texi2dvi, doc_stems)
30 pss = map (env.PostScript, map (lambda x: x + '.dvi', doc_stems))
31 pdfs = map (env.Dvi2pdf, doc_stems)
32
33
34 def file_subst (file_name, find, subst):
35         s = open (file_name).read ()
36         t = string.replace (find, subst, s)
37         if s != t:
38                 os.rename (file_name, file_name + '~')
39                 h = open (file_name, "w")
40                 h.write (t)
41                 h.close ()
42
43 e = env.Copy ()
44 e['usersrc'] = Dir ('.').srcnode ().abspath
45 def url_fixup (target, source, env):
46         file_subst (str (target[0]),
47                     '\.\./lilypond-internals', 'lilypond-internals/')
48 a = ['$MAKEINFO -I$usersrc -I${SOURCE.dir} --html \
49 --css-include=$usersrc/../texinfo.css $__verbose \
50 --output=${TARGET.dir} $SOURCE',
51      '$MAKEINFO -I$usersrc -I${SOURCE.dir} --html --no-split --no-headers \
52      --css-include=$usersrc/../texinfo.css $__verbose \
53      --output=$TARGET $SOURCE',
54      url_fixup,
55      'ln -f ${SOURCE.dir}/*.png ${SOURCE.dir}/*.ly ${TARGET.dir}/']
56      
57 e.Command ('lilypond/lilypond.html', 'lilypond.texi', a)
58 e.Command ('lilypond-internals/lilypond-internals.html',
59              'lilypond-internals.texi', a)
60
61 env.Alias ('doc', texis)
62 env.Alias ('doc', dvis)
63 env.Alias ('doc', pss)
64 env.Alias ('doc', pdfs)
65
66 env.Alias ('doc', 'lilypond/lilypond.html')
67 env.Alias ('doc', 'lilypond-internals/lilypond-internals.html')