简体   繁体   English

自动工具-交叉编译和构建本机中间构建程序

[英]autotools - crosscompiling and building native intermediate building programs

i am right now working on restructuring the autotools project lnav to be buildable with yocto. 我现在正着手重组lnav的自动工具项目,使其可以使用yocto进行构建。 That means lnav itself has to be cross-compiled, while some helper programs have to build natively. 这意味着lnav本身必须交叉编译,而一些帮助程序必须本地构建。

I already found this thread this thread , but the first proposed solution does not work, while the 2nd is heavily invasive on the project structure. 我已经找到这个线程这个线程 ,但第一个提出的解决方案是不行的,而第二个是在项目结构严重侵入。

Can somebody give me a hint how to solve this? 有人可以给我提示如何解决这个问题吗? Maybe tell me which AC/AM Macros do the job or where to get a good example. 也许告诉我哪个AC / AM宏可以完成这项工作,或者在哪里可以得到一个很好的例子。

If you need to build different pieces for different execution hosts, then the cleanest way to go about it is to build the build tools separately. 如果您需要为不同的执行主机构建不同的组件,那么最干净的方法是分别构建构建工具。 One of the answers you linked describes a way to do this. 您链接的答案之一描述了执行此操作的方法。 If you have a well-written Autotools build system, however, then you might be able to tackle this differently, by leveraging out-of-source builds. 但是,如果您有一个写得很好的Autotools构建系统,那么您可以通过利用资源外构建来解决这个问题。 This can be scripted. 可以编写脚本。

Create a directory within which to build the tools. 创建一个目录以在其中构建工具。 In that directory, configure for the build system ( path-to-source-dir/configure ), and then build (just) the needed tools. 在该目录中,配置构建系统( path-to-source-dir/configure ),然后构建(仅)所需的工具。 Then in the source directory or a different out-of-source build directory, configure for the cross-compilation by specifying the appropriate --build and --host triplets to configure , copy or link the already-built tools into the build directory, and perform the rest of the build. 然后,在源目录或其他源外构建目录中,通过指定适当的--build--host三胞胎来configure ,复制或链接已构建的工具到构建目录中,以configure交叉编译。并执行其余的构建。

If the build system is especially carefully crafted, then you may need to overcome provisions for different executable extensions for the build tools on different hosts. 如果特别仔细地构建了构建系统,则可能需要克服针对不同主机上的构建工具的不同可执行扩展名的规定。 If you need to do this and you're planning to script the two-stage cross-compilation anyway, then you can probably handle the issue when you copy/link the tools; 如果您需要执行此操作,并且无论如何都打算编写两阶段交叉编译的脚本,则在复制/链接工具时可能可以解决该问题。 that will avoid any need to write special support for it into the core build system. 这样就避免了将任何特殊支持写入核心构建系统的需要。

To support cross-compilation in general, configure.ac should use the AC_CANONICAL_BUILD and AC_CANONICAL_HOST macros, and the build machine will need to have an appropriate cross-compilation toolchain installed. 通常,为了支持交叉编译, configure.ac应该使用AC_CANONICAL_BUILDAC_CANONICAL_HOST宏,并且构建计算机将需要安装适当的交叉编译工具链。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM