[ale] cross compiling

Ed Cashin ecashin at noserose.net
Mon May 5 11:55:44 EDT 2014


Responses will interleave with selected quotes below.

On Mon, May 5, 2014 at 11:00 AM, Boris Borisov <bugyatl at gmail.com> wrote:
> I'm trying to get my way around cross-compiling. I have host Debian 7.5 and
> the toolchain for mips. I'm working with patched 2.6.24.3 kernel because
> that is what runs on my device. So far I got how to compile the kernel for
> mips.

Congratulations.  It isn't always easy to build old kernels.  I used
to use VMs running old versions of RHEL to build old kernels.  It also
isn't always easy to cross compile!

> My question is how you are compiling module that is not in kernel tree.

I have some experience with that.  I checked out the rt73 sources from
sourceforge.

...
> Since the module package has its own Makefile: do you make changes in this
> Makefile or you start make with extra parameters?

Maybe it's helpful to break down how the parts of the build relate.
Sorry if you know all this, but the Module/Makefile inside rt73 looks
for the kernel sources via the expected "build" symlink:

    79  ifdef KERNDIR
    80   KERNEL_SOURCES := $(KERNDIR)
    81  else
    82   KERNEL_SOURCES := /lib/modules/$(shell uname -r)/build
    83  endif

... so you can do 'make KERNDIR=/path/to/my/sources' ... to specify your own.

It uses the KERNEL_SOURCES to build parameters for the build command:

   115  KBUILD_PARAMS := -C $(KERNEL_SOURCES) SUBDIRS=$(CURDIR) $(KERNEL_OUTPUT)

Notice the "-C" option.  That's going to cause make to change
directories to the kernel sources and to use the Makefile there.  So
this is a recursive make, where it starts out in the rt73 sources but
quickly changes to the kernel sources.

When it's (the child) make running on the Makefile in the kernel
sources, it's being told to build the modules in the subdirectories
$(SUBDIRS), which is set to be rt73's Module/ subdirectory.

Back when rt73 invoked this child make, it passed on the EXTRA_CFLAGS:

   127  module:
   128          @$(MAKE) $(KBUILD_PARAMS)
'EXTRA_CFLAGS=$(EXTRA_CFLAGS)' modules; \
   129          $(MODULE_CHECK)

... and that suggests that you can supply EXTRA_CFLAGS from your
invocation inside rt73's Module/ subdirectory.  You can also edit
Module/Makefile if you like.

With that example, you can probably think of ways to get other
variables to show up in the kernel build as well.

-- 
  Ed Cashin <ecashin at noserose.net>


More information about the Ale mailing list