Reputation: 551
i am right now working on restructuring the autotools project lnav to be buildable with yocto. That means lnav itself has to be cross-compiled, while some helper programs have to build natively.
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.
Upvotes: 0
Views: 192
Reputation: 180745
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. 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. 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.
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.
Upvotes: 1