Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract kernel headers for compiling kernel module later

Tags:

linux-kernel

I compiled various Linux kernel from git repositories. There are times when I copied the kernel to other system and need the kernel header to compile external module.

I tried to run "make headers_install" but it only generated a include/ folder. When I tried to point external module to that folder, it complains it cannot find Makefile.

What is the proper way to package kernel-header for deployment?

Thanks.

like image 740
Patrick Avatar asked Oct 21 '13 04:10

Patrick


2 Answers

Create kernel packages instead, that's "make deb-pkg" for dpkg based distros and "make rpm-pkg" for RPM based ones. These create multiple packages, one of those is a package usable for external modules building. That should be linux-headers-* for the Debian packages and a "devel" package for he RPM versions.

like image 106
Andreas Bombe Avatar answered Nov 09 '22 16:11

Andreas Bombe


In some ways this is just an expansion of the previous answer. If you look at the file scripts/package/builddeb in the kernel sources you will find script code which selects the files needed for building external modules from a kernel build and puts them into /usr/src/linux-headers-$version. I can find that script code in my local kernel version by searching for the string "# Build kernel header package" in the builddeb file. If you want to do things by hand you could execute that script code manually.

like image 33
michaeljt Avatar answered Nov 09 '22 16:11

michaeljt