kbuild: save ARCH & CROSS_COMPILE when building a kernel

When building a kernel for a different architecture
kbuild requires the user always to specify ARCH and
CROSS_COMPILE on the command-line.

We use the asm symlink to detect if user forgets to
specify the correct ARCH value - but that symlink
is about to die. And we do now want to loose this check.

This patch save the settings of ARCH and CROSS_COMPILE
in two files named:

    include/generated/kernel.arch
    include/generated/kernel.cross

The settings are saved during "make *config" time
and always read.

If user try to change the settings we error out.

This works both for plain builds and for O=...
builds.

So now you can do:
$ mkdir sparc64
$ make O=sparc64 ARCH=sparc64 CROSS_COMPILE=sparc64-linux- defconfig
$ cd sparc64
$ make

Notice that you no longer need to tell kbuild
the settings of ARCH and CROSS_COMPILE when you type make
in the output directory.

Likewise for plain builds where you do not use O=...

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roland McGrath <roland@redhat.com>
1 file changed