1
0
mirror of https://github.com/cahirwpz/amigaos-cross-toolchain synced 2025-11-22 19:53:11 +00:00

Build host tools with default compiler. Add DONATE button.

This commit is contained in:
Krystian Bacławski
2016-09-30 19:24:12 +02:00
parent 3b4b739d7b
commit 90261e0eee
3 changed files with 89 additions and 52 deletions

View File

@ -3,7 +3,9 @@ AmigaOS cross compiler for Linux / MacOSX / Windows
**Author:** [Krystian Bacławski](mailto:krystian.baclawski@gmail.com)
**Short description:** Cross toolchain build script for AmigaOS m68k and ppc targets. Supported host platforms are Linux, MacOSX and Windows (Cygwin).
**Short description:** Cross toolchain build script for AmigaOS m68k and ppc targets. Supported host platforms are Linux, MacOSX and Windows (with [MSYS2](https://msys2.github.io/)).
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=47CV5JMRW9BRA)
### Overview
@ -36,9 +38,9 @@ Build process should produce following set of tools for **m68k-amigaos** target:
There are no binary downloads provided for the time being. I do as much as possible to make the toolchain portable among Unix-like environments. Following platforms were tested and the toolchain is known to work for them:
* Windows 7 SP1 32-bit (Cygwin 2.5.1, gcc 5.3.0)
* Ubuntu 16.04 LTS 32-bit (gcc 5.3.1)
* Ubuntu 16.04 LTS 64-bit (gcc 5.3.1) *Requires gcc-multilib package, and i386 libraries!*
* Windows 7 SP1 32-bit (MSYS2 2.6.0, gcc 5.3.0)
* Ubuntu 16.04 LTS 32-bit (gcc 5.4.0)
* Ubuntu 16.04 LTS 64-bit (gcc 5.4.0) *Requires gcc-multilib package, and i386 libraries!*
* MacOS X 10.9.5 (MacPorts - Apple's clang-600.0.57)
### Documentation
@ -65,15 +67,16 @@ AmigaOS specific documents:
You have to have following packages installed in your system:
* GNU gcc 4.x **32-bit version!** or Clang
* libncurses5-dev **32-bit version!**
* GNU make
* python-dev
* perl
* GNU gcc 5.x **32-bit version!** or Clang
* Python 2.7.x
* libncurses-dev
* python-dev 2.7
* GNU make 4.x
* perl 5.22
* git
* subversion
* patch
* yacc
* GNU patch
* GNU gperf
* GNU bison
*For MacOSX users*: you'll likely need to have [MacPorts](http://www.macports.org) or [Homebrew](http://brew.sh) installed in order to build the toolchain.

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python -B
#!/usr/bin/env python2.7 -B
from fnmatch import fnmatch
from glob import glob
@ -357,8 +357,8 @@ def recipe(name, nargs=0):
@recipe('python-setup', 1)
def python_setup(name):
with cwd(path.join('{build}', name)):
execute('python', 'setup.py', 'build')
execute('python', 'setup.py', 'install', '--prefix={host}')
execute(sys.executable, 'setup.py', 'build')
execute(sys.executable, 'setup.py', 'install', '--prefix={host}')
@recipe('fetch', 1)
@ -456,30 +456,34 @@ def make(name, target=None, makefile=None, **makevars):
execute('make', *args)
def require_header(header, lang, msg='', symbol=None, value=None):
debug('require_header "%s"', header)
def require_header(headers, lang='c', errmsg='', symbol=None, value=None):
debug('require_header "%s"', headers[0])
cmd = {'c': os.environ['CC'], 'c++': os.environ['CXX']}[lang]
cmd = fill_in(cmd).split()
proc = subprocess.Popen(cmd + ['-fsyntax-only', '-x', lang, '-'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
for header in headers:
cmd = {'c': os.environ['CC'], 'c++': os.environ['CXX']}[lang]
cmd = fill_in(cmd).split()
opts = ['-fsyntax-only', '-x', lang, '-']
proc = subprocess.Popen(cmd + opts,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc_stdin = ['#include <%s>' % header]
if symbol:
if value:
proc_stdin.append("#if %s != %s" % (symbol, value))
else:
proc_stdin.append("#ifndef %s" % symbol)
proc_stdin.append("#error")
proc_stdin.append("#endif")
proc_stdin = ['#include <%s>' % header]
if symbol:
if value:
proc_stdin.append("#if %s != %s" % (symbol, value))
else:
proc_stdin.append("#ifndef %s" % symbol)
proc_stdin.append("#error")
proc_stdin.append("#endif")
proc_stdout, proc_stderr = proc.communicate('\n'.join(proc_stdin))
proc.wait()
proc_stdout, proc_stderr = proc.communicate('\n'.join(proc_stdin))
proc.wait()
if proc.returncode:
panic(msg)
if proc.returncode == 0:
return
panic(errmsg)
__all__ = ['setvar', 'panic', 'cmpver', 'find_executable', 'chmod', 'execute',

View File

@ -1,4 +1,4 @@
#!/usr/bin/python -B
#!/usr/bin/python2.7 -B
# Build cross toolchain for AmigaOS <= 3.9 / M68k target.
@ -19,6 +19,7 @@ URLS = \
'ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz',
'ftp://ftp.gnu.org/gnu/bison/bison-1.35.tar.gz',
'ftp://ftp.gnu.org/gnu/texinfo/texinfo-4.12.tar.gz',
'git://git.savannah.gnu.org/automake',
('git://github.com/cahirwpz/amigaos-binutils-2.9.1', 'binutils-2.9.1'),
('git://github.com/cahirwpz/amigaos-gcc-2.95.3', 'gcc-2.95.3'),
('http://downloads.sourceforge.net/project/flex/flex/2.5.4.a/flex-2.5.4a.tar.gz',
@ -201,12 +202,22 @@ def install_vbcc_toolchain():
move(config, '{target}/etc/vc.config')
def update_autotools(dst):
copy('{archives}/automake/lib/config.guess', path.join(dst, 'config.guess'))
copy('{archives}/automake/lib/config.sub', path.join(dst, 'config.sub'))
def build():
for var in environ.keys():
if var not in ['_', 'LOGNAME', 'HOME', 'SHELL', 'TMPDIR', 'PWD']:
del environ[var]
environ['PATH'] = '/usr/bin:/bin'
PATH = ['/usr/bin', '/bin']
if fnmatch(platform.system(), 'MSYS_NT*'):
PATH.append('/usr/bin/core_perl') # pod2text, pod2man
environ['PATH'] = ":".join(PATH)
environ['LANG'] = 'C'
environ['TERM'] = 'xterm'
@ -232,17 +243,8 @@ def build():
CC = find_executable(CC)
CXX = find_executable(CXX)
"""
On 64-bit architecture GNU Assembler crashes writing out an object, due to
(probably) miscalculated structure sizes. There could be some other bugs
lurking there in 64-bit mode, but I have little incentive chasing them.
Just compile everything in 32-bit mode and forget about the issues.
"""
ARCH = '-m32' if platform.machine() == 'x86_64' else ''
environ['CC'] = CC + ' ' + ARCH
environ['CXX'] = CXX + ' ' + ARCH
environ['CC'] = CC
environ['CXX'] = CXX
environ['PATH'] = ':'.join([path.join('{target}', 'bin'),
path.join('{host}', 'bin'),
environ['PATH']])
@ -255,18 +257,21 @@ def build():
"""
find_executable('perl')
find_executable('pod2text')
find_executable('pod2man')
find_executable('gperf')
find_executable('patch')
find_executable('make')
find_executable('git')
find_executable('yacc')
require_header('ncurses.h', 'c', 'libncurses-dev package missing')
require_header(['ncurses.h', 'ncurses/ncurses.h'],
lang='c', errmsg='libncurses-dev package missing')
py_ver = 'python%d.%d' % (sys.version_info.major, sys.version_info.minor)
with env(CC=CC, CXX=CXX):
require_header(path.join(py_ver, 'Python.h'), 'c',
'python-dev package missing')
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')
@ -277,6 +282,7 @@ def build():
make('{m4}', 'install')
unpack('{gawk}')
update_autotools('{sources}/{gawk}')
configure('{gawk}', '--prefix={host}')
make('{gawk}')
make('{gawk}', 'install')
@ -287,16 +293,19 @@ def build():
make('{flex}', 'install')
unpack('{bison}')
update_autotools('{sources}/{bison}/config')
configure('{bison}', '--prefix={host}')
make('{bison}')
make('{bison}', 'install')
unpack('{texinfo}')
update_autotools('{sources}/{texinfo}/build-aux')
configure('{texinfo}', '--prefix={host}')
make('{texinfo}')
make('{texinfo}', 'install')
unpack('{autoconf}')
update_autotools('{sources}/{autoconf}')
configure('{autoconf}', '--prefix={host}')
make('{autoconf}')
make('{autoconf}', 'install')
@ -319,6 +328,7 @@ def build():
unpack('fd2sfd')
patch('fd2sfd')
update_autotools('{sources}/fd2sfd')
configure('fd2sfd', '--prefix={target}', copy_source=True)
make('fd2sfd')
make('fd2sfd', 'install')
@ -333,6 +343,20 @@ def build():
patch('{NDK}')
install_ndk()
"""
On 64-bit architecture GNU Assembler crashes writing out an object, due to
(probably) miscalculated structure sizes. There could be some other bugs
lurking there in 64-bit mode, but I have little incentive chasing them.
Just compile everything in 32-bit mode and forget about the issues.
"""
ARCH = '-m32' if platform.machine() == 'x86_64' else ''
environ['CC'] = CC + ' ' + ARCH
environ['CXX'] = CXX + ' ' + ARCH
setvar(cc=environ['CC'], cxx=environ['CXX'])
"""
Older gcc compilers (i.e. 2.95.3 and 3.4.6) and binutils have to be tricked
into thinking that they're being compiled on Linux IA-32 machine. Theirs
@ -340,6 +364,7 @@ def build():
"""
unpack('{binutils}')
update_autotools('{sources}/{binutils}')
with env(CC=environ['CC'] + ' -std=gnu11',
CXX=environ['CXX'] + ' -std=gnu++11',
CFLAGS='-g -O2 -Wall',
@ -355,6 +380,9 @@ def build():
patch('{ixemul}')
unpack('{gcc}')
update_autotools('{sources}/{gcc}')
update_autotools('{sources}/{gcc}/gcc')
update_autotools('{sources}/{gcc}/texinfo')
with env(CC=environ['CC'] + ' -std=gnu11',
CXX=environ['CXX'] + ' -std=gnu++11',
CFLAGS='-g -O2 -Wall',
@ -396,6 +424,7 @@ def build():
'{target}/m68k-amigaos/libnix/include')
unpack('{libm}', top_dir='contrib/libm')
update_autotools('{sources}/{libm}')
with env(CC='m68k-amigaos-gcc -noixemul',
AR='m68k-amigaos-ar',
RANLIB='m68k-amigaos-ranlib'):
@ -407,6 +436,7 @@ def build():
make('{libm}', 'install')
unpack('{libdebug}')
update_autotools('{sources}/{libdebug}')
with env(CC='m68k-amigaos-gcc -noixemul',
AR='m68k-amigaos-ar',
RANLIB='m68k-amigaos-ranlib'):
@ -617,7 +647,7 @@ if __name__ == "__main__":
panic('I need Python 2.7 to run!')
if not (platform.system() in ['Darwin', 'Linux'] or
fnmatch(platform.system(), 'CYGWIN*')):
fnmatch(platform.system(), 'MSYS_NT*')):
panic('Build on %s not supported!', platform.system())
if platform.machine() not in ['i686', 'x86_64']: