[31d4e80] | 1 | #
|
---|
| 2 | # $Id$
|
---|
| 3 | #
|
---|
| 4 | # RTEMS Tools Project (http://www.rtems.org/)
|
---|
| 5 | # Copyright 2010 Chris Johns (chrisj@rtems.org)
|
---|
| 6 | # All rights reserved.
|
---|
| 7 | #
|
---|
| 8 | # This file is part of the RTEMS Tools package in 'rtems-tools'.
|
---|
| 9 | #
|
---|
| 10 | # RTEMS Tools is free software: you can redistribute it and/or modify
|
---|
| 11 | # it under the terms of the GNU General Public License as published by
|
---|
| 12 | # the Free Software Foundation, either version 3 of the License, or
|
---|
| 13 | # (at your option) any later version.
|
---|
| 14 | #
|
---|
| 15 | # RTEMS Tools is distributed in the hope that it will be useful,
|
---|
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | # GNU General Public License for more details.
|
---|
| 19 | #
|
---|
| 20 | # You should have received a copy of the GNU General Public License
|
---|
| 21 | # along with RTEMS Tools. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 22 | #
|
---|
| 23 |
|
---|
| 24 | #
|
---|
| 25 | # This code is based on what ever doco about spec files I could find and
|
---|
| 26 | # RTEMS project's spec files.
|
---|
| 27 | #
|
---|
| 28 |
|
---|
| 29 | import pprint
|
---|
| 30 | import os
|
---|
| 31 |
|
---|
| 32 | import execute
|
---|
| 33 |
|
---|
| 34 | def load():
|
---|
| 35 | uname = os.uname()
|
---|
| 36 | smp_mflags = ''
|
---|
| 37 | processors = '/bin/grep processor /proc/cpuinfo'
|
---|
| 38 | e = execute.capture_execution()
|
---|
| 39 | exit_code, proc, output = e.shell(processors)
|
---|
| 40 | if exit_code == 0:
|
---|
| 41 | cpus = 0
|
---|
| 42 | for l in output.split('\n'):
|
---|
| 43 | count = l.split(':')[1].strip()
|
---|
| 44 | if count > cpus:
|
---|
[a86cd82] | 45 | cpus = int(count)
|
---|
[31d4e80] | 46 | if cpus > 0:
|
---|
| 47 | smp_mflags = '-j%d' % (cpus)
|
---|
| 48 | defines = {
|
---|
| 49 | '_os': 'linux',
|
---|
| 50 | '_host': uname[4] + '-linux-gnu',
|
---|
| 51 | '_host_vendor': 'gnu',
|
---|
| 52 | '_host_os': 'linux',
|
---|
| 53 | '_host_cpu': uname[4],
|
---|
| 54 | '_host_alias': '%{nil}',
|
---|
| 55 | '_host_arch': uname[4],
|
---|
| 56 | '_usr': '/usr',
|
---|
| 57 | '_var': '/usr/var',
|
---|
| 58 | 'optflags': '-O2 -fasynchronous-unwind-tables',
|
---|
| 59 | '_smp_mflags': smp_mflags,
|
---|
[a86cd82] | 60 | '__bzip2': '/usr/bin/bzip2',
|
---|
[31d4e80] | 61 | '__gzip': '/bin/gzip',
|
---|
| 62 | '__tar': '/bin/tar'
|
---|
| 63 | }
|
---|
| 64 | return defines
|
---|
| 65 |
|
---|
| 66 | if __name__ == '__main__':
|
---|
| 67 | pprint.pprint(load())
|
---|