Unify the way GNU Make is invoked.
This commit is contained in:
parent
3f40fcde34
commit
33611fc4b2
69
common.py
69
common.py
|
@ -303,25 +303,30 @@ def env(**kwargs):
|
|||
os.environ[key] = value
|
||||
|
||||
|
||||
def check_stamp(fn):
|
||||
@fill_in_args
|
||||
def wrapper(*args, **kwargs):
|
||||
name = fn.func_name.replace('_', '-')
|
||||
if len(args) > 0:
|
||||
name = name + "-" + str(fill_in(args[0]))
|
||||
stamp = path.join('{stamps}', name)
|
||||
if not path.exists('{stamps}'):
|
||||
mkdir('{stamps}')
|
||||
if not path.exists(stamp):
|
||||
fn(*args, **kwargs)
|
||||
touch(stamp)
|
||||
else:
|
||||
info('already done "%s"', name)
|
||||
|
||||
return wrapper
|
||||
def recipe(name, nargs=0):
|
||||
def real_decorator(fn):
|
||||
@fill_in_args
|
||||
def wrapper(*args, **kwargs):
|
||||
target = [str(arg) for arg in args[:min(nargs, len(args))]]
|
||||
if len(target) > 0:
|
||||
target = [target[0], name] + target[1:]
|
||||
target = '-'.join(target)
|
||||
else:
|
||||
target = name
|
||||
target = target.replace('_', '-')
|
||||
stamp = path.join('{stamps}', target)
|
||||
if not path.exists('{stamps}'):
|
||||
mkdir('{stamps}')
|
||||
if not path.exists(stamp):
|
||||
fn(*args, **kwargs)
|
||||
touch(stamp)
|
||||
else:
|
||||
info('already done "%s"', target)
|
||||
return wrapper
|
||||
return real_decorator
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('fetch', 1)
|
||||
def fetch(name, url):
|
||||
if url.startswith('http') or url.startswith('ftp'):
|
||||
if not path.exists(name):
|
||||
|
@ -344,7 +349,7 @@ def fetch(name, url):
|
|||
panic('URL "%s" not recognized!', url)
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('unpack', 1)
|
||||
def unpack(name, work_dir='{sources}', top_dir=None, dst_dir=None):
|
||||
try:
|
||||
src = glob(path.join('{archives}', name) + '*')[0]
|
||||
|
@ -367,7 +372,7 @@ def unpack(name, work_dir='{sources}', top_dir=None, dst_dir=None):
|
|||
rmtree(tmpdir)
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('patch', 1)
|
||||
def patch(name, work_dir='{sources}'):
|
||||
with cwd(work_dir):
|
||||
for name in find(path.join('{patches}', name),
|
||||
|
@ -380,7 +385,7 @@ def patch(name, work_dir='{sources}'):
|
|||
copy(name, dst)
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('configure', 1)
|
||||
def configure(name, *confopts, **kwargs):
|
||||
info('configuring "%s"', name)
|
||||
|
||||
|
@ -399,28 +404,18 @@ def configure(name, *confopts, **kwargs):
|
|||
execute(path.join(from_dir, 'configure'), *confopts)
|
||||
|
||||
|
||||
@check_stamp
|
||||
def build(name, *targets, **makevars):
|
||||
info('building "%s"', name)
|
||||
@recipe('make', 2)
|
||||
def make(name, target=None, **makevars):
|
||||
info('running make "%s"', target)
|
||||
|
||||
with cwd(path.join('{build}', name)):
|
||||
args = list(targets) + ['%s=%s' % item for item in makevars.items()]
|
||||
execute('make', *args)
|
||||
|
||||
|
||||
@check_stamp
|
||||
def install(name, *targets, **makevars):
|
||||
info('installing "%s"', name)
|
||||
|
||||
if not targets:
|
||||
targets = ['install']
|
||||
|
||||
with cwd(path.join('{build}', name)):
|
||||
args = list(targets) + ['%s=%s' % item for item in makevars.items()]
|
||||
args = ['%s=%s' % item for item in makevars.items()]
|
||||
if target is not None:
|
||||
args = [target] + args
|
||||
execute('make', *args)
|
||||
|
||||
|
||||
__all__ = ['setvar', 'panic', 'cmpver', 'find_executable', 'chmod', 'execute',
|
||||
'rmtree', 'mkdir', 'copy', 'copytree', 'unarc', 'fetch', 'cwd',
|
||||
'symlink', 'remove', 'move', 'find', 'textfile', 'env', 'path',
|
||||
'check_stamp', 'unpack', 'patch', 'configure', 'build', 'install']
|
||||
'recipe', 'unpack', 'patch', 'configure', 'make']
|
||||
|
|
|
@ -21,7 +21,7 @@ URLS = \
|
|||
from common import * # NOQA
|
||||
|
||||
|
||||
def make():
|
||||
def build():
|
||||
for var in environ.keys():
|
||||
if var not in ['_', 'LOGNAME', 'HOME', 'SHELL', 'TMPDIR', 'PWD']:
|
||||
del environ[var]
|
||||
|
@ -59,16 +59,16 @@ def make():
|
|||
configure('{gmp}',
|
||||
'--disable-shared',
|
||||
'--prefix={host}')
|
||||
build('{gmp}')
|
||||
install('{gmp}')
|
||||
make('{gmp}')
|
||||
make('{gmp}', 'install')
|
||||
|
||||
unpack('{mpfr}')
|
||||
configure('{mpfr}',
|
||||
'--disable-shared',
|
||||
'--prefix={host}',
|
||||
'--with-gmp={host}')
|
||||
build('{mpfr}')
|
||||
install('{mpfr}')
|
||||
make('{mpfr}')
|
||||
make('{mpfr}', 'install')
|
||||
|
||||
unpack('{mpc}')
|
||||
configure('{mpc}',
|
||||
|
@ -76,16 +76,16 @@ def make():
|
|||
'--prefix={host}',
|
||||
'--with-gmp={host}',
|
||||
'--with-mpfr={host}')
|
||||
build('{mpc}')
|
||||
install('{mpc}')
|
||||
make('{mpc}')
|
||||
make('{mpc}', 'install')
|
||||
|
||||
unpack('{isl}')
|
||||
configure('{isl}',
|
||||
'--disable-shared',
|
||||
'--prefix={host}',
|
||||
'--with-gmp-prefix={host}')
|
||||
build('{isl}')
|
||||
install('{isl}')
|
||||
make('{isl}')
|
||||
make('{isl}', 'install')
|
||||
|
||||
unpack('{cloog}')
|
||||
configure('{cloog}',
|
||||
|
@ -94,8 +94,8 @@ def make():
|
|||
'--with-isl=system',
|
||||
'--with-gmp-prefix={host}',
|
||||
'--with-isl-prefix={host}')
|
||||
build('{cloog}')
|
||||
install('{cloog}')
|
||||
make('{cloog}')
|
||||
make('{cloog}', 'install')
|
||||
|
||||
with env(CFLAGS='-Wno-error'):
|
||||
configure('binutils',
|
||||
|
@ -103,8 +103,8 @@ def make():
|
|||
'--with-isl={host}',
|
||||
'--target=m68k-elf',
|
||||
from_dir='{archives}/binutils')
|
||||
build('binutils')
|
||||
install('binutils')
|
||||
make('binutils')
|
||||
make('binutils', 'install')
|
||||
|
||||
configure('gcc',
|
||||
'--target=m68k-elf',
|
||||
|
@ -116,8 +116,8 @@ def make():
|
|||
'--enable-languages=c',
|
||||
'--without-headers',
|
||||
from_dir='{archives}/gcc')
|
||||
build('gcc', 'all-gcc')
|
||||
install('gcc', 'install-gcc')
|
||||
make('gcc', 'all-gcc')
|
||||
make('gcc', 'install-gcc')
|
||||
|
||||
|
||||
def clean():
|
||||
|
@ -140,7 +140,7 @@ if __name__ == "__main__":
|
|||
panic('Build on %s architecture not supported!', platform.machine())
|
||||
|
||||
parser = argparse.ArgumentParser(description='Build cross toolchain.')
|
||||
parser.add_argument('action', choices=['make', 'clean'], default='make',
|
||||
parser.add_argument('action', choices=['build', 'clean'], default='build',
|
||||
help='perform action')
|
||||
parser.add_argument('--prefix', type=str, default=None,
|
||||
help='installation directory')
|
||||
|
|
|
@ -42,7 +42,7 @@ URLS = \
|
|||
from common import * # NOQA
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('target-prepare')
|
||||
def prepare_target():
|
||||
info('preparing target')
|
||||
|
||||
|
@ -56,7 +56,7 @@ def prepare_target():
|
|||
symlink('../lib', 'lib')
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('{NDK}-install')
|
||||
def install_ndk():
|
||||
info('installing ndk')
|
||||
|
||||
|
@ -79,14 +79,14 @@ def install_ndk():
|
|||
'--output={target}/os-include/lvo/' + base + '_lib.i', name)
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('libamiga-install')
|
||||
def install_libamiga():
|
||||
info('installing libamiga')
|
||||
|
||||
copytree('{sources}/libamiga/lib', '{target}/lib')
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('vbcc-build')
|
||||
def build_vbcc():
|
||||
copytree('{sources}/vbcc', '{build}/vbcc')
|
||||
mkdir('{build}/vbcc/bin')
|
||||
|
@ -101,17 +101,17 @@ def build_vbcc():
|
|||
'n', 'y', 'unsigned long',
|
||||
'n', 'y', 'float',
|
||||
'n', 'y', 'double')
|
||||
build('vbcc', TARGET='m68k', ETCDIR='\\"{target}/etc\\"', CONFIG=config)
|
||||
make('vbcc', TARGET='m68k', ETCDIR='\\"{target}/etc\\"', CONFIG=config)
|
||||
remove(config)
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('vlink-build')
|
||||
def build_vlink():
|
||||
mkdir('{build}/vlink/objects')
|
||||
build('vlink')
|
||||
make('vlink')
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('vbcc-install')
|
||||
def install_vbcc_toolchain():
|
||||
info('installing vasm')
|
||||
|
||||
|
@ -168,7 +168,7 @@ def install_vbcc_toolchain():
|
|||
move(config, '{target}/etc/vc.config')
|
||||
|
||||
|
||||
def make():
|
||||
def build():
|
||||
for var in environ.keys():
|
||||
if var not in ['_', 'LOGNAME', 'HOME', 'SHELL', 'TMPDIR', 'PWD']:
|
||||
del environ[var]
|
||||
|
@ -219,43 +219,43 @@ def make():
|
|||
'--disable-shared',
|
||||
'--prefix={host}',
|
||||
copy_source=True)
|
||||
build('{lha}')
|
||||
install('{lha}')
|
||||
make('{lha}')
|
||||
make('{lha}', 'install')
|
||||
|
||||
unpack('{m4}')
|
||||
configure('{m4}', '--prefix={host}')
|
||||
build('{m4}')
|
||||
install('{m4}')
|
||||
make('{m4}')
|
||||
make('{m4}', 'install')
|
||||
|
||||
unpack('{gawk}')
|
||||
configure('{gawk}', '--prefix={host}')
|
||||
build('{gawk}')
|
||||
install('{gawk}')
|
||||
make('{gawk}')
|
||||
make('{gawk}', 'install')
|
||||
|
||||
unpack('{flex}')
|
||||
configure('{flex}', '--prefix={host}')
|
||||
build('{flex}')
|
||||
install('{flex}')
|
||||
make('{flex}')
|
||||
make('{flex}', 'install')
|
||||
|
||||
unpack('{bison}')
|
||||
configure('{bison}', '--prefix={host}')
|
||||
build('{bison}')
|
||||
install('{bison}')
|
||||
make('{bison}')
|
||||
make('{bison}', 'install')
|
||||
|
||||
unpack('{texinfo}')
|
||||
configure('{texinfo}', '--prefix={host}')
|
||||
build('{texinfo}')
|
||||
install('{texinfo}')
|
||||
make('{texinfo}')
|
||||
make('{texinfo}', 'install')
|
||||
|
||||
unpack('{autoconf}')
|
||||
configure('{autoconf}', '--prefix={host}')
|
||||
build('{autoconf}')
|
||||
install('{autoconf}')
|
||||
make('{autoconf}')
|
||||
make('{autoconf}', 'install')
|
||||
|
||||
prepare_target()
|
||||
|
||||
unpack('vasm', work_dir='{build}')
|
||||
build('vasm', CPU='m68k', SYNTAX='mot')
|
||||
make('vasm', CPU='m68k', SYNTAX='mot')
|
||||
|
||||
unpack('vlink', work_dir='{build}')
|
||||
build_vlink()
|
||||
|
@ -280,8 +280,8 @@ def make():
|
|||
'--prefix={target}',
|
||||
'--host=i686-linux-gnu',
|
||||
'--target=m68k-amigaos')
|
||||
build('{binutils}')
|
||||
install('{binutils}')
|
||||
make('{binutils}')
|
||||
make('{binutils}', 'install')
|
||||
|
||||
unpack('{ixemul}', top_dir='ixemul')
|
||||
patch('{ixemul}')
|
||||
|
@ -298,20 +298,20 @@ def make():
|
|||
'--target=m68k-amigaos',
|
||||
'--enable-languages=c',
|
||||
'--with-headers={sources}/{ixemul}/include')
|
||||
build('{gcc}', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul')
|
||||
install('{gcc}', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul')
|
||||
make('{gcc}', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul')
|
||||
make('{gcc}', 'install', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul')
|
||||
|
||||
unpack('fd2sfd')
|
||||
patch('fd2sfd')
|
||||
configure('fd2sfd', '--prefix={target}', copy_source=True)
|
||||
build('fd2sfd')
|
||||
install('fd2sfd')
|
||||
make('fd2sfd')
|
||||
make('fd2sfd', 'install')
|
||||
|
||||
unpack('sfdc')
|
||||
patch('sfdc')
|
||||
configure('sfdc', '--prefix={target}', copy_source=True)
|
||||
build('sfdc')
|
||||
install('sfdc')
|
||||
make('sfdc')
|
||||
make('sfdc', 'install')
|
||||
|
||||
unpack('{NDK}')
|
||||
patch('{NDK}')
|
||||
|
@ -325,14 +325,14 @@ def make():
|
|||
'--prefix={target}',
|
||||
'--host=i686-linux-gnu',
|
||||
'--target=m68k-amigaos')
|
||||
build('libnix',
|
||||
CC='m68k-amigaos-gcc',
|
||||
CPP='m68k-amigaos-gcc -E',
|
||||
AR='m68k-amigaos-ar',
|
||||
AS='m68k-amigaos-as',
|
||||
RANLIB='m68k-amigaos-ranlib',
|
||||
LD='m68k-amigaos-ld')
|
||||
install('libnix')
|
||||
make('libnix',
|
||||
CC='m68k-amigaos-gcc',
|
||||
CPP='m68k-amigaos-gcc -E',
|
||||
AR='m68k-amigaos-ar',
|
||||
AS='m68k-amigaos-as',
|
||||
RANLIB='m68k-amigaos-ranlib',
|
||||
LD='m68k-amigaos-ld')
|
||||
make('libnix', 'install')
|
||||
|
||||
copy('{sources}/libnix/sources/headers/stabs.h',
|
||||
'{target}/m68k-amigaos/sys-include')
|
||||
|
@ -345,8 +345,8 @@ def make():
|
|||
'--prefix={target}',
|
||||
'--host=i686-linux-gnu',
|
||||
'--target=m68k-amigaos')
|
||||
build('{libm}')
|
||||
install('{libm}')
|
||||
make('{libm}')
|
||||
make('{libm}', 'install')
|
||||
|
||||
with cwd('{sources}'):
|
||||
remove('{gpp}')
|
||||
|
@ -361,8 +361,8 @@ def make():
|
|||
'--target=m68k-amigaos',
|
||||
'--enable-languages=c++',
|
||||
'--with-headers={sources}/{ixemul}/include')
|
||||
build('{gpp}', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul')
|
||||
install('{gpp}', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul')
|
||||
make('{gpp}', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul')
|
||||
make('{gpp}', 'install', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul')
|
||||
|
||||
|
||||
def clean():
|
||||
|
@ -387,7 +387,7 @@ if __name__ == "__main__":
|
|||
panic('Build on %s architecture not supported!', platform.machine())
|
||||
|
||||
parser = argparse.ArgumentParser(description='Build cross toolchain.')
|
||||
parser.add_argument('action', choices=['make', 'clean'], default='make',
|
||||
parser.add_argument('action', choices=['build', 'clean'], default='build',
|
||||
help='perform action')
|
||||
parser.add_argument('--binutils', choices=['2.9.1'], default='2.9.1',
|
||||
help='desired binutils version')
|
||||
|
|
|
@ -9,6 +9,7 @@ from os import environ
|
|||
import argparse
|
||||
import logging
|
||||
import platform
|
||||
import sys
|
||||
|
||||
URLS = \
|
||||
['ftp://ftp.gnu.org/gnu/gmp/gmp-5.1.3.tar.bz2',
|
||||
|
@ -30,9 +31,9 @@ URLS = \
|
|||
from common import * # NOQA
|
||||
|
||||
|
||||
@check_stamp
|
||||
@recipe('{sdk}-prepare')
|
||||
def prepare_sdk():
|
||||
info('preparing SDK')
|
||||
info('preparing {sdk}')
|
||||
|
||||
base = ''
|
||||
clib2 = ''
|
||||
|
@ -41,7 +42,7 @@ def prepare_sdk():
|
|||
with cwd('{sources}'):
|
||||
for arc in ['base.lha', 'clib2-*.lha', 'newlib-*.lha']:
|
||||
info('extracting "%s"' % arc)
|
||||
execute('lha', '-xifq', path.join('{archives}', 'SDK_53.24.lha'),
|
||||
execute('lha', '-xifq', path.join('{archives}', '{sdk}.lha'),
|
||||
path.join('SDK_Install', arc))
|
||||
base = path.join('{sources}', glob('base*.lha')[0])
|
||||
clib2 = path.join('{sources}', glob('clib2*.lha')[0])
|
||||
|
@ -54,7 +55,7 @@ def prepare_sdk():
|
|||
move('Include', 'include')
|
||||
|
||||
|
||||
def make():
|
||||
def build():
|
||||
for var in environ.keys():
|
||||
if var not in ['_', 'LOGNAME', 'HOME', 'SHELL', 'TMPDIR', 'PWD']:
|
||||
del environ[var]
|
||||
|
@ -94,29 +95,29 @@ def make():
|
|||
'--disable-shared',
|
||||
'--prefix={host}',
|
||||
copy_source=True)
|
||||
build('{lha}')
|
||||
install('{lha}')
|
||||
make('{lha}')
|
||||
make('{lha}', 'install')
|
||||
|
||||
unpack('{texinfo}')
|
||||
configure('{texinfo}',
|
||||
'--prefix={host}')
|
||||
build('{texinfo}')
|
||||
install('{texinfo}')
|
||||
make('{texinfo}')
|
||||
make('{texinfo}', 'install')
|
||||
|
||||
unpack('{gmp}')
|
||||
configure('{gmp}',
|
||||
'--disable-shared',
|
||||
'--prefix={host}')
|
||||
build('{gmp}')
|
||||
install('{gmp}')
|
||||
make('{gmp}')
|
||||
make('{gmp}', 'install')
|
||||
|
||||
unpack('{mpfr}')
|
||||
configure('{mpfr}',
|
||||
'--disable-shared',
|
||||
'--prefix={host}',
|
||||
'--with-gmp={host}')
|
||||
build('{mpfr}')
|
||||
install('{mpfr}')
|
||||
make('{mpfr}')
|
||||
make('{mpfr}', 'install')
|
||||
|
||||
unpack('{mpc}')
|
||||
configure('{mpc}',
|
||||
|
@ -124,16 +125,16 @@ def make():
|
|||
'--prefix={host}',
|
||||
'--with-gmp={host}',
|
||||
'--with-mpfr={host}')
|
||||
build('{mpc}')
|
||||
install('{mpc}')
|
||||
make('{mpc}')
|
||||
make('{mpc}', 'install')
|
||||
|
||||
unpack('{isl}')
|
||||
configure('{isl}',
|
||||
'--disable-shared',
|
||||
'--prefix={host}',
|
||||
'--with-gmp-prefix={host}')
|
||||
build('{isl}')
|
||||
install('{isl}')
|
||||
make('{isl}')
|
||||
make('{isl}', 'install')
|
||||
|
||||
unpack('{cloog}')
|
||||
configure('{cloog}',
|
||||
|
@ -142,8 +143,8 @@ def make():
|
|||
'--with-isl=system',
|
||||
'--with-gmp-prefix={host}',
|
||||
'--with-isl-prefix={host}')
|
||||
build('{cloog}')
|
||||
install('{cloog}')
|
||||
make('{cloog}')
|
||||
make('{cloog}', 'install')
|
||||
|
||||
binutils_env = {}
|
||||
if cmpver('eq', '{binutils_ver}', '2.18'):
|
||||
|
@ -156,8 +157,8 @@ def make():
|
|||
configure('{binutils}',
|
||||
'--prefix={target}',
|
||||
'--target=ppc-amigaos')
|
||||
build('{binutils}')
|
||||
install('{binutils}')
|
||||
make('{binutils}')
|
||||
make('{binutils}', 'install')
|
||||
|
||||
prepare_sdk()
|
||||
|
||||
|
@ -182,8 +183,8 @@ def make():
|
|||
'--enable-sjlj-exceptions'
|
||||
'--disable-libstdcxx-pch'
|
||||
'--disable-tls')
|
||||
build('{gcc}')
|
||||
install('{gcc}')
|
||||
make('{gcc}')
|
||||
make('{gcc}', 'install')
|
||||
|
||||
|
||||
def clean():
|
||||
|
@ -207,7 +208,7 @@ if __name__ == "__main__":
|
|||
panic('Build on %s architecture not supported!', platform.machine())
|
||||
|
||||
parser = argparse.ArgumentParser(description='Build cross toolchain.')
|
||||
parser.add_argument('action', choices=['make', 'clean'], default='make',
|
||||
parser.add_argument('action', choices=['build', 'clean'], default='build',
|
||||
help='perform action')
|
||||
parser.add_argument('--binutils', choices=['2.18', '2.23.2'], default='2.18',
|
||||
help='desired binutils version')
|
||||
|
@ -229,6 +230,7 @@ if __name__ == "__main__":
|
|||
cloog='cloog-0.18.4',
|
||||
texinfo='texinfo-4.12',
|
||||
binutils='binutils-{binutils_ver}',
|
||||
sdk='SDK_53.29',
|
||||
gcc='gcc-{gcc_ver}',
|
||||
patches=path.join('{top}', 'patches'),
|
||||
stamps=path.join('{top}', '.build-ppc', 'stamps'),
|
||||
|
|
Loading…
Reference in New Issue