/[gentoo-x86]/eclass/toolchain-funcs.eclass
Gentoo

Diff of /eclass/toolchain-funcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.102 Revision 1.106
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2007 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.102 2010/09/11 17:12:20 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.106 2011/09/09 19:14:19 vapier Exp $
4 4
5# @ECLASS: toolchain-funcs.eclass 5# @ECLASS: toolchain-funcs.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Toolchain Ninjas <toolchain@gentoo.org> 7# Toolchain Ninjas <toolchain@gentoo.org>
8# @BLURB: functions to query common info about the toolchain 8# @BLURB: functions to query common info about the toolchain
16___ECLASS_RECUR_TOOLCHAIN_FUNCS="yes" 16___ECLASS_RECUR_TOOLCHAIN_FUNCS="yes"
17[[ -z ${___ECLASS_RECUR_MULTILIB} ]] && inherit multilib 17[[ -z ${___ECLASS_RECUR_MULTILIB} ]] && inherit multilib
18 18
19DESCRIPTION="Based on the ${ECLASS} eclass" 19DESCRIPTION="Based on the ${ECLASS} eclass"
20 20
21# tc-getPROG <VAR [search vars]> <default> [tuple]
21tc-getPROG() { 22_tc-getPROG() {
22 local var=$1 23 local tuple=$1
24 local v var vars=$2
23 local prog=$2 25 local prog=$3
24 26
25 if [[ -n ${!var} ]] ; then 27 var=${vars%% *}
26 echo "${!var}" 28 for v in ${vars} ; do
27 return 0
28 fi
29
30 local search=
31 [[ -n $3 ]] && search=$(type -p "$3-${prog}")
32 [[ -z ${search} && -n ${CHOST} ]] && search=$(type -p "${CHOST}-${prog}")
33 [[ -n ${search} ]] && prog=${search##*/}
34
35 export ${var}=${prog}
36 echo "${!var}"
37}
38
39# @FUNCTION: tc-getAR
40# @USAGE: [toolchain prefix]
41# @RETURN: name of the archiver
42tc-getAR() { tc-getPROG AR ar "$@"; }
43# @FUNCTION: tc-getAS
44# @USAGE: [toolchain prefix]
45# @RETURN: name of the assembler
46tc-getAS() { tc-getPROG AS as "$@"; }
47# @FUNCTION: tc-getCC
48# @USAGE: [toolchain prefix]
49# @RETURN: name of the C compiler
50tc-getCC() { tc-getPROG CC gcc "$@"; }
51# @FUNCTION: tc-getCPP
52# @USAGE: [toolchain prefix]
53# @RETURN: name of the C preprocessor
54tc-getCPP() { tc-getPROG CPP cpp "$@"; }
55# @FUNCTION: tc-getCXX
56# @USAGE: [toolchain prefix]
57# @RETURN: name of the C++ compiler
58tc-getCXX() { tc-getPROG CXX g++ "$@"; }
59# @FUNCTION: tc-getLD
60# @USAGE: [toolchain prefix]
61# @RETURN: name of the linker
62tc-getLD() { tc-getPROG LD ld "$@"; }
63# @FUNCTION: tc-getSTRIP
64# @USAGE: [toolchain prefix]
65# @RETURN: name of the strip program
66tc-getSTRIP() { tc-getPROG STRIP strip "$@"; }
67# @FUNCTION: tc-getNM
68# @USAGE: [toolchain prefix]
69# @RETURN: name of the symbol/object thingy
70tc-getNM() { tc-getPROG NM nm "$@"; }
71# @FUNCTION: tc-getRANLIB
72# @USAGE: [toolchain prefix]
73# @RETURN: name of the archiver indexer
74tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; }
75# @FUNCTION: tc-getOBJCOPY
76# @USAGE: [toolchain prefix]
77# @RETURN: name of the object copier
78tc-getOBJCOPY() { tc-getPROG OBJCOPY objcopy "$@"; }
79# @FUNCTION: tc-getF77
80# @USAGE: [toolchain prefix]
81# @RETURN: name of the Fortran 77 compiler
82tc-getF77() { tc-getPROG F77 gfortran "$@"; }
83# @FUNCTION: tc-getFC
84# @USAGE: [toolchain prefix]
85# @RETURN: name of the Fortran 90 compiler
86tc-getFC() { tc-getPROG FC gfortran "$@"; }
87# @FUNCTION: tc-getGCJ
88# @USAGE: [toolchain prefix]
89# @RETURN: name of the java compiler
90tc-getGCJ() { tc-getPROG GCJ gcj "$@"; }
91# @FUNCTION: tc-getPKG_CONFIG
92# @USAGE: [toolchain prefix]
93# @RETURN: name of the pkg-config tool
94tc-getPKG_CONFIG() { tc-getPROG PKG_CONFIG pkg-config "$@"; }
95# @FUNCTION: tc-getRC
96# @USAGE: [toolchain prefix]
97# @RETURN: name of the Windows resource compiler
98tc-getRC() { tc-getPROG RC windres "$@"; }
99# @FUNCTION: tc-getDLLWRAP
100# @USAGE: [toolchain prefix]
101# @RETURN: name of the Windows dllwrap utility
102tc-getDLLWRAP() { tc-getPROG DLLWRAP dllwrap "$@"; }
103
104# @FUNCTION: tc-getBUILD_CC
105# @USAGE: [toolchain prefix]
106# @RETURN: name of the C compiler for building binaries to run on the build machine
107tc-getBUILD_CC() {
108 local v
109 for v in CC_FOR_BUILD BUILD_CC HOSTCC ; do
110 if [[ -n ${!v} ]] ; then 29 if [[ -n ${!v} ]] ; then
111 export BUILD_CC=${!v} 30 export ${var}="${!v}"
112 echo "${!v}" 31 echo "${!v}"
113 return 0 32 return 0
114 fi 33 fi
115 done 34 done
116 35
117 local search= 36 local search=
118 if [[ -n ${CBUILD} ]] ; then 37 [[ -n $4 ]] && search=$(type -p "$4-${prog}")
119 search=$(type -p ${CBUILD}-gcc) 38 [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}")
120 search=${search##*/} 39 [[ -n ${search} ]] && prog=${search##*/}
121 fi
122 search=${search:-gcc}
123 40
124 export BUILD_CC=${search} 41 export ${var}=${prog}
125 echo "${search}" 42 echo "${!var}"
126} 43}
44tc-getBUILD_PROG() { _tc-getPROG CBUILD "$@"; }
45tc-getPROG() { _tc-getPROG CHOST "$@"; }
46
47# @FUNCTION: tc-getAR
48# @USAGE: [toolchain prefix]
49# @RETURN: name of the archiver
50tc-getAR() { tc-getPROG AR ar "$@"; }
51# @FUNCTION: tc-getAS
52# @USAGE: [toolchain prefix]
53# @RETURN: name of the assembler
54tc-getAS() { tc-getPROG AS as "$@"; }
55# @FUNCTION: tc-getCC
56# @USAGE: [toolchain prefix]
57# @RETURN: name of the C compiler
58tc-getCC() { tc-getPROG CC gcc "$@"; }
59# @FUNCTION: tc-getCPP
60# @USAGE: [toolchain prefix]
61# @RETURN: name of the C preprocessor
62tc-getCPP() { tc-getPROG CPP cpp "$@"; }
63# @FUNCTION: tc-getCXX
64# @USAGE: [toolchain prefix]
65# @RETURN: name of the C++ compiler
66tc-getCXX() { tc-getPROG CXX g++ "$@"; }
67# @FUNCTION: tc-getLD
68# @USAGE: [toolchain prefix]
69# @RETURN: name of the linker
70tc-getLD() { tc-getPROG LD ld "$@"; }
71# @FUNCTION: tc-getSTRIP
72# @USAGE: [toolchain prefix]
73# @RETURN: name of the strip program
74tc-getSTRIP() { tc-getPROG STRIP strip "$@"; }
75# @FUNCTION: tc-getNM
76# @USAGE: [toolchain prefix]
77# @RETURN: name of the symbol/object thingy
78tc-getNM() { tc-getPROG NM nm "$@"; }
79# @FUNCTION: tc-getRANLIB
80# @USAGE: [toolchain prefix]
81# @RETURN: name of the archiver indexer
82tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; }
83# @FUNCTION: tc-getOBJCOPY
84# @USAGE: [toolchain prefix]
85# @RETURN: name of the object copier
86tc-getOBJCOPY() { tc-getPROG OBJCOPY objcopy "$@"; }
87# @FUNCTION: tc-getF77
88# @USAGE: [toolchain prefix]
89# @RETURN: name of the Fortran 77 compiler
90tc-getF77() { tc-getPROG F77 gfortran "$@"; }
91# @FUNCTION: tc-getFC
92# @USAGE: [toolchain prefix]
93# @RETURN: name of the Fortran 90 compiler
94tc-getFC() { tc-getPROG FC gfortran "$@"; }
95# @FUNCTION: tc-getGCJ
96# @USAGE: [toolchain prefix]
97# @RETURN: name of the java compiler
98tc-getGCJ() { tc-getPROG GCJ gcj "$@"; }
99# @FUNCTION: tc-getPKG_CONFIG
100# @USAGE: [toolchain prefix]
101# @RETURN: name of the pkg-config tool
102tc-getPKG_CONFIG() { tc-getPROG PKG_CONFIG pkg-config "$@"; }
103# @FUNCTION: tc-getRC
104# @USAGE: [toolchain prefix]
105# @RETURN: name of the Windows resource compiler
106tc-getRC() { tc-getPROG RC windres "$@"; }
107# @FUNCTION: tc-getDLLWRAP
108# @USAGE: [toolchain prefix]
109# @RETURN: name of the Windows dllwrap utility
110tc-getDLLWRAP() { tc-getPROG DLLWRAP dllwrap "$@"; }
111
112# @FUNCTION: tc-getBUILD_CC
113# @USAGE: [toolchain prefix]
114# @RETURN: name of the C compiler for building binaries to run on the build machine
115tc-getBUILD_CC() { tc-getBUILD_PROG "BUILD_CC CC_FOR_BUILD HOSTCC" gcc "$@"; }
116# @FUNCTION: tc-getBUILD_CPP
117# @USAGE: [toolchain prefix]
118# @RETURN: name of the C preprocessor for building binaries to run on the build machine
119tc-getBUILD_CPP() { tc-getBUILD_PROG "BUILD_CPP CPP_FOR_BUILD HOSTCPP" cpp "$@"; }
120# @FUNCTION: tc-getBUILD_CXX
121# @USAGE: [toolchain prefix]
122# @RETURN: name of the C++ compiler for building binaries to run on the build machine
123tc-getBUILD_CXX() { tc-getBUILD_PROG "BUILD_CXX CXX_FOR_BUILD HOSTCXX" g++ "$@"; }
127 124
128# @FUNCTION: tc-export 125# @FUNCTION: tc-export
129# @USAGE: <list of toolchain variables> 126# @USAGE: <list of toolchain variables>
130# @DESCRIPTION: 127# @DESCRIPTION:
131# Quick way to export a bunch of compiler vars at once. 128# Quick way to export a bunch of compiler vars at once.
275 m68*) echo m68k;; 272 m68*) echo m68k;;
276 mips*) echo mips;; 273 mips*) echo mips;;
277 nios2*) echo nios2;; 274 nios2*) echo nios2;;
278 nios*) echo nios;; 275 nios*) echo nios;;
279 powerpc*) 276 powerpc*)
280 # Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees 277 # Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees
281 # have been unified into simply 'powerpc', but until 2.6.16, 278 # have been unified into simply 'powerpc', but until 2.6.16,
282 # ppc32 is still using ARCH="ppc" as default 279 # ppc32 is still using ARCH="ppc" as default
283 if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] && [[ ${type} == "kern" ]] ; then 280 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then
284 echo powerpc 281 echo powerpc
285 elif [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]] && [[ ${type} == "kern" ]] ; then 282 elif [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]] ; then
286 if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]] ; then 283 if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
287 echo powerpc 284 echo powerpc
288 else 285 else
289 echo ppc 286 echo ppc
290 fi 287 fi
291 elif [[ ${host} == powerpc64* ]] ; then 288 elif [[ ${host} == powerpc64* ]] ; then
292 echo ppc64 289 echo ppc64
293 elif [[ ${PROFILE_ARCH} == "ppc64" ]] ; then 290 elif [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
294 ninj ppc64 ppc 291 ninj ppc64 ppc
295 else 292 else
296 echo ppc 293 echo ppc
297 fi 294 fi
298 ;; 295 ;;
299 s390*) echo s390;; 296 s390*) echo s390;;
300 sh64*) ninj sh64 sh;; 297 sh64*) ninj sh64 sh;;
301 sh*) echo sh;; 298 sh*) echo sh;;
302 sparc64*) ninj sparc64 sparc;; 299 sparc64*) ninj sparc64 sparc;;
303 sparc*) [[ ${PROFILE_ARCH} == "sparc64" ]] \ 300 sparc*) [[ ${PROFILE_ARCH} == "sparc64" ]] \
304 && ninj sparc64 sparc \ 301 && ninj sparc64 sparc \
305 || echo sparc 302 || echo sparc
306 ;; 303 ;;
307 vax*) echo vax;; 304 vax*) echo vax;;
305 x86_64*freebsd*) echo amd64;;
308 x86_64*) 306 x86_64*)
309 # Starting with linux-2.6.24, the 'x86_64' and 'i386' 307 # Starting with linux-2.6.24, the 'x86_64' and 'i386'
310 # trees have been unified into 'x86'. 308 # trees have been unified into 'x86'.
311 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]] ; then 309 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]] ; then
312 echo x86 310 echo x86

Legend:
Removed from v.1.102  
changed lines
  Added in v.1.106

  ViewVC Help
Powered by ViewVC 1.1.20