0

On an x86_64 host I have cross-compiled a Linux kernel for an ARM target out-of tree. So I have two directories:

  1. ~/kernel_git_repo/ - contains kernel source only
  2. ~/kernel_buld_dir/ - contains the .config file and built kernel objects

In a third directory

  1. ~/external_module - sources for an external kernel module

I have the source code for an external module, with a Makefile.

The "usual" command for an in-tree built kernel would be:

make -C <path-to-compiled-src-code> M=$(PWD) modules

For my out-of-tree built kernel, neither ~/kernel_git_repo/ nor ~/kernel_buld_dir/ work as <path-to-compiled-src-code>. It appears that the make command needs both the kernel source repo with the Kbuild infrastructure and the build directory with the .config file and the objects.

In this situation, what is the make command to use in the ~/external_module/Makefile for building the module?

Jonathan Ben-Avraham
  • 4,615
  • 2
  • 34
  • 37
  • You should use `make -C ~/kernel_build_dir` always when you did build your kernel with `make O=~/kernel_build_dir`. – 0andriy Jul 26 '19 at 17:06
  • Also, you need to provide an excerpt with the actual error that happens in the case I described in previous comment. – 0andriy Jul 26 '19 at 17:08

1 Answers1

0

You're right, it's essentially the same,

$(MAKE) -C  $(KDIR) SUBDIRS=$(shell pwd) modules

except

KDIR=/path/to/kernel/source