4 Experimental scons (www.scons.org) building:
12 scons build=DIR # scrdir build, write to new tree =build
13 scons out=DIR # write output to deeper dir DIR
15 Optionally, make a custom.py. I have
29 # *, Documentation, ly etc.
40 # put your favourite stuff in custom.py
41 opts = Options ('custom.py', ARGUMENTS)
42 opts.Add ('prefix', 'Install prefix', '/usr/')
43 opts.Add ('out', 'Output directory', 'out-scons')
44 opts.Add ('build', 'Build directory', '.')
46 BoolOption ('warnings', 'compile with -Wall and similiar',
48 BoolOption ('debugging', 'compile with debugging symbols',
50 BoolOption ('optimising', 'compile with optimising',
52 BoolOption ('shared', 'build shared libraries',
54 BoolOption ('static', 'build static libraries',
58 Help (opts.GenerateHelpText (env))
60 env = Environment (options = opts)
62 env.CacheDir (os.path.join (env['build'], '=build-cache'))
65 sys.path.append (os.path.join ('.', 'stepmake', 'bin'))
67 package = packagepython.Package ('.')
69 env['version'] = packagepython.version_tuple_to_str (package.version)
70 env['bindir'] = os.path.join (env['prefix'], 'bin')
71 env['sharedir'] = os.path.join (env['prefix'], 'share')
72 env['libdir'] = os.path.join (env['prefix'], 'lib')
73 env['lilypondprefix'] = os.path.join (env['sharedir'], 'lilypond',
77 env.Append (CFLAGS = '-g')
78 env.Append (CXXFLAGS = '-g')
80 env.Append (CFLAGS = '-O2')
81 env.Append (CXXFLAGS = '-O2')
82 env.Append (CXXFLAGS = '-DSTRING_UTILS_INLINED')
84 env.Append (CFLAGS = '-W ')
85 env.Append (CFLAGS = '-Wall')
86 # what about = ['-W', '-Wall', ...]?
87 env.Append (CXXFLAGS = '-W')
88 env.Append (CXXFLAGS = '-Wall')
89 env.Append (CXXFLAGS = '-Wconversion')
91 env['MFMODE'] = 'ljfour'
93 conf = Configure (env)
95 #ugh -- hardcode territory
100 '2PACKAGE': '"lilypond"',
101 '3TOPLEVEL_VERSION' : '"2.3.6"',
102 '4DATADIR' : '"' + os.getcwd () + '/share"',
103 '5PACKAGE_DATADIR': 'DATADIR "/" PACKAGE',
104 '6LILYPOND_DATADIR' : 'PACKAGE_DATADIR',
105 '7LOCAL_PACKAGE_DATADIR' : 'PACKAGE_DATADIR "/" TOPLEVEL_VERSION',
106 '8LOCAL_LILYPOND_DATADIR' : 'LOCAL_PACKAGE_DATADIR',
107 '9LOCALEDIR' : '"' + os.getcwd () + '/share/locale"',
110 headers = ('sys/stat.h', 'assert.h', 'kpathsea/kpathsea.h')
112 if conf.CheckCHeader (i):
113 key = re.sub ('[./]', '_', 'zHAVE_' + string.upper (i))
116 ccheaders = ('sstream',)
118 if conf.CheckCXXHeader (i):
119 key = re.sub ('[./]', '_', 'zHAVE_' + string.upper (i))
122 functions = ('gettext', 'isinf', 'memmem', 'snprintf', 'vsnprintf')
124 if 0 or conf.CheckFunc (i):
125 key = re.sub ('[./]', '_', 'zHAVE_' + string.upper (i))
129 key = 'zHAVE_FLEXLEXER_YY_CURRENT_BUFFER'
130 defines[key] = conf.TryCompile ("""using namespace std;
131 #include <FlexLexer.h>
132 class yy_flex_lexer: public yyFlexLexer
137 yy_current_buffer = 0;
141 if conf.CheckLib ('dl'):
144 if conf.CheckLib ('kpathsea'):
145 defines['zKPATHSEA'] = '1'
148 if conf.CheckLib ('kpathsea', 'kpse_find_file'):
149 defines['zHAVE_KPSE_FIND_FILE'] = '1'
155 #this could happen after flower...
156 env.ParseConfig ('guile-config compile')
160 ##reldir = str (Dir ('.').srcnode ())
161 reldir = os.getcwd ()
162 outdir = os.path.join (env['build'], reldir, env['out'])
163 if not os.path.exists (outdir):
166 config = open (os.path.join (outdir, 'config.h'), 'w')
167 sort_helper = defines.keys ()
169 for i in sort_helper:
170 config.write ('#define %s %s\n' % (i[1:], defines[i]))
173 os.system (sys.executable \
174 + ' ./stepmake/bin/make-version.py VERSION > '\
175 + os.path.join (outdir, 'version.hh'))
177 if os.path.exists ('parser'):
178 env.Append (LIBPATH = ['#/flower', '#/lily', '#/parser', '#/gui',],
179 CPPPATH = [outdir, '#',])
181 env.Append (LIBPATH = ['#/flower/' + out,],
182 CPPPATH = [outdir, '#',])
184 def get_version (program):
185 command = '(%(program)s --version || %(program)s -V) 2>&1' % vars ()
186 output = os.popen (command).readline ()[:-1]
187 v = re.sub ('^.*[^-.0-9]([0-9][0-9]*\.[0-9][.0-9]*).*$', '\\1', output)
188 return string.split (v, '.')
190 def assert_version (program, minimal, description, package):
192 sys.stdout.write ('Checking %s version... ' % program)
193 actual = get_version (program)
194 sys.stdout.write (string.join (actual, '.'))
195 sys.stdout.write ('\n')
196 if actual < string.split (minimal, '.'):
197 required.append ((description, package,
198 string.join (minimal, '.'),
200 string.join (actual, '.')))
203 assert_version ('gcc', '3.0.5', 'GNU C compiler', 'gcc')
204 assert_version ('makeinfo', '4.7', 'Makeinfo tool', 'texinfo')
208 print '********************************'
209 print 'Please install required packages'
211 print '%s: %s-%s or newer (found: %s-%s)' % i
214 #subdirs = ('flower', 'lily', 'parser', 'gui', 'main',)
215 subdirs = ('flower', 'lily', 'mf')
217 b = os.path.join (build, d, out)
218 # Support clean sourctree build (srcdir build)
220 # TODO: figure out SConscript (dir, builddir, duplicate)) feature
221 if (build and build != '.') \
222 or (out and out != '.'):
223 env.BuildDir (b, d, duplicate=0)
224 SConscript (os.path.join (b, 'SConscript'))