source: rtems-source-builder/source-builder/sb/darwin.py @ a293ddc

5
Last change on this file since a293ddc was 34d7e0c, checked in by Chris Johns <chrisj@…>, on 10/23/17 at 04:32:12

darwin: Allow xz to live anywhere.

  • Property mode set to 100644
File size: 3.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 os
26
27import execute
28
29def load():
30    uname = os.uname()
31    sysctl = '/usr/sbin/sysctl '
32    e = execute.capture_execution()
33    exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
34    if exit_code == 0:
35        ncpus = output.split(' ')[1].strip()
36    else:
37        ncpus = '1'
38    version = uname[2]
39    if version.find('.'):
40        version = version.split('.')[0]
41    defines = {
42        '_ncpus':           ('none',    'none',     ncpus),
43        '_os':              ('none',    'none',     'darwin'),
44        '_host':            ('triplet', 'required', uname[4] + '-apple-darwin' + uname[2]),
45        '_host_vendor':     ('none',    'none',     'apple'),
46        '_host_os':         ('none',    'none',     'darwin'),
47        '_host_os_version': ('none',    'none',     version),
48        '_host_cpu':        ('none',    'none',     uname[4]),
49        '_host_alias':      ('none',    'none',     '%{nil}'),
50        '_host_arch':       ('none',    'none',     uname[4]),
51        '_usr':             ('dir',     'optional', '/usr/local'),
52        '_var':             ('dir',     'optional', '/usr/local/var'),
53        '_prefix':          ('dir',     'optional', '%{_usr}'),
54        '__ldconfig':       ('exe',     'none',     ''),
55        '__cvs':            ('exe',     'optional', 'cvs'),
56        '__xz':             ('exe',     'required', 'xz'),
57        'with_zlib':        ('none',    'none',     '--with-zlib=no'),
58        '_forced_static':   ('none',    'none',     ''),
59        '_ld_library_path': ('none',    'none',     'DYLD_LIBRARY_PATH')
60        }
61
62    if version.find('.'):
63        version = version.split('.')[0]
64        if int(version) >= 13:
65            defines['__cc'] = ('exe',     'required', '/usr/bin/cc')
66            defines['__cxx'] = ('exe',     'required', '/usr/bin/c++')
67            defines['build_cflags'] = '-O2 -pipe -fbracket-depth=1024'
68            defines['build_cxxflags'] = '-O2 -pipe -fbracket-depth=1024'
69
70    defines['_build']        = defines['_host']
71    defines['_build_vendor'] = defines['_host_vendor']
72    defines['_build_os']     = defines['_host_os']
73    defines['_build_cpu']    = defines['_host_cpu']
74    defines['_build_alias']  = defines['_host_alias']
75    defines['_build_arch']   = defines['_host_arch']
76
77    return defines
78
79if __name__ == '__main__':
80    import pprint
81    pprint.pprint(load())
Note: See TracBrowser for help on using the repository browser.