configure文件中的build、host、target含义

news/2024/7/4 9:08:12

 

 

configure文件中的build、host、target含义
   

今天阅读autobook[注1]一书,3.4节讲到了configuration name。书中提到了build、host、target这几个变量。看起来容易让人感到一些混淆,其实这极大的简化了二进制文件格式生成的控制。
build -- 在build系统中建立package
host -- 建立好package后,package能够在host运行
target -- 经由package所产生的可执行文件能够在target上运行。
 
例如:
在GNU/Linux系统上交叉编译一个可以在AIX机器上运行的package。那么
   build = i*86-pc-linux-gnu
    host = rs6000-ibm-aix3.2
   target = rs6000-ibm-aix3.2
GNU/Linux系统上建立一个交叉编译工具,此交叉编译工具可以在AIX上运行,由此交叉编译出来的文件可以在ARM上运行,那么:
   build = i*86-pc-linux-gnu
   host = rs6000-ibm-aix3.2
   target = arm-linux
 
由此可以看出,当建立一个package时,不必非在本地机器上建立,可以设置不同的configuration name来生成不同系统的package。
 
 
注:[1]autobook描述如何使用GNU提供的一系列autotools来管理复杂软件系统的开的。

 

 

 

 

 

 

 

 

关于configure的build,host,target编译选项 收藏

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

考: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的时候编译才是交叉编译。否则就是正常编译

 

 

 

 

 


http://www.niftyadmin.cn/n/4747387.html

相关文章

Android手机快捷键大全

Android手机快捷键大全 Posted by IA on 2010 年 12 月 24 日 Android手机的市场份额是越来越大,Android手机新用户也是越来越多,下面让我们来学习一下Android手机的快捷键,不管新手还是老手总会对你有用的! 全局快捷键启动(默认&…

linux应用层获取鼠标坐标

linux应用层获取鼠标坐标2011-01-13 22:46补充:在这个函数中要打开一个鼠标设备,但是在嵌入式的文件系统中没有这个设备节点,鼠标设备的主设备号和次设备号有是如何确定的呢?在 linux 系统中,鼠标和键盘的设备号都是固…

makefile解释及模板

调试makefile 收藏一个调试makefile文件的简便方法:那就是用make -p|tee make.out来输出make运行过程中产生的中间信息。make -n 就可以输出调试make 的运行——————一般来说,最简单的就是直接在命令行下输入make命令,make命令会找当前目…

miniGui开发进展解决

1.miniGUI中,可以在编译配置选项中设置UI风格。改为FLAT后,编译示例报错。说是myDrawButton没有定义。后来看了源码,才解决。原来定义FLAT时,还有个_GRAY_SCREEN宏开关,决定是否定义my&#xff…

springboot创建parent_SpringBoot 使用maven创建springboot项目

有两种方式可以创建 1是使用spring-boot-start-parent ,2是使用spring-boot-dependencies (即父项目dependencyManagement)(同理springcloud 项目也可以使用两种方式创建,推荐使用dependencyManagement,后续笔记中补充)1.使用 spring-boot-start-parent创建org.spr…

access数字类型对应mysql_Access数据库id类型由自动编号改成数字类型后如何再从数字类型改...

一套网页,初级小技术员编写的,多次用到了固定id的链接,如:a hreflist.asp?id11站内新闻/a。而客户恰好不慎将这个内容删除了。要修复,关键就是补上这个id,id字段又必须还是“自动编号”(其他内容可以让客户…

mysql ab复制原理_MYSQL AB复制原理

Mysql复制(replication)是一个异步的复制,从一个Mysql instace(称之为Master)复制到另一个Mysql instance(称之Slave)。实现整个复制操作主要由三个进程完成的,其中两个进程在Slave(Sql进程和IO进程),另外一个进程在 Master(IO进程)上。要实施…

易语言mysql管理源码下载_易语言MYSQL简化版管理程序源码

易语言MYSQL简化版管理程序源码易语言MYSQL简化版管理程序系统结构:服务是否启动,检测,停止服务,启动服务,安装,卸载服务,启动安装,启动缷载,创建事件同步对象,打开事件同步对象,SendMessage,SetWindowPos,窗口程序集1| || |------ __启动窗口_创建完毕| || |------ _气球提示框…