- vre = re.compile ('^.*[^-.0-9]([0-9][0-9]*\.[0-9][.0-9]*).*$', re.DOTALL)
- def get_version (program):
- command = '(%(program)s --version || %(program)s -V) 2>&1' % vars ()
- pipe = os.popen (command)
- output = pipe.read ()
- if pipe.close ():
- return None
- v = re.sub (vre, '\\1', output)
- return string.split (v, '.')
-
- def test_program (lst, program, minimal, description, package):
- sys.stdout.write ('Checking %s version... ' % program)
- actual = get_version (program)
- if not actual:
- print 'not found'
- lst.append ((description, package, minimal, program,
- 'not installed'))
- return
- sys.stdout.write (string.join (actual, '.'))
- sys.stdout.write ('\n')
- if actual < string.split (minimal, '.'):
- lst.append ((description, package, minimal, program,
- string.join (actual, '.')))
-
- required = []
- test_program (required, 'gcc', '2.8', 'GNU C compiler', 'gcc')
- test_program (required, 'g++', '3.0.5', 'GNU C++ compiler', 'g++')
- test_program (required, 'python', '2.1', 'Python (www.python.org)', 'python')
- test_program (required, 'guile-config', '1.6', 'GUILE development',
- 'libguile-dev or guile-devel')
- # Do not use bison 1.50 and 1.75.
- test_program (required, 'bison', '1.25', 'Bison -- parser generator',
- 'bison')
- test_program (required, 'flex', '0.0', 'Flex -- lexer generator', 'flex')
-
-
- optional = []
- test_program (optional, 'makeinfo', '4.7', 'Makeinfo tool', 'texinfo')
- test_program (optional, 'guile', '1.6', 'GUILE scheme',
- 'libguile-dev or guile-devel')
- test_program (optional, 'mftrace', '1.0.27', 'Metafont tracing Type1',
- 'mftrace')
- test_program (optional, 'perl', '4.0',
- 'Perl practical efficient readonly language', 'perl')
- #test_program (optional, 'foo', '2.0', 'Foomatic tester', 'bar')
-
- def CheckYYCurrentBuffer (context):
- context.Message ('Checking for yy_current_buffer... ')
- ret = conf.TryCompile ("""using namespace std;
- #include <FlexLexer.h>
- class yy_flex_lexer: public yyFlexLexer
- {
- public:
- yy_flex_lexer ()
- {
- yy_current_buffer = 0;
- }
- };""", '.cc')
- context.Result (ret)
- return ret
-
- conf = Configure (env, custom_tests = { 'CheckYYCurrentBuffer'
- : CheckYYCurrentBuffer })
-
- defines = {
- 'DIRSEP' : "'/'",
- 'PATHSEP' : "':'",
- 'TOPLEVEL_VERSION' : '"' + version + '"',
- 'PACKAGE': '"' + package.name + '"',
- 'DATADIR' : '"' + sharedir + '"',
- 'LILYPOND_DATADIR' : '"' + sharedir_package + '"',
- 'LOCAL_LILYPOND_DATADIR' : '"' + sharedir_package_version + '"',
- 'LOCALEDIR' : '"' + localedir + '"',
- }
- conf.env.Append (DEFINES = defines)
-
- command = r"""python -c 'import sys; sys.stdout.write ("%s/include/python%s" % (sys.prefix, sys.version[:3]))'""" #"
- PYTHON_INCLUDE = os.popen (command).read ()
- env.Append (CPPPATH = PYTHON_INCLUDE)
-
- headers = ('sys/stat.h', 'assert.h', 'kpathsea/kpathsea.h', 'Python.h')
- for i in headers:
- if conf.CheckCHeader (i):
- key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
- conf.env['DEFINES'][key] = 1
-
- ccheaders = ('sstream',)
- for i in ccheaders:
- if conf.CheckCXXHeader (i):
- key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
- conf.env['DEFINES'][key] = 1
-
- functions = ('gettext', 'isinf', 'memmem', 'snprintf', 'vsnprintf')
- for i in functions:
- if 0 or conf.CheckFunc (i):
- key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
- conf.env['DEFINES'][key] = 1
-
- if conf.CheckYYCurrentBuffer ():
- conf.env['DEFINES']['HAVE_FLEXLEXER_YY_CURRENT_BUFFER'] = 1
-
- if conf.CheckLib ('dl'):
- pass
-
- if conf.CheckLib ('kpathsea'):
- conf.env['DEFINES']['KPATHSEA'] = 1
-
- # huh?
- if conf.CheckLib ('kpathsea', 'kpse_find_file'):
- conf.env['DEFINES']['HAVE_KPSE_FIND_FILE'] = '1'
- if conf.CheckLib ('kpathsea', 'kpse_find_tfm'):
- conf.env['DEFINES']['HAVE_KPSE_FIND_TFM'] = '1'
-
- #this could happen after flower...
- env.ParseConfig ('guile-config compile')
-
- #this could happen only for compiling pango-*
- if env['gui']:
- env.ParseConfig ('pkg-config --cflags --libs gtk+-2.0')
- env.ParseConfig ('pkg-config --cflags --libs pango')
- if conf.CheckCHeader ('pango/pangofc-fontmap.h'):
- conf.env['DEFINES']['HAVE_PANGO_PANGOFC_FONTMAP_H'] = '1'
-
- if conf.CheckLib ('pango-1.0',
- 'pango_fc_font_map_add_decoder_find_func'):
- conf.env['DEFINES']['HAVE_PANGO_CVS'] = '1'
- conf.env['DEFINES']['HAVE_PANGO_FC_FONT_MAP_ADD_DECODER_FIND_FUNC'] = '1'
-
- if required:
- print
- print '********************************'
- print 'Please install required packages'
- for i in required:
- print '%s: %s-%s or newer (found: %s %s)' % i
- Exit (1)
-
- if optional:
- print
- print '*************************************'
- print 'Consider installing optional packages'
- for i in optional:
- print '%s: %s-%s or newer (found: %s %s)' % i
-
- return conf.Finish ()
+ dre = re.compile ('\n(200[0-9]{5})')
+ vre = re.compile ('.*?\n[^-.0-9]*([0-9][0-9]*\.[0-9]([.0-9]*[0-9])*)',
+ re.DOTALL)
+ def get_version (program):
+ command = '(pkg-config --modversion %(program)s || %(program)s --version || %(program)s -V) 2>&1' % vars ()
+ pipe = os.popen (command)
+ output = pipe.read ()
+ if pipe.close ():
+ return None
+ splits = re.sub ('^|\s', '\n', output)
+ date_hack = re.sub (dre, '\n0.0.\\1', splits)
+ m = re.match (vre, date_hack)
+ v = m.group (1)
+ if v[-1] == '\n':
+ v = v[:-1]
+ return string.split (v, '.')
+
+ def test_version (lst, full_name, minimal, description, package):
+ program = os.path.basename (full_name)
+ sys.stdout.write ('Checking %s version... ' % program)
+ actual = get_version (program)
+ if not actual:
+ print 'not found'
+ lst.append ((description, package, minimal, program,
+ 'not installed'))
+ return 0
+ print string.join (actual, '.')
+ if map (string.atoi, actual) \
+ < map (string.atoi, string.split (minimal, '.')):
+ lst.append ((description, package, minimal, program,
+ string.join (actual, '.')))
+ return 0
+ return 1
+
+ def test_program (lst, program, minimal, description, package):
+ key = program.upper ()
+ if key.find ('+-'):
+ key = re.sub ('\+', 'X', key)
+ key = re.sub ('-', '_', key)
+ sys.stdout.write ('Checking for %s ... ' % program)
+ if env.has_key (key):
+ f = env[key]
+ sys.stdout.write ('(cached) ')
+ else:
+ f = WhereIs (program)
+ env[key] = f
+ if not f:
+ print 'not found'
+ lst.append ((description, package, minimal, program,
+ 'not installed'))
+ return 0
+ print f
+ return test_version (lst, program, minimal, description, package)
+
+ def test_lib (lst, program, minimal, description, package):
+ # FIXME: test for Debian or RPM (or -foo?) based dists
+ # to guess (or get correct!: apt-cache search?)
+ # package name.
+ #if os.system ('pkg-config --atleast-version=0 freetype2'):
+ # barf
+ if test_version (lst, program, minimal, description,
+ 'lib%(package)s-dev or %(package)s-devel'
+ % vars ()):
+ env.ParseConfig ('pkg-config --cflags --libs %(program)s'
+ % vars ())
+ return 1
+ return 0
+
+ required = []
+ test_program (required, 'bash', '2.0', 'Bash', 'bash')
+ test_program (required, 'gcc', '4.0', 'GNU C compiler', 'gcc')
+ test_program (required, 'g++', '4.0.5', 'GNU C++ compiler', 'g++')
+ test_program (required, 'guile-config', '1.8', 'GUILE development',
+ 'libguile-dev or guile-devel')
+ test_program (required, 'mf', '0.0', 'Metafont', 'tetex-bin')
+ test_program (required, 'python', '2.1', 'Python (www.python.org)',
+ 'python')
+ # Silly, and breaks with /bin/sh == dash
+ #test_program (required, 'sh', '0.0', 'Bourne shell', 'sh')
+
+ optional = []
+ # Do not use bison 1.50 and 1.75.
+ #test_program (optional, 'foo', '2.0', 'Foomatic tester', 'bar')
+ test_program (optional, 'bison', '1.25', 'Bison -- parser generator',
+ 'bison')
+ test_program (optional, 'fontforge', '0.0.20050624', 'FontForge',
+ 'fontforge')
+ test_program (optional, 'flex', '0.0', 'Flex -- lexer generator',
+ 'flex')
+ test_program (optional, 'guile', '1.8', 'GUILE scheme', 'guile')
+ test_program (optional, 'gs', '8.15',
+ 'Ghostscript PostScript interpreter',
+ 'gs or gs-afpl or gs-esp or gs-gpl')
+ test_program (optional, 'makeinfo', '4.8', 'Makeinfo tool', 'texinfo')
+ test_program (optional, 'perl', '4.0',
+ 'Perl practical efficient readonly language', 'perl')
+
+ def CheckYYCurrentBuffer (context):
+ context.Message ('Checking for yy_current_buffer... ')
+ ret = conf.TryCompile ("""using namespace std;
+ #include <FlexLexer.h>
+ class yy_flex_lexer: public yyFlexLexer
+ {
+ public:
+ yy_flex_lexer ()
+ {
+ yy_current_buffer = 0;
+ }
+ };""", '.cc')
+ context.Result (ret)
+ return ret
+
+ conf = Configure (env, custom_tests = { 'CheckYYCurrentBuffer'
+ : CheckYYCurrentBuffer })
+
+ defines = {
+ 'DIRSEP' : "'%s'" % os.sep,
+ 'PATHSEP' : "'%s'" % os.pathsep,
+ 'PACKAGE': '"%s"' % package.name,
+ 'DATADIR' : '"%s"' % sharedir,
+ 'PACKAGE_DATADIR' : '"%s"' % sharedir_package,
+ 'LOCALEDIR' : '"%s"' %localedir,
+ }
+ conf.env.Append (DEFINES = defines)
+
+ command = r"""python -c 'import sys; sys.stdout.write ("%s/include/python%s" % (sys.prefix, sys.version[:3]))'""" #"
+ PYTHON_INCLUDE = os.popen (command).read ()#[:-1]
+ if env['fast']:
+ env.Append (CCFLAGS = ['-I%s' % PYTHON_INCLUDE])
+ else:
+ env.Append (CPPPATH = [PYTHON_INCLUDE])
+
+ headers = ('assert.h', 'grp.h', 'libio.h', 'pwd.h',
+ 'sys/stat.h', 'utf8/wchar.h', 'wchar.h', 'Python.h')
+ for i in headers:
+ if conf.CheckCHeader (i):
+ key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
+ conf.env['DEFINES'][key] = 1
+
+ ccheaders = ('sstream',)
+ for i in ccheaders:
+ if conf.CheckCXXHeader (i):
+ key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
+ conf.env['DEFINES'][key] = 1
+
+ functions = ('chroot', 'fopencookie', 'funopen',
+ 'gettext', 'isinf',
+ 'mbrtowc', 'memmem', 'snprintf', 'vsnprintf', 'wcrtomb')
+ for i in functions:
+ if 0 or conf.CheckFunc (i):
+ key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
+ conf.env['DEFINES'][key] = 1
+
+ if conf.CheckYYCurrentBuffer ():
+ conf.env['DEFINES']['HAVE_FLEXLEXER_YY_CURRENT_BUFFER'] = 1
+
+ if conf.CheckLib ('dl'):
+ pass
+
+ if env['fast']:
+ cpppath = []
+ if env.has_key ('CPPPATH'):
+ cpppath = env['CPPPATH']
+
+ ## FIXME: linkage, check for libguile.h and scm_boot_guile
+ #this could happen after flower...
+ env.ParseConfig ('guile-config compile')
+
+ test_program (required, 'pkg-config', '0.9.0',
+ 'pkg-config library compile manager', 'pkg-config')
+ if test_lib (required, 'freetype2', '0.0',
+ 'Development files for FreeType 2 font engine',
+ 'freetype6'):
+ conf.env['DEFINES']['HAVE_FREETYPE2'] = '1'
+
+ if test_lib (required, 'pangoft2', '1.6.0',
+ 'Development files for pango, with FreeType2',
+ 'pango1.0'):
+ conf.env['DEFINES']['HAVE_PANGO_FT2'] = '1'
+
+ if test_lib (optional, 'fontconfig', '2.2.0',
+ 'Development files for fontconfig', 'fontconfig1'):
+ conf.env['DEFINES']['HAVE_FONTCONFIG'] = '1'
+
+ #this could happen only for compiling pango-*
+ if env['gui']:
+ test_lib (required, 'gtk+-2.0', '2.4.0',
+ 'Development files for GTK+', 'gtk2.0')
+
+ if env['fast']:
+ # Using CCFLAGS = -I<system-dir> rather than CPPPATH = [
+ # <system-dir>] speeds up SCons
+ env['CCFLAGS'] += map (lambda x: '-I' + x,
+ env['CPPPATH'][len (cpppath):])
+ env['CPPPATH'] = cpppath
+
+ if required:
+ print
+ print '********************************'
+ print 'Please install required packages'
+ for i in required:
+ print '%s: %s-%s or newer (found: %s %s)' % i
+ Exit (1)
+
+ if optional:
+ print
+ print '*************************************'
+ print 'Consider installing optional packages'
+ for i in optional:
+ print '%s: %s-%s or newer (found: %s %s)' % i
+
+ return conf.Finish ()