/[gentoo-x86]/eclass/crosscompile.eclass
Gentoo

Contents of /eclass/crosscompile.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Wed Oct 13 14:13:46 2004 UTC (10 years, 2 months ago) by vapier
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +1 -1 lines
FILE REMOVED
no longer used; toolchain eclasses now

1 # Copyright 1999-2004 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/crosscompile.eclass,v 1.9 2004/06/25 00:39:48 vapier Exp $
4 # Author: Zachary T Welch
5
6 inherit flag-o-matic
7
8 ECLASS=crosscompile
9 INHERITED="$INHERITED $ECLASS"
10
11 DESCRIPTION="Based on the ${ECLASS} eclass"
12
13 # CBUILD is the --build for configure
14 # CHOST is the --host for configure
15 # CCHOST is the --target for configure
16
17 extract-arch() {
18 local ISSPARC=$(expr "${1}" : sparc64)
19
20 if [ $(expr "${1}" : 'i[3456]86') -eq 4 ]; then
21 echo "i386"
22 elif [ $(expr "${1}" : alpha) -eq 5 ]; then
23 echo "alpha"
24 elif [ $(expr "${1}" : arm) -eq 3 ]; then
25 echo "arm"
26 elif [ $(expr "${1}" : hppa) -eq 4 ]; then
27 echo "parisc"
28 elif [ $(expr "${1}" : mips) -eq 4 ]; then
29 echo "mips"
30 elif [ $(expr "${1}" : powerpc) -eq 7 ]; then
31 echo "ppc"
32 elif [ ${ISSPARC} -eq 5 ]; then
33 echo "sparc"
34 elif [ ${ISSPARC} -eq 7 ]; then
35 echo "sparc64"
36 elif [ $(expr "${1}" : x86_64) -eq 5 ]; then
37 echo "x86_64"
38 else
39 echo "unknown"
40 fi
41 }
42
43 build-arch() {
44 extract-arch "${CBUILD}"
45 }
46 chost-arch() {
47 extract-arch "${CHOST}"
48 }
49 target-arch() {
50 extract-arch "${CCHOST}"
51 }
52
53
54 # this function tests to see if we are currently
55 # building something for another host
56 cross-build() {
57 [ -n "${CBUILD}" ] && [ "${CBUILD}" != "${CHOST}" ]
58 }
59
60 # this function tests to see if we are currently
61 # building something that targets another host
62 # this is useful primarily for cross-compiling tools
63 # These tools are typically available in parallel
64 # or in extension to the native toolchain(s).
65 # NOTE: ebuilds must presently handle this type of
66 # parallel installs themselves, but most packages
67 # that support --target should provide most of it
68 cross-target() {
69 [ -n "${CCHOST}" ] && [ "${CHOST}" != "${CCHOST}" ]
70 }
71
72
73 # cross-setslot sets the SLOT for a cross-targetable ebuild
74 # this prevents portage from unmerging the native version
75 cross-setslot() {
76 # IMPORTANT, this only works because cross-compiling uses
77 # arch-CCHOST categories in the portage overlay to fake
78 # portage into thinking it sees a new CATEGORY/PACKAGE
79 SLOT="${1}"
80 # in the future, we should be able to do the following:
81 # cross-target && SLOT="${1}-${CCHOST}" || SLOT="${1}"
82
83 }
84
85 # The compiler will need to be able to find the header files
86 # and libs from $ROOT
87 cross-setflags() {
88 CFLAGS="${CFLAGS} -I${ROOT}/usr/include -L${ROOT}lib -L${ROOT}usr/lib"
89 CXXFLAGS=${CFLAGS}
90 }
91
92 # this function should be called by all packages that want
93 # to be cross-compile compatible and safe about it.
94 # Right now, we take away a couple of obvious bullets from the
95 # guns aimed at users' toes... what others remain?
96 cross-check() {
97 if cross-build
98 then
99 # if we're cross compiling,
100 # be sure to set ROOT or risk overwriting native versions
101 if [ "${ROOT}" = "/" ]; then
102 eerror "You are cross-compiling and have not set ROOT"
103 die
104 fi
105
106 # Sets CC and CXX to the correct compilers
107 CC=${CHOST}-gcc
108 CXX=${CHOST}-gcc
109
110 # For want of a better way I am using filter-flags to
111 # invalidate and march or mcpu flags then strip-flags
112 # removes any invalid flags.
113 # -march=athlonx-xp won't work when targeting something
114 # other than an athlon-xp.
115 # The correct CFLAGS really needs to get set for CHOST.
116 filter-flags "-march= -mcpu="
117 strip-flags
118 fi
119 }
120
121 # This function is just for diagnostic purposes. It prints the
122 # environment flags to do with building packages then abort
123 # the emerge. Saves me having to put a lot of echos in an
124 # ebuild just to check a few environment variables.
125 # Aiken 31/03/2003
126 cross-diag() {
127 cat <<-__EOD__
128 CATEGORY = ${CATEGORY}
129 DEPEND = ${DEPEND}
130 CBUILD = ${CBUILD}
131 CHOST = ${CHOST}
132 CCHOST = ${CCHOST}
133 CC = ${CC}
134 CXX = ${CXX}
135 CFLAGS = ${CFLAGS}
136 CXXFLAGS = ${CXXFLAGS}
137 CPPFLAGS = ${CPPFLAGS}
138 LDPATH = ${LDPATH}
139 PV = ${PV}
140 SLOT = ${SLOT}
141 ROOT = ${ROOT}
142 PATH = ${PATH}
143 __EOD__
144 die "Diagnostics complete"
145 }
146
147 # Create a config.cache that works in the cross compile case.
148 # Not all packages need this which is good. Generate a local
149 # config cache then remove information that is specific to
150 # building for the host.
151 # Aiken 31/03/2003
152 cross-configure() {
153 # Run configure to generate a config.cache
154 CC=gcc ./configure --cache-file=config.cache
155 mv config.cache config.cache-orig
156 make distclean
157
158 # Remove the host specific information.
159 grep -v \
160 -e bigendian \
161 -e ac_cv_env_CC \
162 -e ac_cv_env_build_alias \
163 -e ac_cv_env_host_alias \
164 -e ac_cv_env_target_alias \
165 -e ac_cv_env_CFLAGS \
166 -e ac_cv_host \
167 -e ac_cv_host_alias \
168 -e ac_cv_lib_termcap_tgetent \
169 -e ac_cv_prog_AR \
170 -e ac_cv_prog_CPP \
171 -e ac_cv_prog_ac_ct_CC \
172 -e ac_cv_prog_ac_ct_RANLIB \
173 -e _cv_termcap_lib \
174 config.cache-orig > config.cache
175 }

  ViewVC Help
Powered by ViewVC 1.1.20