source: rtems-source-builder/tb/linux.py @ 19622ea

4.104.114.95
Last change on this file since 19622ea was bf13d27, checked in by Chris Johns <chrisj@…>, on 10/29/12 at 23:37:12

Initial import.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2012 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#
21# This code is based on what ever doco about spec files I could find and
22# RTEMS project's spec files.
23#
24
25import pprint
26import os
27
28import execute
29
30def load():
31    uname = os.uname()
32    smp_mflags = ''
33    processors = '/bin/grep processor /proc/cpuinfo'
34    e = execute.capture_execution()
35    exit_code, proc, output = e.shell(processors)
36    if exit_code == 0:
37        cpus = 0
38        for l in output.split('\n'):
39            count = l.split(':')[1].strip()
40            if count > cpus:
41                cpus = int(count)
42        if cpus > 0:
43            smp_mflags = '-j%d' % (cpus)
44    defines = {
45        '_os':                     'linux',
46        '_host':                   uname[4] + '-linux-gnu',
47        '_host_vendor':            'gnu',
48        '_host_os':                'linux',
49        '_host_cpu':               uname[4],
50        '_host_alias':             '%{nil}',
51        '_host_arch':              uname[4],
52        '_usr':                    '/usr',
53        '_var':                    '/usr/var',
54        'optflags':                '-O2 -fasynchronous-unwind-tables',
55        '_smp_mflags':             smp_mflags,
56        '__bzip2':                 '/usr/bin/bzip2',
57        '__gzip':                  '/bin/gzip',
58        '__tar':                   '/bin/tar'
59        }
60    return defines
61
62if __name__ == '__main__':
63    pprint.pprint(load())
Note: See TracBrowser for help on using the repository browser.