Skip to content

Commit a2ff468

Browse files
author
leffmann
committed
Verify prerequisites
1 parent 0af4d25 commit a2ff468

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

common.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from fnmatch import fnmatch
44
from glob import glob
55
from logging import debug, info, error
6-
from os import path
6+
from os import path, environ
77
import contextlib
88
import distutils.spawn
99
import os
@@ -450,8 +450,31 @@ def make(name, target=None, **makevars):
450450
execute('make', *args)
451451

452452

453+
def require_header(header, symbol = False, value = False):
454+
debug('require_header "%s"', header)
455+
cmd = environ['CC'].split() + ['-fsyntax-only', '-x', 'c', '-']
456+
proc = subprocess.Popen(cmd, stdin = subprocess.PIPE, env = environ)
457+
458+
stdin_line = '#include ' + header
459+
if symbol:
460+
if value:
461+
stdin_line += """\n#if %s != %s
462+
#error
463+
#endif """ % (symbol, value)
464+
else:
465+
stdin_line += """\n#ifndef %s
466+
#error
467+
#endif """ % (symbol)
468+
469+
proc.communicate(stdin_line)
470+
proc.wait()
471+
472+
if proc.returncode != 0:
473+
panic('require_header "%s" failed', header)
474+
475+
453476
__all__ = ['setvar', 'panic', 'cmpver', 'find_executable', 'chmod', 'execute',
454477
'rmtree', 'mkdir', 'copy', 'copytree', 'unarc', 'fetch', 'cwd',
455478
'symlink', 'remove', 'move', 'find', 'textfile', 'env', 'path',
456479
'add_site_dir', 'python_setup', 'recipe', 'unpack', 'patch',
457-
'configure', 'make']
480+
'configure', 'make', 'require_header']

toolchain-m68k

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

244+
"""
245+
When we have a working compiler in our path, we can also check if the
246+
required headers/libraries are present.
247+
"""
248+
249+
require_header('<python2.7/python.h>')
250+
require_header('<ncurses.h>', symbol = 'NCURSES_VERSION_MAJOR', value = 5)
251+
244252
unpack('{m4}')
245253
configure('{m4}', '--prefix={host}')
246254
make('{m4}')

0 commit comments

Comments
 (0)