1 | # |
---|
2 | # RTEMS Tools Project (http://www.rtems.org/) |
---|
3 | # Copyright 2010-2014 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 | # Redistribution and use in source and binary forms, with or without |
---|
9 | # modification, are permitted provided that the following conditions are met: |
---|
10 | # |
---|
11 | # 1. Redistributions of source code must retain the above copyright notice, |
---|
12 | # this list of conditions and the following disclaimer. |
---|
13 | # |
---|
14 | # 2. Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | # this list of conditions and the following disclaimer in the documentation |
---|
16 | # and/or other materials provided with the distribution. |
---|
17 | # |
---|
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
---|
22 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
23 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
25 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
26 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
27 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
28 | # POSSIBILITY OF SUCH DAMAGE. |
---|
29 | # |
---|
30 | |
---|
31 | # |
---|
32 | # This code is based on what ever doco about spec files I could find and |
---|
33 | # RTEMS project's spec files. |
---|
34 | # |
---|
35 | |
---|
36 | import pprint |
---|
37 | import os |
---|
38 | |
---|
39 | import check |
---|
40 | import execute |
---|
41 | |
---|
42 | def load(): |
---|
43 | uname = os.uname() |
---|
44 | sysctl = '/sbin/sysctl ' |
---|
45 | e = execute.capture_execution() |
---|
46 | exit_code, proc, output = e.shell(sysctl + 'hw.ncpu') |
---|
47 | if exit_code == 0: |
---|
48 | ncpus = output.split(' ')[1].strip() |
---|
49 | else: |
---|
50 | ncpus = '1' |
---|
51 | if uname[4] == 'amd64': |
---|
52 | cpu = 'x86_64' |
---|
53 | else: |
---|
54 | cpu = uname[4] |
---|
55 | version = uname[2] |
---|
56 | if version.find('-') > 0: |
---|
57 | version = version.split('-')[0] |
---|
58 | defines = { |
---|
59 | '_ncpus': ('none', 'none', ncpus), |
---|
60 | '_os': ('none', 'none', 'freebsd'), |
---|
61 | '_host': ('triplet', 'required', cpu + '-freebsd' + version), |
---|
62 | '_host_vendor': ('none', 'none', 'pc'), |
---|
63 | '_host_os': ('none', 'none', 'freebsd'), |
---|
64 | '_host_cpu': ('none', 'none', cpu), |
---|
65 | '_host_alias': ('none', 'none', '%{nil}'), |
---|
66 | '_host_arch': ('none', 'none', cpu), |
---|
67 | '_usr': ('dir', 'required', '/usr/local'), |
---|
68 | '_var': ('dir', 'optional', '/usr/local/var'), |
---|
69 | '__bash': ('exe', 'optional', '/usr/local/bin/bash'), |
---|
70 | '__bison': ('exe', 'required', '/usr/local/bin/bison'), |
---|
71 | '__git': ('exe', 'required', '/usr/local/bin/git'), |
---|
72 | '__svn': ('exe', 'required', '/usr/local/bin/svn'), |
---|
73 | '__xz': ('exe', 'optional', '/usr/bin/xz'), |
---|
74 | '__make': ('exe', 'required', 'gmake'), |
---|
75 | '__patch_opts': ('none', 'none', '-E') |
---|
76 | } |
---|
77 | |
---|
78 | defines['_build'] = defines['_host'] |
---|
79 | defines['_build_vendor'] = defines['_host_vendor'] |
---|
80 | defines['_build_os'] = defines['_host_os'] |
---|
81 | defines['_build_cpu'] = defines['_host_cpu'] |
---|
82 | defines['_build_alias'] = defines['_host_alias'] |
---|
83 | defines['_build_arch'] = defines['_host_arch'] |
---|
84 | |
---|
85 | for gv in ['47', '48', '49']: |
---|
86 | gcc = '%s-portbld-freebsd%s-gcc%s' % (cpu, version, gv) |
---|
87 | if check.check_exe(gcc, gcc): |
---|
88 | defines['__cc'] = gcc |
---|
89 | break |
---|
90 | for gv in ['47', '48', '49']: |
---|
91 | gxx = '%s-portbld-freebsd%s-g++%s' % (cpu, version, gv) |
---|
92 | if check.check_exe(gxx, gxx): |
---|
93 | defines['__cxx'] = gxx |
---|
94 | break |
---|
95 | |
---|
96 | return defines |
---|
97 | |
---|
98 | if __name__ == '__main__': |
---|
99 | pprint.pprint(load()) |
---|