+def at_copy_ext (target, source, env):
+ n = str (source[0])
+ s = open (n).read ()
+ for i in atvars:
+ if env.has_key (i):
+ s = string.replace (s, '@%s@'% i, env[i])
+ # whugh
+ e = os.path.splitext (n)[1]
+ t = str (target[0]) + e
+ open (t, 'w').write (s)
+
+AT_COPY_EXT = Builder (action = at_copy_ext, src_suffix = ['.py', '.sh',])
+env.Append (BUILDERS = {'AT_COPY_EXT': AT_COPY_EXT})
+
+
+MO = Builder (action = 'msgfmt -o $TARGET $SOURCE',
+ suffix = '.mo', src_suffix = '.po')
+env.Append (BUILDERS = {'MO': MO})
+
+ugh = 'ln -f po/lilypond.pot ${TARGET.dir}/lilypond.po ; '
+a = ugh + 'xgettext --default-domain=lilypond --join \
+--output-dir=${TARGET.dir} --add-comments \
+--keyword=_ --keyword=_f --keyword=_i $SOURCES'
+PO = Builder (action = a, suffix = '.pot',
+ src_suffix = ['.cc', '.hh', '.py'], multi = 1)
+env['potarget'] = os.path.join (env['absbuild'], 'po', env['out'],
+ 'lilypond.pot')
+env['pocommand'] = a
+
+ugh = '; mv ${TARGET} ${SOURCE}'
+a = 'msgmerge ${SOURCE} ${SOURCE.dir}/lilypond.pot -o ${TARGET}' + ugh
+POMERGE = Builder (action = a, suffix = '.pom', src_suffix = '.po')
+env.Append (BUILDERS = {'POMERGE': POMERGE})
+
+a = 'BSTINPUTS=$BSTINPUTS $BIB2HTML -o $TARGET $SOURCE'
+BIB2HTML = Builder (action = a, suffix = '.html', src_suffix = '.bib')
+env.Append (BUILDERS = {'BIB2HTML': BIB2HTML})
+
+a = '$PYTHON $srcdir/buildscripts/lys-to-tely.py \
+--name=${TARGET.base} --title="$TITLE" $SOURCES'
+LYS2TELY = Builder (action = a, suffix = '.tely', src_suffix = '.ly')
+env.Append (BUILDERS = {'LYS2TELY': LYS2TELY})
+
+
+def mutopia (ly=None, abc=None):
+ e = env.Copy (
+ LILYPOND_BOOK_FLAGS = lilypond_book_flags,
+ )
+
+ if not abc:
+ abc = base_glob ('*.abc')
+ if not ly:
+ ly = base_glob ('*.ly') + map (e.ABC, abc)
+ pdf = map (e.LilyPond, ly)
+ env.Depends (pdf, ['#/lily', '#/mf'])
+ env.Alias ('doc', pdf)
+
+Export ('mutopia')
+
+def collate (title = 'collated files'):
+ ly = base_glob ('*.ly')
+
+ e = env.Copy (
+ TITLE = title,
+ LILYPOND_BOOK_FLAGS = lilypond_book_flags,
+ # __verbose = ' --verbose',
+ )
+ tely = e.LYS2TELY ('collated-files', ly)
+ texi = e.TEXI (tely)
+ env.Depends (texi, ['#/lily', '#/mf'])
+ dvi = e.TEXIDVI (texi)
+ pspdf = e.DVIPDF (dvi)
+ pdf = e.PSPDF (pspdf)
+ html = e.HTML (texi)
+
+ env.Alias ('doc', pdf)
+ env.Alias ('doc', html)
+
+Export ('collate')
+
+Export ('env')