From 39f0b27679e4f688e44616a6d6d7bc2b2bb753be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Bac=C5=82awski?= Date: Fri, 4 Aug 2017 23:50:23 +0200 Subject: [PATCH] Integrate amitools into the toolchain (#86) * Attempt to integrate amitools into the toolchain * Update link for IDA * Install amitools with easy_install * Move amitools build to the end * Update README file --- README.md | 1 + common.py | 58 ++++++++++++++++++++++++++++++++++++++++++-------- toolchain-m68k | 22 +++++++++++++------ 3 files changed, 65 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 23394bd..73b848a 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Build process should produce following set of tools for **m68k-amigaos** target: * IRA: portable M68000/010/020/030/040 reassembler for AmigaOS hunk-format executables, libraries, devices and raw binary files * vda68k: portable M68k disassembler for 68000-68060, 68851, 68881, 68882 + * [amitools](https://github.com/cnvogelg/amitools/blob/master/README.md#contents) with [vamos](https://github.com/cnvogelg/amitools/blob/master/doc/vamos.md) AmigaOS emulator which is proven to run SAS/C ... and following set of tools for **ppc-amigaos** target: diff --git a/common.py b/common.py index b960b76..96a796f 100644 --- a/common.py +++ b/common.py @@ -1,11 +1,14 @@ #!/usr/bin/env python2.7 -B +from __future__ import print_function + from fnmatch import fnmatch from glob import glob from logging import debug, info, error from os import path import contextlib from distutils import spawn, sysconfig +import fileinput import os import shutil import site @@ -260,7 +263,7 @@ def download(url, name): sys.stdout.write(status) sys.stdout.flush() - print "" + print("") @fill_in_args @@ -292,6 +295,18 @@ def unarc(name): raise RuntimeError('Unrecognized archive: "%s"', name) +@fill_in_args +def fix_python_shebang(filename, prefix): + PYTHON = fill_in('{python}') + SITEDIR = path.join(prefix, '{sitedir}') + for line in fileinput.input(files=[filename], inplace=True): + line = line.rstrip() + if line.startswith('#!'): + print('#!/usr/bin/env PYTHONPATH=%s %s' % (SITEDIR, PYTHON)) + else: + print(line.rstrip()) + + @fill_in_args def find_site_dir(dirname): prefix = sysconfig.EXEC_PREFIX @@ -362,12 +377,36 @@ def recipe(name, nargs=0): return real_decorator -@recipe('python-setup', 1) -def python_setup(name, **kwargs): - dest_dir = kwargs.get('dest_dir', '{host}') - with cwd(path.join('{build}', name)): - execute(sys.executable, 'setup.py', 'build') - execute(sys.executable, 'setup.py', 'install', '--prefix=' + dest_dir) +def extend_pythonpath(prefix): + SITEDIR = path.join(prefix, '{sitedir}') + try: + return ':'.join([os.environ['PYTHONPATH'], SITEDIR]) + except KeyError: + return SITEDIR + + +@recipe('pyinstall', 1) +def pyinstall(name, **kwargs): + prefix = kwargs.get('prefix', '{prefix}') + mkdir(path.join(prefix, '{sitedir}')) + with env(PYTHONPATH=extend_pythonpath(prefix)): + execute('{python}', '-m', 'easy_install', '--prefix=' + prefix, name) + +@recipe('pyfixbin', 1) +def pyfixbin(name, names, **kwargs): + prefix = kwargs.get('prefix', '{prefix}') + for name in names: + fix_python_shebang(path.join(prefix, 'bin', name), prefix) + + +@recipe('pysetup', 1) +def pysetup(name, **kwargs): + prefix = kwargs.get('prefix', '{prefix}') + mkdir(path.join(prefix, '{sitedir}')) + with env(PYTHONPATH=extend_pythonpath(prefix)): + with cwd(path.join('{build}', name)): + execute('{python}', 'setup.py', 'build') + execute('{python}', 'setup.py', 'install', '--prefix=' + prefix) @recipe('fetch', 1) @@ -499,5 +538,6 @@ def require_header(headers, lang='c', errmsg='', symbol=None, value=None): __all__ = ['setvar', 'panic', 'cmpver', 'find_executable', 'chmod', 'execute', 'rmtree', 'mkdir', 'copy', 'copytree', 'unarc', 'fetch', 'cwd', 'symlink', 'remove', 'move', 'find', 'textfile', 'env', 'path', - 'add_site_dir', 'find_site_dir', 'python_setup', 'recipe', - 'unpack', 'patch', 'configure', 'make', 'require_header', 'touch'] + 'add_site_dir', 'find_site_dir', 'pysetup', 'pyinstall', 'recipe', + 'unpack', 'patch', 'configure', 'make', 'require_header', 'touch', + 'pyfixbin'] diff --git a/toolchain-m68k b/toolchain-m68k index 7291aae..9ea81f7 100755 --- a/toolchain-m68k +++ b/toolchain-m68k @@ -32,7 +32,7 @@ URLS = \ 'http://sun.hasenbraten.de/vasm/release/vasm.tar.gz', 'http://sun.hasenbraten.de/vlink/release/vlink.tar.gz', ('http://server.owl.de/~frank/tags/vbcc0_9f.tar.gz', 'vbcc.tar.gz'), - 'http://aminet.net/dev/asm/ira.lha', + 'http://de3.aminet.net/dev/asm/ira.lha', 'http://sun.hasenbraten.de/~frank/projects/download/vdam68k.tar.gz', ('http://mail.pb-owl.de/~frank/vbcc/current/vbcc_target_m68k-amigaos.lha', 'vclib.lha')] @@ -266,7 +266,7 @@ def build(): execute('git', 'submodule', 'init'); execute('git', 'submodule', 'update'); - add_site_dir('{host}') + add_site_dir('{prefix}') """ Make sure we always choose known compiler (from the distro) and not one in @@ -312,13 +312,14 @@ def build(): require_header(['ncurses.h', 'ncurses/ncurses.h'], lang='c', errmsg='libncurses-dev package missing') - unpack('{automake}') - py_ver = 'python%d.%d' % (sys.version_info.major, sys.version_info.minor) require_header([path.join(py_ver, 'Python.h')], lang='c', errmsg='python-dev package missing') + unpack('python-lha', work_dir='{build}') - python_setup('python-lha') + pysetup('python-lha') + + unpack('{automake}') unpack('{m4}') configure('{m4}', '--prefix={host}') @@ -508,6 +509,10 @@ def build(): install_tools() + pyinstall('amitools') + pyfixbin('amitools', ['fdtool', 'geotool', 'hunktool', 'rdbtool', 'romtool', + 'typetool', 'vamos', 'vamospath', 'xdfscan', 'xdftool']) + def clean(): rmtree('{stamps}') @@ -654,7 +659,7 @@ def install_sdk(*names): path.join('{host}', 'bin'), environ['PATH']]) - add_site_dir('{host}') + add_site_dir('{prefix}') with cwd('{prefix}/{target}'): mkdir('doc', 'guide', 'include/proto', 'include/inline', 'include/lvo', @@ -727,7 +732,8 @@ if __name__ == "__main__": setvar(top=path.abspath(path.dirname(sys.argv[0])), binutils_ver=args.binutils, - gcc_ver=args.gcc) + gcc_ver=args.gcc, + py_ver='python%d.%d' % (sys.version_info.major, sys.version_info.minor)) setvar(m4='m4-1.4.17', gawk='gawk-3.1.8', @@ -747,6 +753,8 @@ if __name__ == "__main__": gcc='gcc-{gcc_ver}', gpp='g++-{gcc_ver}', target='m68k-amigaos', + python=sys.executable, + sitedir=path.join('lib', '{py_ver}', 'site-packages'), patches=path.join('{top}', 'patches'), stamps=path.join('{top}', '.build-m68k', 'stamps'), build=path.join('{top}', '.build-m68k', 'build'),