Following my posts about autotools improvements, I’d like to write a short post about another quite often misused macro provided by autoconf
, that I had to fix in lscube too.
The macro in question is AC_CANONICAL_TARGET
, which is used to provide the --host
/--build
and --target
options to ./configure
. What is the problem with that macro? Well in most cases you don’t want it at all, and you want to use, if anything, AC_CANONICAL_HOST
(which is not even needed, for most cases) that only provides --host
and --build
options.
Why is this? Well, the problem is that the --target
option is used only for compilers and other tools generating machine-dependent code. The meaning of the three names are as follows:
- the build machine is where you’re compiling the code (that is, building the source); it’s almost impossible that build doesn’t refer to the machine running
./configure
; - the host machine is where the project will run once built, when this differs from build, we’re crosscompiling;
- the target machine is the machine the software is going to generate code for, if this differs from host you’re building a cross-compiler.
It’s worth mentioning that if you try and set target for stuff other than compilers, weird things start happening like binary filenames (such as nano) getting prefixed with the triplet.