Changeset 3badbb0 in rtems-tools


Ignore:
Timestamp:
Jan 18, 2015, 7:12:18 AM (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
f381f26
Parents:
3f47178
Message:

Add support to cross-compile. Use --hosti=.

On FreeBSD use --host=mingw32 for Windows. If you use another
OS you might need to add the specific windows host to the
top level wscript file.

Files:
3 edited
5 moved

Legend:

Unmodified
Added
Removed
  • linkers/wscript

    r3f47178 r3badbb0  
    4242                        rtemstoolkit + '/elftoolchain/common',
    4343                        rtemstoolkit + '/libiberty']
     44    if bld.env.DEST_OS == 'win32':
     45        conf['includes'] += [rtemstoolkit + '/win32']
    4446    conf['warningflags'] = ['-Wall', '-Wextra', '-pedantic']
    4547    conf['optflags'] = bld.env.C_OPTS
  • rtemstoolkit/wscript

    r3f47178 r3badbb0  
    3939    #
    4040    conf['includes'] = ['elftoolchain/libelf', 'elftoolchain/common', 'libiberty']
    41     if sys.platform == 'win32':
     41    if bld.env.DEST_OS == 'win32':
    4242        conf['includes'] += ['win32']
    4343
     
    123123    if sys.platform == 'win32':
    124124        m4_rule = 'type ${SRC} | m4 -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + '> ${TGT}"'
     125    else:
     126        m4_rule = 'm4 -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + ' ${SRC} > ${TGT}'
     127    if bld.env.DEST_OS == 'win32':
    125128        includes = ['win32']
    126129    else:
    127         m4_rule = 'm4 -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + ' ${SRC} > ${TGT}'
    128130        includes = []
    129131
     
    134136    host_source = []
    135137
    136     if sys.platform == 'linux2':
     138    if bld.env.DEST_OS == 'linux2':
    137139        common = 'elftoolchain/common/'
    138140        bld(target = common + 'native-elf-format.h',
     
    141143            rule   = './${SRC} > ${TGT}')
    142144        bld.add_group ()
    143     elif sys.platform == 'win32':
     145    elif bld.env.DEST_OS == 'win32':
    144146        host_source += [libelf + 'mmap_win32.c']
    145147
     
    148150              install_path = None,
    149151              uses = ['native-elf-format'],
    150               includes = [bld.bldnode.abspath(), 'elftoolchain/libelf', 'elftoolchain/common'] + includes,
     152              includes = [bld.bldnode.abspath(),
     153                          'elftoolchain/libelf', 'elftoolchain/common'] + includes,
    151154              cflags = conf['cflags'],
    152155              source =[libelf + 'elf.c',
     
    231234
    232235def bld_libiberty(bld, conf):
    233     if sys.platform == 'win32':
     236    if bld.env.DEST_OS == 'win32':
    234237        pex_host = 'libiberty/pex-win32.c'
    235238    else:
  • wscript

    r3f47178 r3badbb0  
    4747                   dest='c_opts',
    4848                   help = 'Set build options, default: -O2.')
     49    ctx.add_option('--host',
     50                   default = 'native',
     51                   dest='host',
     52                   help = 'Set host to build for, default: none.')
    4953    recurse(ctx)
     54
     55def init(ctx):
     56    try:
     57        import waflib.Options
     58        import waflib.ConfigSet
     59        env = waflib.ConfigSet.ConfigSet()
     60        env.load(waflib.Options.lockfile)
     61        check_options(ctx, env.options['host'])
     62        for sd in subdirs:
     63            ctx.recurse(sd)
     64    except:
     65        pass
    5066
    5167def configure(ctx):
     
    5672    ctx.env.C_OPTS = ctx.options.c_opts.split(',')
    5773    ctx.env.RTEMS_VERSION = ctx.options.rtems_version
     74    check_options(ctx, ctx.options.host)
    5875    recurse(ctx)
    5976
     
    7188    waflib.Options.commands.extend(['clean', 'build'])
    7289
     90def check_options(ctx, host):
     91    if host in ['mingw32']:
     92        ctx.env.HOST = host
     93        ctx.env.CC = '%s-gcc' % (host)
     94        ctx.env.CXX = '%s-g++' % (host)
     95        ctx.env.AR = '%s-ar' % (host)
     96        ctx.env.PYTHON = 'python'
     97    elif host is not 'native':
     98        ctx.fatal('unknown host: %s' % (host));
     99
    73100#
    74101# The doxy command.
Note: See TracChangeset for help on using the changeset viewer.