# -*-python-*-
-import glob
+Import ('env')
-sources = glob.glob ('*.cc') + ['parser.yy', 'lexer.ll']
-name = 'lyparser'
+outdir = Dir ('.').abspath
+cc_sources = env['src_glob'] (env, '*.cc')
+sources = cc_sources + ['parser.yy', 'lexer.ll']
+includes = env['src_glob'] (env, 'include/*.hh')
-Import ('env')
e = env.Copy ()
+e.Append (CPPPATH = [outdir, '#/lily/include', '#/flower/include'])
+e.Append (LEXFLAGS = ['-Cfe', '-p', '-p'])
+
+# SCons builds parser.cc and parser.hh automagically with this but
+# keeps removing and rebuilding parser.cc because it wants parser.hpp.
+# e.Append (YACCFLAGS = '-d')
+# e.Depends ('lexer.cc', 'parser.cc')
+# e.Depends ('my-lily-lexer.o', 'parser.cc')
+# e.Depends ('my-lily-parser.o', 'parser.cc')
+
+# Adding an explicit Builder works well, we do not even need to list
+# header dependencies.
+HH = Builder (action = 'bison -d -o ${TARGET.base}.cc $SOURCE',
+ suffix = '.hh', src_suffix = '.yy')
+e.Append (BUILDERS = {'HH' : HH})
+e.HH ('parser.hh', 'parser.yy')
-e.Append (YACCFLAGS = '-d')
-e.Append (CPPPATH = ['include', '#/lily/include', '#/flower/include'])
-e.Depends ('lexer.cc', 'parser.cc')
+e.Append (LIBS = ['flower'])
+e.ParseConfig ('guile-config link')
+name = 'lilypond-bin'
+lily = e.Program (name, sources)
+env.Install (env['bindir'], lily)
+env.Alias ('install', env['bindir'])
-# some stuff here from lily-as-lib
-if os.path.exists ('main.cc'):
- if env['static']:
- e.Library (name, sources)
- if not env['static'] or ['shared']:
- e.SharedLibrary (name, sources)
-else:
- #e.Append (LIBS = ['lygui', 'lyparser', 'lily', 'flower'])
- e.Append (LIBS = ['flower'])
- e.ParseConfig ('guile-config link')
- name = 'lilypond-bin'
- e.Program (name, sources)
+po = env.Command ('lilypond.po', cc_sources + includes, env['pocommand'])
+env.Alias ('po-update', po)