LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1036|回复: 1

有关debian下编译嵌入式交叉环境

[复制链接]
发表于 2006-10-2 21:44:39 | 显示全部楼层 |阅读模式
各位帮帮忙:

http://www.emdebian.org
上面介绍了关于如何建立嵌入式交叉编译环境
可是我的apt源是

deb ftp://debian.ustc.edu.cn/debian stable main non-free contrib
deb-src ftp://debian.ustc.edu.cn/debian stable main non-free contrib

deb ftp://debian.ustc.edu.cn/debian proposed-updates main contrib non-free
deb-src ftp://debian.ustc.edu.cn/debian proposed-updates main contrib non-free

deb ftp://debian.ustc.edu.cn/debian-security stable/updates main


当按照他的步骤走的时候
第一步就出现:

E: Unable to find a source package for binutils

我倒
我这不能上外网

没办法在他那上面下载编译好的

只能自己编译
可是
这个源不支持

各位能不能帮我想想办法啊
小弟在此谢谢了
 楼主| 发表于 2006-10-2 21:47:51 | 显示全部楼层
他上面的编译过程是:

1. Binutils.

Let's assume you have apt'able slind source repository. To obtain binutils sources, issue:

$ apt-get source binutils=2.16.1-2.slind1

and step into binutils source tree:

$ cd binutils-2.16.1

Now, in case you're building for an uclibc target, issue the following command:

$ env TARGET=<cpu>-linux LIBC_TARGET=uclibc fakeroot debian/rules binary-cross

and that will get you a binutils package. If your target of choice is glibc, then instead of the command above, issue:

$ env TARGET=<cpu> fakeroot debian/rules binary-cross

Now that you have a cross binutils package, install it using

$ dpkg -i ../binutils-<gnuarch>_2.16.1-2.slind1_i386.deb

2. Linux kernel headers.

Obtain linux-kernel-headers sources with the following command:

$ apt-get source linux-kernel-headers=2.6.12.0-1.slind1

and step into the source tree

$ cd linux-kernel-headers-2.6.12.0.orig

Build the package with

$ dpkg-buildpackage -uc -us -rfakeroot -a<arch> -b -d

Now you have to cast a dpkg-cross spell upon this package to make it usable in your cross development environment:

$ cd ..

$ dpkg-cross -a<arch> -b linux-kernel-headers_2.6.12.0-1.slind1_<arch>.deb

And install the freshly built cross-package with

$ dpkg -i linux-kernel-headers-<arch>-cross_2.6.12.0-1.slind1_all.deb

3. Libc development headers.

3.1. For a glibc target, get the glibc sources with

$ apt-get source glibc=2.3.2.ds1-22.slind1

$ cd glibc-2.3.2.ds1

To build the libc6-dev-headers package, issue:

$ env DEB_CROSS_BOOTSTRAP=yes dpkg-buildpackage -uc -us -rfakeroot -a<arch> -b -d

$ cd ..

Run dpkg-cross over the resulting package:

$ dpkg-cross -a<arch> -b libc6-dev-headers_2.3.2.ds1-22.slind1_<arch>.deb

And install with:

$ dpkg -i libc6-dev-headers-<arch>-cross_2.3.2.ds1-22.slind1_all.deb

3.2 For uclibc target, get the uclibc sources with

$ apt-get source uclibc=0.9.28-1slind0

$ cd uclibc-0.9.28

Build the package with

$ env DEB_CROSS_BOOTSTRAP=yes dpkg-buildpackage -uc -us -rfakeroot -a<arch> -b -d

$ cd ..

Call dpkg-cross and install the final package:

$ dpkg-cross -a<arch> -b libuclibc-dev-headers_0.9.28-1slind0_<arch>.deb

$ dpkg -i libuclibc-dev-headers-<arch>-cross_0.9.28-1slind0_all.deb

4. Bootstrap compiler.

Get the sources for gcc-3.4:

$ apt-get source gcc-3.4=3.4.4-5.slind1

$ cd gcc-3.4-3.4.4

To build a bootstrap compiler package, issue:

$ env GCC_TARGET=<arch> DEB_CROSS_BOOTSTRAP=yes dpkg-buildpackage -uc -us -rfakeroot -b -d

$ cd ..

Now, install the packages with

$ dpkg -i gcc-3.4-<gnuarch>_3.4.4-5.slind1_i386.deb cpp-3.4-<gnuarch>_3.4.4-5.slind1_i386.deb libgcc1-<arch>-cross_3.4.4-5.slind1_all.deb

Now that you have a bootstrap compiler, it's time to build real libc packages.

5. C library.

First of all, you should remove the package with libc development headers. So, for glibc, do

$ dpkg --remove libc6-dev-headers-<arch>-cross_2.3.2.ds1-22.slind1_all.deb

or, in case of uclibc target:

$ dpkg --remove libuclibc-dev-headers-<arch>-cross_0.9.28-1slind0_all.deb

5.1. For glibc, do the following:

$ cd glibc-2.3.2.ds1

$ dpkg-buildpacakge -uc -us -rfakeroot -a<arch> -b -d

$ cd ..

Run dpkg-cross over the packages:

$ dpkg-cross -a<arch> -b libc6_2.3.2.ds1-22.slind1_<arch>.deb libc6-dev_2.3.2.ds1-22.slind1_<arch>.deb

and install them:

$ dpkg -i libc6-<arch>-cross_2.3.2.ds1-22.slind1_all.deb libc6-dev-<arch>-cross_2.3.2.ds1-22.slind1_all.deb

5.2. For an uclibc target, do the following:

$ cd uclibc-0.9.28

$ dpkg-buildpackage -uc -us -rfakeroot -a<arch> -b -d

$ cd ..

Run dpkg-cross:

$ dpkg-cross -a<arch> -b libuclibc0_0.9.28-1slind0_<arch>.deb libuclibc-dev_0.9.28-1slind0_<arch>.deb

And install the packages:

$ dpkg -i libuclibc0-<arch>-cross_0.9.28-1slind0_all.deb libuclibc-dev-<arch>-cross_0.9.28-1slind0_all.deb

6. Build the final compiler.

This one is quite easy as well:

$ cd gcc-3.4-3.4.4

$ env GCC_TARGET=<arch> DEB_TARGET_LIBCXX=yes dpkg-buildpackage -uc -us -rfakeroot -b -d

Note, that if you don't need c++ development packages, you may omit the DEB_TARGET_LIBCXX=yes part.

Now, install the whole lot of gcc packages:

$ dpkg -i gcc-3.4-<gnuarch>_3.4.4-5.slind1_i386.deb cpp-3.4-<gnuarch>_3.4.4-5.slind1_i386.deb libgcc1-<arch>-cross_3.4.4-5.slind1_all.deb

(and c++ related packages, if any)

$ dpkg -i g++-3.4-<gnuarch>_3.4.4-5.slind1_i386.deb libstdc++6-<arch>-cross_3.4.4-5.slind1_all.deb libstdc++6-dev-<arch>-cross_3.4.4-5.slind1_all.deb

Congratulations!
You managed to build a cross-compilation toolchain for your favourite <arch> architecture.
Have fun!

Sincerely,

Your toolchain master <alexander.shishkin _at_ siemens.com>
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表