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
22 os.path.join (os.getcwd (), '=install')
28 # * running from build-dir, without installing?
29 # - scons will not install, if PREFIX lives outside of CWD
30 # - build symlink tree
31 # + mimicking regular installation setup?
32 # + use tweaked scons 'install' target?
33 # * commandline targets:
35 # - dist, tar => env.Tar
36 # * Documentation, scripts
38 # * more fine-grained config.h -- move lilypondprefix to version.hh?
39 # - config.h: changes after system upgrades, affects all files
40 # - version.hh: prefix, version etc? affects few
50 # put your favourite stuff in custom.py
51 opts = Options ('custom.py', ARGUMENTS)
52 opts.Add ('prefix', 'Install prefix', '/usr/')
53 opts.Add ('out', 'Output directory', 'out-scons')
54 opts.Add ('build', 'Build directory', '.')
56 BoolOption ('warnings', 'compile with -Wall and similiar',
58 BoolOption ('debugging', 'compile with debugging symbols',
60 BoolOption ('optimising', 'compile with optimising',
62 BoolOption ('shared', 'build shared libraries',
64 BoolOption ('static', 'build static libraries',
66 BoolOption ('gui', 'build with GNOME backend (EXPERIMENTAL)',
68 BoolOption ('verbose', 'run commands with verbose flag',
72 Help (opts.GenerateHelpText (env))
74 env = Environment (options = opts)
76 env.CacheDir (os.path.join (env['build'], '=build-cache'))
79 sys.path.append (os.path.join ('.', 'stepmake', 'bin'))
81 package = packagepython.Package ('.')
83 env['version'] = packagepython.version_tuple_to_str (package.version)
84 env['bindir'] = os.path.join (env['prefix'], 'bin')
85 env['sharedir'] = os.path.join (env['prefix'], 'share')
86 env['libdir'] = os.path.join (env['prefix'], 'lib')
87 env['localedir'] = os.path.join (env['sharedir'], 'locale')
89 env['sharedir_package'] = os.path.join (env['sharedir'], package.name)
90 env['sharedir_package_version'] = os.path.join (env['sharedir_package'],
92 env['lilypondprefix'] = os.path.join (env['sharedir_package_version'])
96 env.Append (CFLAGS = '-g')
97 env.Append (CXXFLAGS = '-g')
99 env.Append (CFLAGS = '-O2')
100 env.Append (CXXFLAGS = '-O2')
101 env.Append (CXXFLAGS = '-DSTRING_UTILS_INLINED')
103 env.Append (CFLAGS = '-W ')
104 env.Append (CFLAGS = '-Wall')
105 # what about = ['-W', '-Wall', ...]?
106 env.Append (CXXFLAGS = '-W')
107 env.Append (CXXFLAGS = '-Wall')
108 env.Append (CXXFLAGS = '-Wconversion')
110 env['MFMODE'] = 'ljfour'
113 conf = Configure (env)
116 vre = re.compile ('^.*[^-.0-9]([0-9][0-9]*\.[0-9][.0-9]*).*$', re.DOTALL)
117 def get_version (program):
118 command = '(%(program)s --version || %(program)s -V) 2>&1' % vars ()
119 pipe = os.popen (command)
120 output = pipe.read ()
123 v = re.sub (vre, '\\1', output)
124 return string.split (v, '.')
126 def assert_version (lst, program, minimal, description, package):
128 sys.stdout.write ('Checking %s version... ' % program)
129 actual = get_version (program)
132 lst.append ((description, package, minimal, program,
135 sys.stdout.write (string.join (actual, '.'))
136 sys.stdout.write ('\n')
137 if actual < string.split (minimal, '.'):
138 lst.append ((description, package, minimal, program,
139 string.join (actual, '.')))
142 assert_version (required, 'gcc', '2.8', 'GNU C compiler', 'gcc')
143 assert_version (required, 'g++', '3.0.5', 'GNU C++ compiler', 'g++')
144 assert_version (required, 'python', '2.1', 'Python (www.python.org)', 'python')
145 assert_version (required, 'guile-config', '1.6', 'GUILE development',
146 'libguile-dev or guile-devel')
147 # Do not use bison 1.50 and 1.75.
148 assert_version (required, 'bison', '1.25', 'Bison -- parser generator',
150 assert_version (required, 'flex', '0.0', 'Flex -- lexer generator', 'flex')
154 assert_version (optional, 'makeinfo', '4.7', 'Makeinfo tool', 'texinfo')
155 assert_version (optional, 'guile', '1.6', 'GUILE scheme',
156 'libguile-dev or guile-devel')
157 assert_version (optional, 'mftrace', '1.0.27', 'Metafont tracing Type1',
159 assert_version (optional, 'perl', '4.0',
160 'Perl practical efficient readonly language', 'perl')
161 #assert_version (optional, 'foo', '2.0', 'Foomatic tester', 'bar')
167 'TOPLEVEL_VERSION' : '"' + env['version'] + '"',
168 'PACKAGE': '"' + package.name + '"',
169 'DATADIR' : '"' + env['sharedir'] + '"',
170 'LILYPOND_DATADIR' : '"' + env['sharedir_package'] + '"',
171 'LOCAL_LILYPOND_DATADIR' : '"' + env['sharedir_package_version'] + '"',
172 'LOCALEDIR' : '"' + env['localedir'] + '"',
176 command = r"""python -c 'import sys; sys.stdout.write ("%s/include/python%s" % (sys.prefix, sys.version[:3]))'""" #"
177 PYTHON_INCLUDE = os.popen (command).read ()
178 env.Append (CPPPATH = PYTHON_INCLUDE)
181 headers = ('sys/stat.h', 'assert.h', 'kpathsea/kpathsea.h', 'Python.h')
183 if conf.CheckCHeader (i):
184 key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
187 ccheaders = ('sstream',)
189 if conf.CheckCXXHeader (i):
190 key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
193 functions = ('gettext', 'isinf', 'memmem', 'snprintf', 'vsnprintf')
195 if 0 or conf.CheckFunc (i):
196 key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
200 key = 'HAVE_FLEXLEXER_YY_CURRENT_BUFFER'
201 defines[key] = conf.TryCompile ("""using namespace std;
202 #include <FlexLexer.h>
203 class yy_flex_lexer: public yyFlexLexer
208 yy_current_buffer = 0;
212 if conf.CheckLib ('dl'):
215 if conf.CheckLib ('kpathsea'):
216 defines['KPATHSEA'] = '1'
219 if conf.CheckLib ('kpathsea', 'kpse_find_file'):
220 defines['HAVE_KPSE_FIND_FILE'] = '1'
221 if conf.CheckLib ('kpathsea', 'kpse_find_tfm'):
222 defines['HAVE_KPSE_FIND_TFM'] = '1'
224 #this could happen after flower...
225 env.ParseConfig ('guile-config compile')
227 #this could happen only for compiling pango-*
229 env.ParseConfig ('pkg-config --cflags --libs gtk+-2.0')
230 env.ParseConfig ('pkg-config --cflags --libs pango')
231 if conf.CheckCHeader ('pango/pangofc-fontmap.h'):
232 defines['HAVE_PANGO_PANGOFC_FONTMAP_H'] = '1'
234 if conf.CheckLib ('pango-1.0',
235 'pango_fc_font_map_add_decoder_find_func'):
236 defines['HAVE_PANGO_CVS'] = '1'
237 defines['HAVE_PANGO_FC_FONT_MAP_ADD_DECODER_FIND_FUNC'] = '1'
243 ##reldir = str (Dir ('.').srcnode ())
244 reldir = os.getcwd ()
245 outdir = os.path.join (env['build'], reldir, env['out'])
246 if not os.path.exists (outdir):
254 config = open (os.path.join (outdir, 'config.h'), 'w')
255 for i in list_sort (defines.keys ()):
256 config.write ('#define %s %s\n' % (i, defines[i]))
259 os.system (sys.executable \
260 + ' ./stepmake/bin/make-version.py VERSION > '\
261 + os.path.join (outdir, 'version.hh'))
263 if os.path.exists ('parser'):
264 env.Append (LIBPATH = ['#/flower', '#/lily', '#/parser', '#/gui',],
265 CPPPATH = [outdir, '#',])
267 env.Append (LIBPATH = ['#/flower/' + out,],
268 CPPPATH = [outdir, '#',])
272 print '********************************'
273 print 'Please install required packages'
275 print '%s: %s-%s or newer (found: %s %s)' % i
280 print '*************************************'
281 print 'Consider installing optional packages'
283 print '%s: %s-%s or newer (found: %s %s)' % i
285 #env['tarball'] = os.path.join (outdir,
286 # package.name + '-' + env['version'] + '.tar.gz')
288 env['tarball'] = os.path.join ('~/tmp',
289 package.name + '-' + env['version'] + '.tar.gz')
294 #subdirs = ['flower', 'lily', 'parser', 'gui', 'main',]
295 subdirs = ['flower', 'lily', 'mf', 'scm', 'ly']
297 b = os.path.join (build, d, out)
298 # Support clean sourctree build (srcdir build)
300 # TODO: figure out SConscript (dir, builddir, duplicate)) feature
301 if (build and build != '.') \
302 or (out and out != '.'):
303 env.BuildDir (b, d, duplicate=0)
304 SConscript (os.path.join (b, 'SConscript'))
307 readmes = ['AUTHORS.txt', 'ChangeLog', 'NEWS.txt']
310 env.Append (TARFLAGS = '-z --owner=0 --group=0')
311 env.Append (GZIPFLAGS = '-9')
312 all_sources = ['SConstruct',] + readmes + subdirs
313 x = env.Tar (env['tarball'], all_sources)