[19622ea] | 1 | # |
---|
| 2 | # RTEMS Tools Project (http://www.rtems.org/) |
---|
[b7a13ab] | 3 | # Copyright 2010-2014 Chris Johns (chrisj@rtems.org) |
---|
[19622ea] | 4 | # All rights reserved. |
---|
| 5 | # |
---|
| 6 | # This file is part of the RTEMS Tools package in 'rtems-tools'. |
---|
| 7 | # |
---|
| 8 | # RTEMS Tools is free software: you can redistribute it and/or modify |
---|
| 9 | # it under the terms of the GNU General Public License as published by |
---|
| 10 | # the Free Software Foundation, either version 3 of the License, or |
---|
| 11 | # (at your option) any later version. |
---|
| 12 | # |
---|
| 13 | # RTEMS Tools is distributed in the hope that it will be useful, |
---|
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | # GNU General Public License for more details. |
---|
| 17 | # |
---|
| 18 | # You should have received a copy of the GNU General Public License |
---|
| 19 | # along with RTEMS Tools. If not, see <http://www.gnu.org/licenses/>. |
---|
| 20 | # |
---|
| 21 | |
---|
| 22 | # |
---|
| 23 | # This code is based on what ever doco about spec files I could find and |
---|
| 24 | # RTEMS project's spec files. |
---|
| 25 | # |
---|
| 26 | |
---|
| 27 | import pprint |
---|
| 28 | import os |
---|
| 29 | |
---|
[db65c6a] | 30 | import check |
---|
[11e7146] | 31 | import error |
---|
[19622ea] | 32 | import execute |
---|
| 33 | |
---|
| 34 | def load(): |
---|
| 35 | uname = os.uname() |
---|
| 36 | sysctl = '/sbin/sysctl ' |
---|
| 37 | e = execute.capture_execution() |
---|
| 38 | exit_code, proc, output = e.shell(sysctl + 'hw.ncpu') |
---|
| 39 | if exit_code == 0: |
---|
[0add2ea] | 40 | ncpus = output.split(' ')[1].strip() |
---|
[19622ea] | 41 | else: |
---|
[0add2ea] | 42 | ncpus = '1' |
---|
[19622ea] | 43 | if uname[4] == 'amd64': |
---|
| 44 | cpu = 'x86_64' |
---|
| 45 | else: |
---|
| 46 | cpu = uname[4] |
---|
| 47 | version = uname[2] |
---|
| 48 | if version.find('-') > 0: |
---|
| 49 | version = version.split('-')[0] |
---|
| 50 | defines = { |
---|
[a14171f] | 51 | '_ncpus': ('none', 'none', ncpus), |
---|
| 52 | '_os': ('none', 'none', 'freebsd'), |
---|
| 53 | '_host': ('triplet', 'required', cpu + '-freebsd' + version), |
---|
| 54 | '_host_vendor': ('none', 'none', 'pc'), |
---|
| 55 | '_host_os': ('none', 'none', 'freebsd'), |
---|
| 56 | '_host_os_version': ('none', 'none', version), |
---|
| 57 | '_host_cpu': ('none', 'none', cpu), |
---|
| 58 | '_host_alias': ('none', 'none', '%{nil}'), |
---|
| 59 | '_host_arch': ('none', 'none', cpu), |
---|
| 60 | '_usr': ('dir', 'required', '/usr/local'), |
---|
| 61 | '_var': ('dir', 'optional', '/usr/local/var'), |
---|
| 62 | '__bash': ('exe', 'optional', '/usr/local/bin/bash'), |
---|
| 63 | '__bison': ('exe', 'required', '/usr/local/bin/bison'), |
---|
| 64 | '__git': ('exe', 'required', '/usr/local/bin/git'), |
---|
| 65 | '__svn': ('exe', 'required', '/usr/local/bin/svn'), |
---|
| 66 | '__xz': ('exe', 'optional', '/usr/bin/xz'), |
---|
| 67 | '__make': ('exe', 'required', 'gmake'), |
---|
| 68 | '__patch_opts': ('none', 'none', '-E') |
---|
[19622ea] | 69 | } |
---|
[db65c6a] | 70 | |
---|
| 71 | defines['_build'] = defines['_host'] |
---|
| 72 | defines['_build_vendor'] = defines['_host_vendor'] |
---|
| 73 | defines['_build_os'] = defines['_host_os'] |
---|
| 74 | defines['_build_cpu'] = defines['_host_cpu'] |
---|
| 75 | defines['_build_alias'] = defines['_host_alias'] |
---|
| 76 | defines['_build_arch'] = defines['_host_arch'] |
---|
| 77 | |
---|
[f3b5490] | 78 | # FreeBSD 10 and above no longer have /usr/bin/cvs, but it can (e.g.) be |
---|
| 79 | # installed to /usr/local/bin/cvs through the devel/cvs port |
---|
[462f915] | 80 | fb_version = int(float(version)) |
---|
| 81 | if fb_version >= 10: |
---|
[11e7146] | 82 | # |
---|
| 83 | # FreeBSD has switched to clang plus gcc. On 10.0 cc is gcc based and |
---|
| 84 | # clang is provided however it is not building binutils-2.24. |
---|
| 85 | # |
---|
[527515c] | 86 | cc = '/usr/bin/cc' |
---|
| 87 | if check.check_exe(cc, cc): |
---|
| 88 | defines['__cc'] = cc |
---|
[11e7146] | 89 | else: |
---|
| 90 | cc = '/usr/bin/clang' |
---|
| 91 | if not check.check_exe(cc, cc): |
---|
[d15a7f8] | 92 | raise error.general('no valid cc found') |
---|
[527515c] | 93 | cxx = '/usr/bin/c++' |
---|
| 94 | if check.check_exe(cxx, cxx): |
---|
| 95 | defines['__cxx'] = cxx |
---|
[11e7146] | 96 | else: |
---|
| 97 | cxx = '/usr/bin/clang++' |
---|
| 98 | if check.check_exe(cxx, cxx): |
---|
[d15a7f8] | 99 | raise error.general('no valid c++ found') |
---|
[5821b02] | 100 | # |
---|
| 101 | # Assume the compiler is clang and so we need to increase |
---|
| 102 | # bracket depth build build the gcc ARM compiler. |
---|
| 103 | # |
---|
| 104 | defines['build_cflags'] = '-O2 -pipe -fbracket-depth=1024' |
---|
| 105 | defines['build_cxxflags'] = '-O2 -pipe -fbracket-depth=1024' |
---|
[b7a13ab] | 106 | cvs = 'cvs' |
---|
| 107 | if check.check_exe(cvs, cvs): |
---|
| 108 | defines['__cvs'] = cvs |
---|
[f3b5490] | 109 | # |
---|
| 110 | # Fix the mess iconv is on FreeBSD 10.0. |
---|
| 111 | # |
---|
[0ffee19] | 112 | defines['iconv_includes'] = ('none', 'none', '-I/usr/local/include -L/usr/local/lib') |
---|
[462f915] | 113 | |
---|
| 114 | # |
---|
| 115 | # On 11.0+ makeinfo and install-info have moved to /usr/local/... |
---|
| 116 | # |
---|
| 117 | if fb_version >= 11: |
---|
| 118 | defines['__install_info'] = ('exe', 'optional', '/usr/local/bin/install-info') |
---|
| 119 | defines['__makeinfo'] = ('exe', 'required', '/usr/local/bin/makeinfo') |
---|
[d15a7f8] | 120 | else: |
---|
| 121 | for gv in ['49', '48', '47']: |
---|
| 122 | gcc = '%s-portbld-freebsd%s-gcc%s' % (cpu, version, gv) |
---|
| 123 | if check.check_exe(gcc, gcc): |
---|
| 124 | defines['__cc'] = gcc |
---|
| 125 | break |
---|
| 126 | for gv in ['49', '48', '47']: |
---|
| 127 | gxx = '%s-portbld-freebsd%s-g++%s' % (cpu, version, gv) |
---|
| 128 | if check.check_exe(gxx, gxx): |
---|
| 129 | defines['__cxx'] = gxx |
---|
| 130 | break |
---|
[db65c6a] | 131 | |
---|
[19622ea] | 132 | return defines |
---|
| 133 | |
---|
| 134 | if __name__ == '__main__': |
---|
| 135 | pprint.pprint(load()) |
---|