10 srcdir = env['srcdir']
12 def join_path (path, infix=os.pathsep, prefix = ''):
17 return string.join (map (lambda x: prefix + dir (x), path), infix)
19 env['join_path'] = join_path
21 env['MAKEINFO_INCLUDES'] = join_path (env['MAKEINFO_PATH'], '', ' -I')
22 a = '$MAKEINFO $__verbose $MAKEINFO_INCLUDES --no-split --no-headers \
23 --output=$TARGET $SOURCE'
24 TXT = Builder (action = a, suffix = '.txt', src_suffix = '.texi')
25 env.Append (BUILDERS = {'TXT': TXT})
27 a = '$MAKEINFO $__verbose $MAKEINFO_INCLUDES --output=$TARGET $SOURCE'
28 INFO = Builder (action = a, suffix = '.info', src_suffix = '.texi')
29 env.Append (BUILDERS = {'INFO': INFO})
31 a = '$MAKEINFO $__verbose $MAKEINFO_INCLUDES --html --no-split --no-headers \
32 --css-include=$srcdir/Documentation/texinfo.css --output=$TARGET $SOURCE'
33 HTML = Builder (action = a, suffix = '.html', src_suffix = '.texi')
34 env.Append (BUILDERS = {'HTML': HTML})
37 env['LILYPOND_BOOK_INCLUDES'] = join_path (env['LILYPOND_BOOK_PATH'], '',
40 # UGHR, lilypond.py uses lilypond-bin from PATH
41 env.PrependENVPath ('PATH',
42 os.path.join (env['absbuild'], env['out'], 'usr/bin'))
44 if os.environ.has_key ('TEXMF'):
45 env.Append (ENV = {'TEXMF' : os.environ['TEXMF']})
46 env.Append (ENV = {'TEXMF' : '{$LILYPONDPREFIX,' \
47 + os.popen ('kpsexpand \$TEXMF').read ()[:-1] + '}' })
49 #if os.environ.has_key ('GS_LIB'):
50 # env.Append (ENV = {'GS_LIB' : os.environ['GS_LIB'] })
52 #env.PrependENVPath ('GS_LIB', ['$run_prefix/share/lilyond/ps',
53 # '$run_prefix/share/lilypond/fonts/type1/'])
55 if os.environ.has_key ('LD_LIBRARY_PATH'):
56 env.Append (ENV = {'LD_LIBRARY_PATH' : os.environ['LD_LIBRARY_PATH']})
57 if os.environ.has_key ('GUILE_LOAD_PATH'):
58 env.Append (ENV = {'GUILE_LOAD_PATH' : os.environ['GUILE_LOAD_PATH']})
60 env.Append (PYTHONPATH = [os.path.join (env['absbuild'], env['out'],
62 os.path.join (srcdir, 'buildscripts'),
63 os.path.join (srcdir, 'python')])
64 env.Append (ENV = { 'PYTHONPATH' : string.join (env['PYTHONPATH'],
67 a = ['${__set_x}rm -f $$(grep -LF "\lilypondend" ${TARGET.dir}/lily-*.tex 2>/dev/null);',
68 'LILYPONDPREFIX=$LILYPONDPREFIX \
69 $PYTHON $LILYPOND_BOOK $__verbose \
70 --include=${TARGET.dir} $LILYPOND_BOOK_INCLUDES \
71 --process="$LILYPOND_BIN $LILYPOND_BOOK_INCLUDES" \
72 --output=${TARGET.dir} --format=$LILYPOND_BOOK_FORMAT \
73 $LILYPOND_BOOK_FLAGS \
75 TEXI = Builder (action = a, suffix = '.texi', src_suffix = '.tely')
76 env.Append (BUILDERS = {'TEXI': TEXI})
78 a = 'cd ${TARGET.dir} \
79 && texi2dvi --batch $TEXINFO_PAPERSIZE_OPTION ${SOURCE.file}'
80 texi2dvi = Builder (action = a, suffix = '.dvi', src_suffix = '.texi')
81 env.Append (BUILDERS = {'Texi2dvi': texi2dvi})
83 env.Append (DVIPSFLAGS = '-Ppdf -u+lilypond.map -u+ec-mftrace.map')
85 env ['DVIPS_PAPERSIZE'] = 'a4'
86 a = ['dvips $DVIPSFLAGS -o ${TARGET}.pdfps -t $DVIPS_PAPERSIZE $SOURCE',
87 'ps2pdf -sPAPERSIZE=$DVIPS_PAPERSIZE ${TARGET}.pdfps $TARGET']
88 dvi2pdf = Builder (action = a, suffix = '.pdf', src_suffix = '.dvi')
89 env.Append (BUILDERS = {'Dvi2pdf': dvi2pdf})
91 a = 'convert $SOURCE $TARGET'
92 png2eps = Builder (action = a, suffix = '.eps', src_suffix = '.png')
93 env.Append (BUILDERS = {'Png2eps': png2eps})
95 def add_ps_target (target, source, env):
96 base = os.path.splitext (str (target[0]))[0]
97 return (target + [base + '.ps'], source)
99 a = '${set__x}LILYPONDPREFIX=$LILYPONDPREFIX \
100 $PYTHON $LILYPOND_PY${__verbose} \
101 --include=${TARGET.dir} \
102 --output=${TARGET.base} $SOURCE'
103 lilypond = Builder (action = a, suffix = '.pdf', src_suffix = '.ly')
104 ## emitter = add_ps_target)
105 env.Append (BUILDERS = {'LilyPond': lilypond})
107 a = '${set__x}LILYPONDPREFIX=$LILYPONDPREFIX $PYTHON $ABC2LY_PY \
108 --strict --output=${TARGET} $SOURCE'
109 ABC = Builder (action = a, suffix = '.ly', src_suffix = '.abc')
110 env.Append (BUILDERS = {'ABC': ABC})
112 def add_log_target (target, source, env):
113 base = os.path.splitext (str (target[0]))[0]
114 return (target + [base + '.log'], source)
116 def add_enc_ly_tex_target (target, source, env):
117 base = os.path.splitext (str (target[0]))[0]
118 return (target + [base + '.enc', base + '.tex', base + 'list.ly'],
121 def add_suffixes (target, source, env, target_suffixes, src_suffixes):
122 base = os.path.splitext (str (target[0]))[0]
123 return (target + map (lambda x: base + x, target_suffixes),
124 source + map (lambda x: base + x, src_suffixes))
126 a = 'cd ${TARGET.dir} && \
127 MFINPUTS=.:${SOURCE.dir}:$srcdir/${SOURCE.dir} \
128 mf "\\mode:=$MFMODE; nonstopmode; input ${SOURCE.filebase};" \
130 tfm = Builder (action = a, suffix = '.tfm', src_suffix = '.mf',
131 # emitter = lambda t, s, e: add_suffixes (t, s, e, ['.log'], []))
132 emitter = add_log_target)
133 env.Append (BUILDERS = {'TFM': tfm})
135 a = '$PYTHON $MF_TO_TABLE_PY \
136 --outdir=${TARGET.dir} \
137 --afm=${TARGET.base}.afm \
138 --enc=${TARGET.base}.enc \
139 --tex=${TARGET.base}.tex \
140 --ly=${TARGET.base}list.ly \
142 afm = Builder (action = a, suffix = '.afm', src_suffix = '.log',
143 emitter = add_enc_ly_tex_target)
144 env.Append (BUILDERS = {'AFM': afm})
146 def add_enc_src (target, source, env):
147 base = os.path.splitext (str (target[0]))[0]
148 return (target, source + [base + '.enc'])
150 # UGH, should fix --output option for mftrace
151 # mftrace --verbose is too verbose
152 a = 'cd ${TARGET.dir} && \
153 if test -e ${SOURCE.filebase}.enc; then encoding="--encoding=${SOURCE.filebase}.enc"; fi; \
154 MFINPUTS=$srcdir/mf:.: \
155 mftrace --pfa --simplify --keep-trying $$encoding $TOO__verbose \
156 --include=${TARGET.dir} \
159 pfa = Builder (action = a,
162 emitter = add_enc_src)
163 env.Append (BUILDERS = {'PFA': pfa})
165 env['DIFF_PY'] = os.path.join (srcdir, 'stepmake/bin/package-diff.py')
166 a = '$PYTHON $DIFF_PY $__verbose --outdir=${TARGET.dir}'
167 patch = Builder (action = a, suffix = '.diff', src_suffix = '.tar.gz')
168 env.Append (BUILDERS = {'PATCH': patch})
170 def src_glob (env, s):
172 os.chdir (env.Dir ('.').srcnode ().abspath)
173 result = glob.glob (s)
176 env['src_glob'] = src_glob
178 def base_glob (env, s):
179 return map (lambda x: os.path.splitext (x)[0], src_glob (env, s))
180 env['glob'] = base_glob
192 'local_lilypond_datadir',
193 'local_lilypond_libdir',
209 def at_copy (target, source, env):
210 s = open (str (source[0])).read ()
213 s = string.replace (s, '@%s@'% i, env[i])
215 open (t, 'w').write (s)
217 if os.path.basename (os.path.dirname (str (target[0]))) == 'bin':
220 AT_COPY = Builder (action = at_copy, src_suffix = ['.in', '.py', '.sh',])
221 env.Append (BUILDERS = {'AT_COPY': AT_COPY})
223 MO = Builder (action = 'msgfmt -o $TARGET $SOURCE',
224 suffix = '.mo', src_suffix = '.po')
225 env.Append (BUILDERS = {'MO': MO})
227 ugh = 'ln -f po/lilypond.pot ${TARGET.dir}/lilypond.po; '
228 a = ugh + 'xgettext --default-domain=lilypond --join \
229 --output-dir=${TARGET.dir} --add-comments \
230 --keyword=_ --keyword=_f --keyword=_i $SOURCES'
231 PO = Builder (action = a, suffix = '.pot',
232 src_suffix = ['.cc', '.hh', '.py'], multi = 1)
233 ##env.Append (BUILDERS = {'PO': PO})
234 ##env.Command(env['absbuild'] + '/po/' + env['out'] + '/lilypond.pot',
235 env['potarget'] = os.path.join (env['absbuild'], 'po', env['out'],
239 ugh = '; mv ${TARGET} ${SOURCE}'
240 a = 'msgmerge ${SOURCE} ${SOURCE.dir}/lilypond.pot -o ${TARGET}' + ugh
241 POMERGE = Builder (action = a, suffix = '.pom', src_suffix = '.po')
242 env.Append (BUILDERS = {'POMERGE': POMERGE})
244 a = '$PYTHON $srcdir/buildscripts/bib2html.py -o $TARGET $SOURCE'
245 BIB2HTML = Builder (action = a, suffix = '.html', src_suffix = '.bib')
246 env.Append (BUILDERS = {'BIB2HTML': BIB2HTML})
248 a = '$PYTHON $srcdir/buildscripts/lys-to-tely.py \
249 --name=${TARGET.base} --title="$TITLE" $SOURCES'
250 LYS2TELY = Builder (action = a, suffix = '.tely', src_suffix = '.ly')
251 env.Append (BUILDERS = {'LYS2TELY': LYS2TELY})
254 def mutopia (ly = None, abc = None):
256 abc = env['glob'] (env, '*.abc')
258 ly = env['glob'] (env, '*.ly') + map (env.ABC, abc)
259 pdf = map (env.LilyPond, ly)
260 # We need lily and mf to build these.
261 env.Depends (pdf, ['#/lily', '#/mf'])
262 env.Alias ('doc', pdf)
264 env['mutopia'] = mutopia
267 def collate (title = 'collated files'):
268 ly = env['glob'] (env, '*.ly')
271 LILYPOND_BOOK_FLAGS = '''--process="lilypond-bin --header=texidoc -I$srcdir/input/test -e '(ly:set-option (quote internal-type-checking) #t)'"''',
272 __verbose = ' --verbose',
275 tely = e.LYS2TELY ('collated-files', ly)
277 # We need lily and mf to build these.
278 env.Depends (texi, ['#/lily', '#/mf'])
279 dvi = e.Texi2dvi (texi)
280 pdf = e.Dvi2pdf (dvi)
283 env.Alias ('doc', pdf)
284 env.Alias ('doc', html)
286 env['collate'] = collate