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

Contents of /eclass/crosscompile.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Fri Jul 18 20:11:22 2003 UTC (16 years, 11 months ago) by tester
Branch: MAIN
Branch point for: RELEASE-1_4
Changes since 1.4: +3 -1 lines
Adding amd64/x86_64 to a few eclasses

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

  ViewVC Help
Powered by ViewVC 1.1.20