0

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.

Community
  • 1
  • 1
guenni_90
  • 511
  • 5
  • 11
  • I'm not sure I understand the nature of the problem. Why do you need to build components for different host types in the same build? Are the helpers supportive only of *the build*, or are they installable pieces of the package? – John Bollinger Apr 27 '17 at 16:45
  • @john Yes, you are right. These helper programs are _only_ for build and not installation on the target. – guenni_90 Apr 28 '17 at 09:30

1 Answers1

1

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.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157