| || |
The main cross compiling issue in a `Makefile' arises when you want to use a subsidiary program to generate code or data which you will then include in your real program. If you compile this subsidiary program using `$(CC)' in the usual way, you will not be able to run it. This is because `$(CC)' will build a program for the host system, but the program is being built on the build system. You must instead use a compiler for the build system, rather than the host system. This compiler is conventionally called `$(CC_FOR_BUILD)' .
A `configure' script should normally permit the user to define `CC_FOR_BUILD' explicitly in the environment. Your configure script should help by selecting a reasonable default value. If the `configure' script is not being run with a cross compiler (i.e., the `cross_compiling' shell variable is `no' after calling `AC_PROG_CC' ), then the proper default for `CC_FOR_BUILD' is simply `$(CC)' . Otherwise, a reasonable default is simply `cc' .
Note that you should not include `config.h' in a file you are compiling with `$(CC_FOR_BUILD)' . The `configure' script will build `config.h' with information for the host system. However, you are compiling the file using a compiler for the build system (a native compiler). Subsidiary programs are normally simple filters which do no user interaction, and it is often possible to write them in a highly portable fashion so that the absence of `config.h' is not crucial.