Skip to content

Commit aa692fe

Browse files
committed
Merge pull request #21 from leffmann/master
Verify libncurses5-dev prerequisite
2 parents 3cb40d9 + 99adc64 commit aa692fe

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

common.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,38 @@ def make(name, target=None, **makevars):
450450
execute('make', *args)
451451

452452

453+
def require_header(header, lang, msg = '', symbol = False, value = False):
454+
debug('require_header "%s"', header)
455+
456+
cmd = {'c':'{cc}', 'c++':'{cxx}'}[lang]
457+
cmd = fill_in(cmd).split() + ['-fsyntax-only', '-x', lang, '-']
458+
proc = subprocess.Popen(cmd, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
459+
460+
stdin_line = '#include <' + header + '>'
461+
if symbol:
462+
if value:
463+
stdin_line += """\n#if %s != %s
464+
#error
465+
#endif """ % (symbol, value)
466+
else:
467+
stdin_line += """\n#ifndef %s
468+
#error
469+
#endif """ % (symbol)
470+
471+
(result_stdout, result_stderr) = proc.communicate(stdin_line)
472+
proc.wait()
473+
474+
cmd = ' '.join(cmd)
475+
476+
if proc.returncode == 0:
477+
debug('output from "%s":\n%s', cmd, result_stdout)
478+
else:
479+
debug('error output from "%s":\n%s', cmd, result_stderr)
480+
panic('require_header failed: %s', msg)
481+
482+
453483
__all__ = ['setvar', 'panic', 'cmpver', 'find_executable', 'chmod', 'execute',
454484
'rmtree', 'mkdir', 'copy', 'copytree', 'unarc', 'fetch', 'cwd',
455485
'symlink', 'remove', 'move', 'find', 'textfile', 'env', 'path',
456486
'add_site_dir', 'python_setup', 'recipe', 'unpack', 'patch',
457-
'configure', 'make']
487+
'configure', 'make', 'require_header']

toolchain-m68k

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ def build():
241241
path.join('{host}', 'bin'),
242242
environ['PATH']])
243243

244+
setvar(cc = environ['CC'], cxx = environ['CXX'])
245+
246+
"""
247+
When we have a working compiler in our path, we can also check if the
248+
required headers/libraries are present.
249+
"""
250+
251+
require_header('ncurses.h', 'c', 'libncurses-dev 5.x missing', 'NCURSES_VERSION_MAJOR', 5)
252+
244253
unpack('{m4}')
245254
configure('{m4}', '--prefix={host}')
246255
make('{m4}')

0 commit comments

Comments
 (0)