linux confure文件参数配置build,host,target


http://hujianjust.blog.163.com/blog/static/724550722010321199621/

关于 configure的 build,host,target编译选项的理解

2008-01-31 12:51
考:http://www.airs.com/ian/configure/configure_toc.html
Reference:
http://www.tcpdump.org/lists/workers/2001/11/msg00148.html
Nope. See `info standards' for the definition of $build*, $host* and
$target* macros. Basically, $build* refer to the system compilation is
being performed on, $host* refer to the system compiled binaries are to
run on and $target* refer to the system compiled binaries will handle. As
such $target* usually have a meaning a meaning for developemt tool only.
So far packages that make use of $target* I know of are binutils, gcc,
gdb and ksymoops (a Linux run-time error disassembler). Let's take
binutils as an example. I compile it in several ways, following are

examples of configure invocations:
1. `./configure --build=mipsel-linux --host=mipsel-linux
--target=mipsel-linux' will build native mipsel-linux binutils on
mipsel-linux.
2. `./configure --build=i386-linux --host=mipsel-linux
--target=mipsel-linux' will cross-build native mipsel-linux binutils on
i386-linux.
3. `./configure --build=i386-linux --host=i386-linux
--target=mipsel-linux' will build mipsel-linux cross-binutils on
i386-linux.
4. `./configure --build=mipsel-linux --host=i386-linux
--target=mipsel-linux' will cross-build mipsel-linux cross-binutils for
i386-linux on mipsel-linux.
As you see, only if $build != $host a cross-compilation is performed.

个人理解:
build:执行代码编译的主机,正常的话就是你的主机系统。这个参数一般由config.guess来猜就可以。当然自己指定也可以。
host:编译出来的二进制程序所执行的主机,因为绝大多数是如果本机编译,本机执行。所以这个值就等于build。只有交叉编译的时候(也就是本机编译,其他系统机器执行)才会build和host不同。用host指定运行主机。
target:这个选项只有在建立交叉编译环境的时候用到,正常编译和交叉编译都不会用到。他用build主机上的编译器,编译一个新的编译器(
binutils, gcc,gdb等 ),这个新的编译器将来编译出来的其他程序将运行在 target指定的系统上。
让我们以编译binutils为例:
1. `./configure --build=mipsel-linux --host=mipsel-linux --target=mipsel-linux'
说明我们利用
mipsel-linux的编译器对 binutils进行编译,编译出来的 binutils运行在 mipsel-linux ,这个 binutils用来编译能够在 mipsel-linux运行的代码。“当然没有人会用这个选项来编译 binutils”
2. `./configure --build=i386-linux --host=mipsel-linux
--target=mipsel-linux' will cross-build native mipsel-linux binutils oni386-linux.

说明我们利用 i386-linux 的编译器对 binutils进行编译,编译出来的 binutils运行在 mipsel-linux ,这个 binutils用来编译能够在 mipsel-linux运行的代码。“这个选项可以用来为其他的机器编译它的编译器 ”。

3. `./configure --build=i386-linux --host=i386-linux
--target=mipsel-linux' will build mipsel-linux cross-binutils on i386-linux.
说明我们利用 i386-linux 的编译器对 binutils进行编译,编译出来的 binutils运行在 i386-linux ,这个 binutils用来编译能够在 mipsel-linux运行的代码。“这个选项用来在i386主机上建立一个 mipsel-linux的 交叉编译环境 ”。

4. `./configure --build=mipsel-linux --host=i386-linux
--target=mipsel-linux' will cross-build mipsel-linux cross-binutils for
i386-linux on mipsel-linux.
说明我们利用 mipsel-linux 的编译器对 binutils进行编译,编译出来的 binutils运行在 i386-linux ,这个 binutils用来编译能够在 mipsel-linux运行的代码。“这个选项可以用来在i386主机上建立一个 mipsel-linux的 交叉编译环境 ,但是交叉编译环境在 mipsel-linux 编译出来,安装到i386-linux主机上,估计没有多少人会这么用吧

总的来说,只有host !=build的时候编译才是交叉编译。否则就是正常编译。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值