Re: build -->/usr/src/linux

Jamie Lokier
2001-04-09T15:02:58Z

Miquel van Smoorenburg wrote:
> >There is a way though I'd not call it clean. Here is an extract from
>
> Do you think something like this is the correct approach? If it
> was part of the official kernel you could write a Makefile like this:
>
> [code to creake /lib/modules/`uname -r`/config.mak

I agree with that idea in principle, although for quite a while
something else is required, to deal with older kernels. You'll notice
that my fragment greps for SMP from the kernel's Makefile: that is to
deal with 2.2 kernels and isn't required for 2.4 kernels. This is not
an issue if you only care about future-compatibility.

Fortunately, the file $(KERNEL_SOURCE)/arc/$(ARCH)/Makefile provides
most of the variables like CFLAGS et al.

Unfortunately, determining ARCH is rather ugly. I copied the expression
from the kernel's top level Makefile.

One more thing: some systems do not have a /lib/modules directory. On
those systems it's good to hunt in /usr/src/linux.

> -modules: include/config/MARKER $(patsubst %, _mod_%, $(SUBDIRS))
> +modules: include/config/MARKER $(patsubst %, _mod_%, $(SUBDIRS)) \
> + include/linux/config.mak

The file needs to be created even if you don't do `make modules'. Some
kernels will support third party modules, but don't actually have any
modules of their own.

> +include/linux/config.mak: ./Makefile

This must depend on the configuration somehow. If the kernel's
reconfigured, a new file needs to be created. For 2.2 kernels it must
depend on whether SMP is defined too.

-- Jamie