Skip to content

Commit 3849998

Browse files
committed
Close #23
1 parent c36c3f9 commit 3849998

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

common.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -451,34 +451,30 @@ def make(name, target=None, **makevars):
451451
execute('make', *args)
452452

453453

454-
def require_header(header, lang, msg = '', symbol = False, value = False):
454+
def require_header(header, lang, msg='', symbol=None, value=None):
455455
debug('require_header "%s"', header)
456456

457-
cmd = {'c':'{cc}', 'c++':'{cxx}'}[lang]
458-
cmd = fill_in(cmd).split() + ['-fsyntax-only', '-x', lang, '-']
459-
proc = subprocess.Popen(cmd, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
457+
cmd = {'c': '{cc}', 'c++': '{cxx}'}[lang]
458+
cmd = fill_in(cmd).split()
459+
proc = subprocess.Popen(cmd + ['-fsyntax-only', '-x', lang, '-'],
460+
stdin=subprocess.PIPE,
461+
stdout=subprocess.PIPE,
462+
stderr=subprocess.PIPE)
460463

461-
stdin_line = '#include <' + header + '>'
464+
proc_stdin = ['#include <%s>' % header]
462465
if symbol:
463466
if value:
464-
stdin_line += """\n#if %s != %s
465-
#error
466-
#endif """ % (symbol, value)
467+
proc_stdin.append("#if %s != %s" % (symbol, value))
467468
else:
468-
stdin_line += """\n#ifndef %s
469-
#error
470-
#endif """ % (symbol)
469+
proc_stdin.append("#ifndef %s" % symbol)
470+
proc_stdin.append("#error")
471+
proc_stdin.append("#endif")
471472

472-
(result_stdout, result_stderr) = proc.communicate(stdin_line)
473+
proc_stdout, proc_stderr = proc.communicate('\n'.join(proc_stdin))
473474
proc.wait()
474475

475-
cmd = ' '.join(cmd)
476-
477-
if proc.returncode == 0:
478-
debug('output from "%s":\n%s', cmd, result_stdout)
479-
else:
480-
debug('error output from "%s":\n%s', cmd, result_stderr)
481-
panic('require_header failed: %s', msg)
476+
if proc.returncode:
477+
panic(msg)
482478

483479

484480
__all__ = ['setvar', 'panic', 'cmpver', 'find_executable', 'chmod', 'execute',

toolchain-m68k

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,6 @@ def build():
197197
environ['LANG'] = 'C'
198198
environ['TERM'] = 'xterm'
199199

200-
find_executable('perl')
201-
find_executable('patch')
202-
find_executable('make')
203-
find_executable('git')
204-
find_executable('yacc')
205-
206200
with cwd('{archives}'):
207201
for url in URLS:
208202
if type(url) == tuple:
@@ -211,9 +205,6 @@ def build():
211205
name = path.basename(url)
212206
fetch(name, url)
213207

214-
unpack('python-lha', work_dir='{build}')
215-
python_setup('python-lha')
216-
217208
add_site_dir('{host}')
218209

219210
"""
@@ -241,14 +232,29 @@ def build():
241232
path.join('{host}', 'bin'),
242233
environ['PATH']])
243234

244-
setvar(cc = environ['CC'], cxx = environ['CXX'])
235+
setvar(cc=environ['CC'], cxx=environ['CXX'])
245236

246237
"""
247-
When we have a working compiler in our path, we can also check if the
248-
required headers/libraries are present.
238+
When we have a working compiler in our path, we shoule also check if the
239+
required programs, headers and libraries are present.
249240
"""
250241

251-
require_header('ncurses.h', 'c', 'libncurses-dev 5.x missing', 'NCURSES_VERSION_MAJOR', 5)
242+
find_executable('perl')
243+
find_executable('patch')
244+
find_executable('make')
245+
find_executable('git')
246+
find_executable('yacc')
247+
248+
require_header('ncurses.h', 'c', 'libncurses5-dev package missing',
249+
'NCURSES_VERSION_MAJOR', 5)
250+
251+
py_ver = 'python%d.%d' % (sys.version_info.major, sys.version_info.minor)
252+
253+
require_header(path.join(py_ver, 'Python.h'), 'c',
254+
'python-dev package missing')
255+
256+
unpack('python-lha', work_dir='{build}')
257+
python_setup('python-lha')
252258

253259
unpack('{m4}')
254260
configure('{m4}', '--prefix={host}')

0 commit comments

Comments
 (0)