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 | sysctl = '/usr/sbin/sysctl ' |
---|
37 | e = execute.capture_execution() |
---|
38 | exit_code, proc, output = e.shell(sysctl + 'hw.ncpu') |
---|
39 | if exit_code == 0: |
---|
40 | smp_mflags = '-j' + output.split(' ')[1].strip() |
---|
41 | else: |
---|
42 | smp_mflags = '' |
---|
43 | defines = { |
---|
44 | '_os': 'darwin', |
---|
45 | '_host': uname[4] + '-apple-darwin' + uname[2], |
---|
46 | '_host_vendor': 'apple', |
---|
47 | '_host_os': 'darwin', |
---|
48 | '_host_cpu': uname[4], |
---|
49 | '_host_alias': '%{nil}', |
---|
50 | '_host_arch': uname[4], |
---|
51 | '_usr': '/opt/local', |
---|
52 | '_var': '/opt/local/var', |
---|
53 | 'optflags': '-O2 -fasynchronous-unwind-tables', |
---|
54 | '_smp_mflags': smp_mflags, |
---|
55 | '__xz': '/usr/local/bin/xz', |
---|
56 | # Work around the broken sed code on BSD sed |
---|
57 | #'without_gcc_std': 'True', |
---|
58 | 'with_zlib': '--with-zlib=no', |
---|
59 | } |
---|
60 | return defines |
---|
61 | |
---|
62 | if __name__ == '__main__': |
---|
63 | pprint.pprint(load()) |
---|