金庸书中张三丰:scratchbox添加工具链

来源:百度文库 编辑:九乡新闻网 时间:2024/04/19 23:12:08
参考:
http://www.scratchbox.org/wiki/ForeignToolchains
http://scratchbox.org/repos/1.0/sb-toolchain-extras/

sudo apt-get install darcs

sudo apt-get install dh-buildinfo

//拷贝工具链
sudo cp arm-linux/ -raf /scratchbox/compilers/arm-linux-gcc-3.4.5-glibc-2.3.3

//下载工具
cd /scratchbox
darcs get --set-scripts-executable http://scratchbox.org/repos/1.0/sb-toolchain-extras

//得到配置文件。记得要自己修改一下.conf文件
cd /scratchbox/compilers/arm-linux-gcc-3.4.5-glibc-2.3.3
/scratchbox/sb-toolchain-extras/confhelper/create_toolchain_conf.py > /scratchbox/sb-toolchain-extras/meta/alien-tc/arm-linux-gcc-3.4.5-glibc-2.3.3.conf

比如:
ARCH = arm
SUB_ARCH = $(ARCH)
VENDOR = unknown-
TOOLCHAIN_PREFIX_END = gnu-
TARGET_END = -gnu
交叉编译工具命名为:arm-unknown-linux-gnu-


//进到/scratchbox/sb-toolchain-extras文件夹之后
//下载东东,主要就是gdb之类的东西,如果下过一遍了,下次做的时候就别下了  :)
make CONFIG=meta/alien-tc/arm-linux-gcc-3.4.5-glibc-2.3.3.conf -C meta/alien-tc/ all-sums

//一般是不会出错了,如果出错,你就把出错的那个Makefile文件里面的关于gdb的那句话去掉就好了。
make CONFIG=meta/alien-tc/arm-linux-gcc-3.4.5-glibc-2.3.3.conf-C meta/alien-tc

//基本上你把工具链添加成功了

进入sb,然后sb-menu,创建你自己的target,让交叉编译见鬼去吧。

说实话,sb相对openembedded是要好控制一些。对于我们作嵌入式的,sb是个好东西。
如果大家有什么问题,可以到官方网站上看他们的邮件列表。如果我可以帮你,我也很乐意

--------------------------------------------------------------------------------------------------------------------------------
在Ubuntu 10.04和debian/squeeze系统上不能添加外部工具链,在编译步骤
make CONFIG=meta/alien-tc/arm-linux-gcc-3.4.5-glibc-2.3.3.conf -C meta/alien-tc
出现一些奇怪的错误,比如找不到文件,但是指定路径下明明有相应的文件,未解决。目前,只能在debian/lenny系统上添加外部工具链,之后通过命令打包
make tarbal deb CONFIG=meta/alien-tc/arm-linux-gcc-3.4.5-glibc-2.3.3.conf
拷贝到其他系统使用

Foreign Toolchains

This page describes how to use foreign toolchains, ie toolchains compiled outside scratchbox, such like [http://www.codesourcery.com/gnu_toolchains/developers.html CodeSourcery], [http://buildroot.uclibc.org/ BuildRoot] or [http://kegel.com/crosstool/ crosstool].

Finding a suitable toolchain for scratchbox

Not all prebuilt toolchains are going to work with sb. For arm, the toolchain should have C library and binutils, support for dynamic libraries, no TLS support (or relatively new qemu and/or 2.6 target kernel).

Installation

Unpacking

Extract the prebuilt toolchain to your COMPILER_DIR: eg.  /scratchbox/compilers/arm-linux-withmyhacks .

The COMPILER_DIR should probably now have subdirectories like bin,your-arch-name and lib.

For the alien wrapper to work, you must have Scratchbox version 1.0.3 or newer (Apophis branch) and the compiler must work when invoked directly, eg.

/scratchbox/compilers/arm-linux-withmyhacks/bin/your-arch-name-gcc --version

Configuring

To actually use the foreign toolchain in the scratchbox compilation environment, some configuration must be done. To be more precise, we need some tools for the target (eg. sbrsh, strace, fakeroot, gdb), some toolchain specific tools to the scratcbox (eg. libtool), a script to setup the target for this toolchain, and some meta-information about the architecture of the target so that scratchbox can provide sane build environment.

Fortunately, there are some more tools to aid through the configuration process.

  1. Setup the system as in building native [wiki:Toolchains Toolchains] (Compiling toolchains, steps 1-3), with exception that you must have perl and doctools devkits selected as well

  2. Unpack the toolchain you intend to use to /scratchbox/compilers/your-cool-compiler
  3. Fetch sb-toolchain-extras repository.

    darcs get --set-scripts-executable http://scratchbox.org/repos/1.0/sb-toolchain-extras
  4. Create the configuration file. This can be either done manually, or by using a helper.

Configuring using the create_toolchain_conf -helper

  1. Go to /scratchbox/compilers/your-cool-compiler directory.
  2. Run the helper-script

    ~/sb-toolchain-extras/confhelper/create_toolchain_conf.py 
  3. If the output looks sensible, you should store it inside sbtc-extras tree

    ~/sb-toolchain-extras/confhelper/create_toolchain_conf.py > ~/sb-toolchain-extras/meta/alien-tc/arm-mycoolhacks.conf
    Even if there is something wrong with the config, you can probably use that as a starting point in making the final configuration.

Configuring manually

  • Create your own configuration file into meta/alien-tc directory.

    • You can use some of the provided ones as a template.

Building auxiliary tools

  • Auxillary tools are toolchain-specific tools such as sbrshd, fakeroot, gdb and strace. these typically come with the toolchain package.
  • Change to ~/sb-toolchain-extras directory

  • If you are building the toolchain for the first time (eg. you have created a new config), you have to build the checksums too.

      make CONFIG=meta/alien-tc/yourconfig.conf -C meta/alien-tc all-sums
  • Build toolchain extras:

      make CONFIG=meta/alien-tc/yourconfig.conf -C meta/alien-tc

Create new target

Now you can use sb-menu to setup the target as usual. For quick testing, you can use tests/env/run.sh from http://scratchbox.org/repos/1.0/scratchbox.

Building packages

For redistribution, you probably want to build packages when you have working toolchains. Remember to redistribute the sources as well.

make tarball deb CONFIG=meta/alien-tc/yourconfig.conf

Former Issues

Target C library is not found at runtime

/lib/libc.so and/or /usr/lib/libc.so might contain absolute(and incorrect) pathnames; they should be removed.

The shadow package fails

You might get something like

aclocal: configure.in: 12: macro `AM_DISABLE_SHARED' not found in libraryaclocal: configure.in: 13: macro `AM_ENABLE_STATIC' not found in libraryaclocal: configure.in: 21: macro `AM_PROG_LIBTOOL' not found in library

if the libtool exists, but is misconfigured. Some versions don't install the m4 files to ./share/aclocal.

Perl

Perl might not compile, especially when using sbrsh. Most of the issues can be circumvented by compiling miniperl using host-gcc instead of target-gcc. Patch taken and modified from ["MIPS Crocodile"].


Other issues

Depending on your toolchain, you might need some additional compiler-prefixes into your scratchbox.config for some build-systems. Just add those to /targets/links/scratchbox.config, line SBOX_CROSS_GCC_PREFIX_LIST

e.g. If you get error like this:

make[1]: Entering directory `/home/jussi/crocodile/work/build/zlib-1.2.2/build-tree/zlib-1.2.2'arm-linux-gcc -O3 -g -D_REENTRANT -fPIC -DNO_snprintf -DHAS_sprintf_void -DNO_ERRNO_H   -c -o example.o example.csb_gcc_wrapper (arm-linux-gcc): arm-linux-gcc cannot be recognizedMaybe you are trying to run a compiler of a wrong architecture?make[1]: *** [example.o] Error 1

then just add arm-linux- to SBOX_CROSS_GCC_PREFIX_LIST in /targets/links/scratchbox.config.


Toolchains