1 |
vapier 07/12/24 20:26:21 |
2 |
|
3 |
Modified: cross-compiling-packages.xml |
4 |
Log: |
5 |
add some real information |
6 |
|
7 |
Revision Changes Path |
8 |
1.2 xml/htdocs/proj/en/base/embedded/handbook/cross-compiling-packages.xml |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-compiling-packages.xml?rev=1.2&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-compiling-packages.xml?rev=1.2&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-compiling-packages.xml?r1=1.1&r2=1.2 |
13 |
|
14 |
Index: cross-compiling-packages.xml |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-compiling-packages.xml,v |
17 |
retrieving revision 1.1 |
18 |
retrieving revision 1.2 |
19 |
diff -u -r1.1 -r1.2 |
20 |
--- cross-compiling-packages.xml 26 Aug 2007 13:21:49 -0000 1.1 |
21 |
+++ cross-compiling-packages.xml 24 Dec 2007 20:26:21 -0000 1.2 |
22 |
@@ -1,7 +1,7 @@ |
23 |
<?xml version='1.0' encoding='UTF-8'?> |
24 |
<!DOCTYPE sections SYSTEM "/dtd/book.dtd"> |
25 |
|
26 |
-<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-compiling-packages.xml,v 1.1 2007/08/26 13:21:49 vapier Exp $ --> |
27 |
+<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-compiling-packages.xml,v 1.2 2007/12/24 20:26:21 vapier Exp $ --> |
28 |
|
29 |
<sections> |
30 |
|
31 |
@@ -43,6 +43,169 @@ |
32 |
</tr> |
33 |
</table> |
34 |
|
35 |
+<p> |
36 |
+You can either set this all by hand, but that obviously gets quite tedious very |
37 |
+quickly. A better idea is to stick these into a shell script so you can avoid |
38 |
+typing it out all the time. |
39 |
+</p> |
40 |
+ |
41 |
+</body> |
42 |
+</section> |
43 |
+ |
44 |
+<section> |
45 |
+<title>Filesystem Setup</title> |
46 |
+<body> |
47 |
+ |
48 |
+<p> |
49 |
+Cross-compiling a system generally involves two directory trees. The first is |
50 |
+where all development files are normally installed. This is your sysroot. The |
51 |
+other tree is where only your runtime files are installed. You emerge all of |
52 |
+your fun packages into your sysroot (without trimming down any files), and then |
53 |
+either install via binary packages or copying files by hand all the stuff you |
54 |
+need in your runtime tree. |
55 |
+</p> |
56 |
+ |
57 |
+<p> |
58 |
+The common convention is to use your <path>/usr/CTARGET/</path> tree as your |
59 |
+sysroot as the include/library directories in this tree are already encoded |
60 |
+into the gcc cross-compiler for searching. You could use another directory |
61 |
+and then add custom -I/-L paths to your CPPFLAGS/LDFLAGS, but this has |
62 |
+historically proven to be problematic. Yes it works most of the time, but |
63 |
+the corner cases are why this method is discouraged. In the embedded handbook, |
64 |
+we'll assume you're using the sysroot as your development ROOT. |
65 |
+</p> |
66 |
+ |
67 |
+<p> |
68 |
+For your runtime system, you'll need a much slimmer/trimmed down setup. The |
69 |
+files you remove from a normal installed package is why this tree is not |
70 |
+suitable for compiling against. If you build binary packages while installing |
71 |
+into your sysroot, then you can use those binary packages in conjunction with |
72 |
+the <c>INSTALL_MASK</c> variable to trim out most things. See the make.conf(5) |
73 |
+man page for more information. |
74 |
+</p> |
75 |
+ |
76 |
+</body> |
77 |
+</section> |
78 |
+ |
79 |
+<section> |
80 |
+<title>Environment Setup</title> |
81 |
+<body> |
82 |
+ |
83 |
+<p> |
84 |
+Once you've select your sysroot path, you'll have to setup the portage |
85 |
+environment just like you setup your host when you first installed. That |
86 |
+means you have to create the <path>make.conf</path> and <path>make.profile</path> |
87 |
+for your target system. You'll also need to setup <path>make.globals</path>. |
88 |
+</p> |
89 |
+ |
90 |
+<pre caption="SYSROOT/etc/make.conf"> |
91 |
+ACCEPT_KEYWORDS="ppc" |
92 |
+ARCH="ppc" |
93 |
+CHOST="powerpc-softfloat-linux-uclibc" |
94 |
+CFLAGS="-Os -pipe" |
95 |
+CXXFLAGS="${CFLAGS}" |
96 |
+GENTOO_MIRRORS="http://open-systems.ufl.edu/mirrors/gentoo \ |
97 |
+ http://prometheus.cs.wmich.edu/gentoo \ |
98 |
+ http://mirror.datapipe.net/gentoo \ |
99 |
+ http://ftp.ucsb.edu/pub/mirrors/linux/gentoo/" |
100 |
+INPUT_DEVICES="keyboard" |
101 |
+MAKEOPTS="-j2" |
102 |
+USE="-* minimal" |
103 |
+</pre> |
104 |
+ |
105 |
+<p> |
106 |
+The <path>make.globals</path> file is common arch-independent defaults. So we |
107 |
+can just cheat and symlink it. |
108 |
+</p> |
109 |
+ |
110 |
+<pre caption="SYSROOT/etc/make.globals"> |
111 |
+# <i>ln -s /etc/make.globals SYSROOT/etc/make.globals</i> |
112 |
+</pre> |
113 |
+ |
114 |
+<p> |
115 |
+Then for the <path>make.profile</path>, just create a symlink like normal. |
116 |
+</p> |
117 |
+ |
118 |
+<pre caption="SYSROOT/etc/make.profile"> |
119 |
+# <i>ln -s /usr/portage/profiles/uclibc/ppc SYSROOT/etc/make.profile</i> |
120 |
+</pre> |
121 |
+ |
122 |
+</body> |
123 |
+</section> |
124 |
+ |
125 |
+<section> |
126 |
+<title>Helper: xmerge</title> |
127 |
+<body> |
128 |
+ |
129 |
+<p> |
130 |
+A simple wrapper script will setup the environment variables to point to the |
131 |
+right places and then run <c>emerge</c>. This script expects you to have setup |
132 |
+the environment variable <c>SYSROOT</c> already. |
133 |
+</p> |
134 |
+ |
135 |
+<pre caption="sample xmerge"> |
136 |
+#!/bin/sh |
137 |
+export CBUILD=$(portageq envvar CHOST) |
138 |
+export PORTAGE_CONFIGROOT=${SYSROOT} |
139 |
+if [ "$1" = "--root" ] ; then |
140 |
+ export ROOT=$2 |
141 |
+ shift 2 |
142 |
+else |
143 |
+ export ROOT=${SYSROOT} |
144 |
+fi |
145 |
+exec emerge "$@" |
146 |
+</pre> |
147 |
+ |
148 |
+<p> |
149 |
+Now you can use this for both installing into your development root (sysroot) |
150 |
+and into your runtime root. For the latter, simply specify by using the --root |
151 |
+option. |
152 |
+</p> |
153 |
+ |
154 |
+</body> |
155 |
+</section> |
156 |
+ |
157 |
+<section> |
158 |
+<title>Helper: pkg-config</title> |
159 |
+<body> |
160 |
+ |
161 |
+<p> |
162 |
+Many packages are moving to installing pkg-config files (*.pc) and using those |
163 |
+to discover needed libraries and includes. To ease the build process, you |
164 |
+should install a pkg-config wrapper for your target which will tell pkg-config |
165 |
+to only search your cross-compiler paths rather than your host paths. |
166 |
+</p> |
167 |
+ |
168 |
+<p> |
169 |
+You should install this into your PATH so that configure scripts will detect it |
170 |
+properly. Name it with a CTARGET prefix and the script will do the rest. In |
171 |
+other words, the canonical name is <c>CTARGET-pkg-config</c>. Older configure |
172 |
+scripts would only search for <c>pkg-config</c>, so in those cases you will |
173 |
+need to export the <c>PKG_CONFIG</c> variable to the wrapper script. |
174 |
+</p> |
175 |
+ |
176 |
+<pre caption="cross-pkg-config wrapper"> |
177 |
+#!/bin/sh |
178 |
+CTARGET=${0%-pkg-config} |
179 |
+SYSROOT="/usr/${CTARGET}" |
180 |
+export PKG_CONFIG_LIBDIR="${SYSROOT}/usr/lib/pkgconfig" |
181 |
+unset PKG_CONFIG_ALLOW_SYSTEM_CFLAGS PKG_CONFIG_ALLOW_SYSTEM_LIBS |
182 |
+exec pkg-config "$@" |
183 |
+</pre> |
184 |
+ |
185 |
+</body> |
186 |
+</section> |
187 |
+ |
188 |
+<section> |
189 |
+<title>Uninstall</title> |
190 |
+<body> |
191 |
+ |
192 |
+<p> |
193 |
+If you want to uninstall and delete your work, then you can safely remove the |
194 |
+sysroot tree without affecting any native packages. See also the section in |
195 |
+the <uri link="cross-compiler.xml">crossdev guide</uri> about uninstalling. |
196 |
+</p> |
197 |
+ |
198 |
</body> |
199 |
</section> |
200 |
|
201 |
|
202 |
|
203 |
|
204 |
-- |
205 |
gentoo-commits@g.o mailing list |