+#urg how does #/ subst work?
+Export ('env')
+SConscript ('buildscripts/builder.py')
+
+env.PrependENVPath ('PATH',
+ os.path.join (env['absbuild'], env['out'], 'usr/bin'))
+
+LILYPONDPREFIX = os.path.join (run_prefix, 'share/lilypond/', version)
+
+env.Append (ENV = {
+ #'LILYPONDPREFIX' : os.path.join (run_prefix, 'share/lilypond/', version),
+ 'LILYPONDPREFIX' : LILYPONDPREFIX,
+ # ugh, can't use LILYPONDPREFIX here
+ #'TEXMF' : '{' + os.path.join (run_prefix, 'share/lilypond/', version)\
+ #+ ',' \
+ 'TEXMF' : '{$LILYPONDPREFIX,'
+ + os.popen ('kpsexpand \$TEXMF').read ()[:-1] + '}',
+ })
+
+BUILD_ABC2LY = '${set__x}$PYTHON $srcdir/scripts/abc2ly.py'
+BUILD_LILYPOND = '$absbuild/lily/$out/lilypond ${__verbose}'
+BUILD_LILYPOND_BOOK = '$PYTHON $srcdir/scripts/lilypond-book.py ${__verbose}'
+
+
+# post-option environment-update
+env.Append (
+ bindir = bindir,
+ sharedir = sharedir,
+ lilypond_datadir = sharedir_package,
+ localedir = localedir,
+ local_lilypond_datadir = sharedir_package_version,
+ lilypondprefix = lilypondprefix,
+ sharedir_package = sharedir_package,
+ sharedir_doc_package = sharedir_doc_package,
+ sharedir_package_version = sharedir_package_version,
+
+ # global build verbosity switch
+ __verbose = ' --verbose',
+
+ LILYPOND = BUILD_LILYPOND,
+ ABC2LY = BUILD_ABC2LY,
+ LILYPOND_BOOK = BUILD_LILYPOND_BOOK,
+ LILYPOND_BOOK_FORMAT = 'texi-html',
+ MAKEINFO_FLAGS = '--css-include=$srcdir/Documentation/texinfo.css',
+ # should not be necessary
+ # PYTHONPATH = ['$absbuild/python/$out'],
+ TEXI2DVI_PAPERSIZE = '@afourpaper',
+ TEXI2DVI_FLAGS = [ '-t$TEXI2DVI_PAPERSIZE'],
+ DVIPS_PAPERSIZE = 'a4',
+ DVIPS_FLAGS = ['-t$DVIPS_PAPERSIZE',
+ '-u+lilypond.map',
+ '-u+ec-mftrace.map'],
+ PSPDF_FLAGS = ['-sPAPERSIZE=$DVIPS_PAPERSIZE'],
+ )
+
+env.Append (CCFLAGS = ['-pipe', '-Wno-pmf-conversions'])
+if env['debugging']:
+ env.Append (CCFLAGS = ['-g'])
+if env['optimising']:
+ env.Append (CCFLAGS = '-O2')
+ env.Append (CXXFLAGS = ['-DSTRING_UTILS_INLINED'])
+if env['warnings']:
+ env.Append (CCFLAGS = ['-W', '-Wall'])
+ env.Append (CXXFLAGS = ['-Wconversion'])
+
+# ugr,huh?
+env.Append (LINKFLAGS = ['-Wl,--export-dynamic'])
+# FIXME: ParseConfig ignores -L flag?
+env.Append (LINKFLAGS = ['-L/usr/X11R6/lib'])
+
+if env['verbose']:
+ env['__verbose'] = ' --verbose'
+ env['set__x'] = 'set -x;'
+
+
+## Explicit target and dependencies
+
+if 'clean' in COMMAND_LINE_TARGETS:
+ # ugh: prevent reconfigure instead of clean
+ os.system ('touch %s' % config_cache)
+
+ command = sys.argv[0] + ' -c .'
+ sys.stdout.write ('Running %s ... ' % command)
+ sys.stdout.write ('\n')
+ s = os.system (command)
+ if os.path.exists (config_cache):
+ os.unlink (config_cache)
+ Exit (s)
+
+if 'sconsclean' in COMMAND_LINE_TARGETS:
+ command = 'rm -rf scons.cache $(find . -name ".scon*")'
+ s = os.system (command)
+ if os.path.exists (config_cache):
+ os.unlink (config_cache)
+ Exit (s)
+
+if 'realclean' in COMMAND_LINE_TARGETS:
+ command = 'rm -rf $(find . -name "out-scons" -o -name ".scon*")'
+ sys.stdout.write ('Running %s ... ' % command)
+ sys.stdout.write ('\n')
+ s = os.system (command)
+ if os.path.exists (config_cache):
+ os.unlink (config_cache)
+ Exit (s)
+
+# Declare SConscript phonies
+env.Alias ('minimal', config_cache)
+env.Alias ('mf-essential', config_cache)
+
+env.Alias ('minimal', ['lily', 'mf-essential'])
+env.Alias ('all', ['minimal', 'mf', '.'])
+# Do we want the doc/web separation?
+env.Alias ('doc',
+ ['Documentation',
+ 'Documentation/user',
+ 'Documentation/topdocs',
+ 'Documentation/bibliography',
+ 'input'])
+
+# Without target arguments, do minimal build
+if not COMMAND_LINE_TARGETS:
+ env.Default (['minimal'])
+
+# GNU Make rerouting compat:
+env.Alias ('web', 'doc')
+
+