- def dir (x):
- if x and x[0] == '#':
- return srcdir + x[1:]
- return x
- return string.join (map (lambda x: prefix + dir (x), path), infix)
-
-verbose = verbose_opt (env, ' --verbose')
-MAKEINFO_INCLUDES = join_path (env['MAKEINFO_PATH'], '', ' -I')
-MAKEINFO = env['MAKEINFO']
-a = ('%(MAKEINFO)s%(verbose)s %(MAKEINFO_INCLUDES)s'\
- ' --no-split --no-headers --output=$TARGET $SOURCE') % vars ()
-texi2txt = Builder (action = a, suffix = '.txt', src_suffix = '.texi')
-env.Append (BUILDERS = {'Texi2txt': texi2txt})
-
-
-PYTHON = env['PYTHON']
-ABC2LY_PY = env['ABC2LY_PY']
-LILYPOND_PY = env['LILYPOND_PY']
-LILYPOND_BIN = env['LILYPOND_BIN']
-LILYPOND_BOOK = env['LILYPOND_BOOK']
-LILYPOND_BOOK_FLAGS = env['LILYPOND_BOOK_FLAGS']
-LILYPOND_BOOK_FORMAT = env['LILYPOND_BOOK_FORMAT']
-LILYPOND_BOOK_INCLUDES = join_path (env['LILYPOND_BOOK_PATH'], '',
- ' --include=')
-LILYPONDPREFIX = env['LILYPONDPREFIX']
-
-# UGHR, lilypond.py uses lilypond-bin from PATH
-#env.Append (ENV = {'PATH' : os.environ['PATH']})
-env.PrependENVPath ('PATH',
- os.path.join (env['absbuild'], env['out'], 'usr/bin'))
-
-if os.environ.has_key ('TEXMF'):
- env.Append (ENV = {'TEXMF' : os.environ['TEXMF']})
-env.Append (ENV = {'TEXMF' : '{' + LILYPONDPREFIX + ',' \
- + os.popen ('kpsexpand \$TEXMF').read ()[:-1] + '}' })
-
-if os.environ.has_key ('LD_LIBRARY_PATH'):
- env.Append (ENV = {'LD_LIBRARY_PATH' : os.environ['LD_LIBRARY_PATH']})
-if os.environ.has_key ('GUILE_LOAD_PATH'):
- env.Append (ENV = {'GUILE_LOAD_PATH' : os.environ['GUILE_LOAD_PATH']})
-
-env.Append (PYTHONPATH = [os.path.join (env['absbuild'], env['out'],
- 'usr/lib/python'),
- os.path.join (srcdir, 'buildscripts'),
- os.path.join (srcdir, 'python')])
-env.Append (ENV = { 'PYTHONPATH' : string.join (env['PYTHONPATH'],
- os.pathsep) } )
-
-verbose = verbose_opt (env, ' --verbose')
-a = (r'''rm -f $$(grep -LF '\lilypondend' ${TARGET.dir}/lily-*.tex 2>/dev/null); ''' \
- + 'LILYPONDPREFIX=%(LILYPONDPREFIX)s '\
- + '%(PYTHON)s %(LILYPOND_BOOK)s%(verbose)s'\
- + ' --include=${TARGET.dir} %(LILYPOND_BOOK_INCLUDES)s'\
- + r""" --process='%(LILYPOND_BIN)s %(LILYPOND_BOOK_INCLUDES)s'"""\
- + ' --output=${TARGET.dir} --format=%(LILYPOND_BOOK_FORMAT)s\
- %(LILYPOND_BOOK_FLAGS)s\
- $SOURCE') % vars ()
-tely2texi = Builder (action = a, suffix = '.texi', src_suffix = '.tely')
-env.Append (BUILDERS = {'Tely2texi': tely2texi})
-
-TEXINFO_PAPERSIZE_OPTION = env['TEXINFO_PAPERSIZE_OPTION']
-a = '(cd ${TARGET.dir} &&\
- texi2dvi --batch %(TEXINFO_PAPERSIZE_OPTION)s ${SOURCE.file})' % vars ()
-texi2dvi = Builder (action = a, suffix = '.dvi', src_suffix = '.texi')
-env.Append (BUILDERS = {'Texi2dvi': texi2dvi})
-
-env.Append (DVIPSFLAGS = '-Ppdf -u+lilypond.map -u+ec-mftrace.map')
-
-DVIPS_PAPERSIZE = 'a4'
-DVIPSFLAGS = env['DVIPSFLAGS']
-a = ('set -x; dvips %(DVIPSFLAGS)s' \
- + ' -o ${TARGET}.pdfps'\
- + ' -t %(DVIPS_PAPERSIZE)s $SOURCE &&'\
- + ' ps2pdf -sPAPERSIZE=%(DVIPS_PAPERSIZE)s ${TARGET}.pdfps $TARGET') \
- % vars ()
-dvi2pdf = Builder (action = a, suffix = '.pdf', src_suffix = '.dvi')
-env.Append (BUILDERS = {'Dvi2pdf': dvi2pdf})
-
-a = 'convert $SOURCE $TARGET'
-png2eps = Builder (action = a, suffix = '.eps', src_suffix = '.png')
-env.Append (BUILDERS = {'Png2eps': png2eps})
+ def dir (x):
+ if x and x[0] == '#':
+ return env['srcdir'] + x[1:]
+ return x
+ return string.join (map (lambda x: prefix + dir (x), path), infix)
+
+
+def src_glob (s):
+ here = os.getcwd ()
+ os.chdir (env.Dir ('.').srcnode ().abspath)
+ result = glob.glob (s)
+ os.chdir (here)
+ return result
+
+Export ('src_glob')
+
+def base_glob (s):
+ return map (lambda x: os.path.splitext (x)[0], src_glob (s))
+
+Export ('base_glob')
+
+def install (target, dir):
+ dest = env['DESTDIR'] + dir
+ if type (target) == type ([]):
+ map (lambda x: env.Install (dir, x), target)
+ else:
+ env.Install (dir, target)
+ env.Alias ('install', dir)
+
+Export ('install')
+
+def _fixme (s):
+ x = string.replace (s, '#', env['srcdir'])
+ x = string.replace (x, '@', env['absbuild'])
+ return x
+
+# Clean separation between generic action + flags and actual
+# configuration and flags in environment for this build.
+
+# Generic builders could/should be part of SCons.
+
+
+HH = Builder (action = 'bison -d -o ${TARGET.base}.cc $SOURCE',
+ suffix = '.hh', src_suffix = '.yy')
+env.Append (BUILDERS = {'HH' : HH})
+
+
+# Setup LilyPond environment. For the LilyPond build, we override
+# some of these commands in the ENVironment.
+
+lilypond_book_flags = '''--format=$LILYPOND_BOOK_FORMAT --process="lilypond -I$srcdir -I$srcdir/input/test $__verbose --backend=eps --formats=ps,png --header=texidoc -dinternal-type-checking -ddump-signatures -danti-alias-factor=2 -dgs-font-load" '''
+
+env.Append (
+ BSTINPUTS = '${SOURCE.dir}:${TARGET.dir}:',
+ BIB2HTML = '$PYTHON $srcdir/buildscripts/bib2html.py',
+ LILYOND_BOOK = 'lilypond-book',
+ LILYPOND_BOOK_FORMAT = '',
+ LILYPOND_BOOK_FLAGS = lilypond_book_flags,
+ LILYPOND_PATH = [],
+ # The SCons way around FOO_PATH:
+ LILYPOND_INCFLAGS = '$( ${_concat(INCPREFIX, LILYPOND_PATH, INCSUFFIX, __env__)} $)',
+
+ MAKEINFO_PATH = [],
+ MAKEINFO_FLAGS = [],
+ MAKEINFO_INCFLAGS = '$( ${_concat(INCPREFIX, MAKEINFO_PATH, INCSUFFIX, __env__, RDirs)} $)',
+ #TEXI2DVI_FLAGS = [],
+ _TEXI2DVI_FLAGS = '$( ${_concat(" ", TEXI2DVI_FLAGS,)} $)',
+ )
+
+TXT =\
+ Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCFLAGS\
+ --no-split --no-headers $SOURCE',
+ suffix = '.txt', src_suffix = '.texi')
+env.Append (BUILDERS = {'TXT': TXT})
+
+INFO =\
+ Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCFLAGS $SOURCE',
+ suffix = '.info', src_suffix = '.texi')
+env.Append (BUILDERS = {'INFO': INFO})
+
+HTML =\
+ Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCLUDES\
+ --html --no-split --no-headers $MAKEINFO_FLAGS $SOURCE',
+suffix = '.html', src_suffix = '.texi')
+env.Append (BUILDERS = {'HTML': HTML})
+
+TEXI =\
+ Builder (action =
+ '$LILYPOND_BOOK --output=${TARGET.dir} \
+ --include=${TARGET.dir} $LILYPOND_INCFLAGS \
+ --process="$LILYPOND $LILYPOND_INCFLAGS" \
+ $LILYPOND_BOOK_FLAGS \
+ $SOURCE',
+ suffix = '.texi', src_suffix = '.tely')
+env.Append (BUILDERS = {'TEXI': TEXI})
+
+TEXIDVI =\
+ Builder (action = 'cd ${TARGET.dir} && \
+ texi2dvi --batch -I $srcdir/Documentation/user $_TEXI2DVI_FLAGS ${SOURCE.file}',
+ suffix = '.dvi', src_suffix = '.texi')
+env.Append (BUILDERS = {'TEXIDVI': TEXIDVI})
+
+DVIPS =\
+ Builder (action = 'TEXINPUTS=${TARGET.dir}:$$TEXINPUTS $DVIPS -o $TARGET $DVIPS_FLAGS $SOURCE',
+ suffix = '.ps', src_suffix = '.dvi')
+env.Append (BUILDERS = {'DVIPS': DVIPS})
+
+DVIPDF =\
+ Builder (action = 'TEXINPUTS=${TARGET.dir}:$$TEXINPUTS $DVIPS -o $TARGET -Ppdf $DVIPS_FLAGS $SOURCE',
+ suffix = '.pdfps', src_suffix = '.dvi')
+env.Append (BUILDERS = {'DVIPDF': DVIPDF})
+
+PSPDF =\
+ Builder (action = 'ps2pdf $PSPDF_FLAGS $SOURCE $TARGET',
+ suffix = '.pdf', src_suffix = '.pdfps')
+env.Append (BUILDERS = {'PSPDF': PSPDF})
+
+PNG2EPS =\
+ Builder (action = 'convert $SOURCE $TARGET',
+ suffix = '.eps', src_suffix = '.png')
+env.Append (BUILDERS = {'PNG2EPS': PNG2EPS})
+
+EPS2PNG =\
+ Builder (action = 'convert $SOURCE $TARGET',
+ suffix = '.png', src_suffix = '.eps')
+env.Append (BUILDERS = {'EPS2PNG': EPS2PNG})