source: rtems-tools/specbuilder/specbuilder/linux.py @ 31d4e80

4.104.11
Last change on this file since 31d4e80 was 31d4e80, checked in by Chris Johns <chrisj@…>, on Aug 31, 2010 at 12:58:45 AM

2010-08-31 Chris Johns <chrisj@…>

  • specbuilder/specbuilder/linux.py: Add Linux support. Can be useful on those distributions that do not support RPM packages. Users should always be encouraged to use the RPM packages provided by the project.
  • specbuilder/specbuilder/default.py: Add Linux.
  • Property mode set to 100644
File size: 2.2 KB
Line 
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
29import pprint
30import os
31
32import execute
33
34def 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:
45                cpus = count
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,
60        '__bzip2':                 '/bin/bzip2',
61        '__gzip':                  '/bin/gzip',
62        '__tar':                   '/bin/tar'
63        }
64    return defines
65
66if __name__ == '__main__':
67    pprint.pprint(load())
Note: See TracBrowser for help on using the repository browser.