john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Make build from source

To use make to compile things for your kernel you'll need kernel headers installed.

Kernel header files (a.k.a. "kernel source" files) are a set of pre-compiled binary files reflecting your currently running kernel. Essentially the kernel headers are simply a "raw" mirror image of the kernel that's running your computer. You need kernel headers (or kernel source) files in order to make drivers, fix things etc..

uname -r shows me exactly what kernel I have... very important when compiling modules that will interact with the kernel (aka drivers)

I had to use google to find the exact debian page with 2.6.26-2-686 (lenny) kernel headers (.deb so at least that's easy)...

e.g.

make -C /lib/modules/2.6.26-2-686/build M=pwd clean

this doesn't actually help much... thanks for the crappy instructions broadcom...


The kernel headers package is specifically for precompiled kernels. thus you can download: linux-headers-2.6.26-2-686.deb

Of course, the kernel headers deb has some dependencies... (download them also!)

linux-headers-2.6.26-2-common (= 2.6.26-17) linux-kbuild-2.6.26 gcc-4.1

download the above .deb files and then use dpkg -i gcc-4.1.deb

of course you'll get errors because gcc-4.1 depends on:

gcc-4.1-base cpp-4.1 binutils

Normally all of this is done for you with apt-get or yum (and an internet connection...)


now /usr/src contains 3 directories: linux-headers linux-headers-common linux-kbuild


cd /linksys/hybrid_wl make -C /lib/modules/2.6.26-2-686/build M=pwd clean make -C /lib/modules/2.6.26-2-686/build M=pwd

now shows all sorts of good geeky messages

make --help | more //reveals much more!

make -C /linksys/hybrid_wl -f Makefile -C //change to directory -f //file to be used as makefile

unfortunately "no rule to make target" "no targets"

from someone with a similar problem

make -C /lib/modules/uname -r/build M=pwd

The kernel headers are stored in /usr/src and usually appear as a directory reflecting the version of the currently running kernel. You can check that (currently running kernel version) by typing uname -r.

-> Kernel source (i.e. kernel headers) is what I described above. Kernel source (header) files are pre-compiled set of binaries (inlcuding bug fixes and patches) that reflect the kernel that's running your system. These files are named in the following manner: "kernel-source-.rpm"

--> Source kernel files are simply the source file for making a kernel. If you plan to make (compile) your own kernel (the core of linux) then you must use the "source" files - as you would with some programs... obtain the source and then compile your own program based on the "source files". These are normally named: "kernel-.src.rpm"

In the Makefile you may find a line like:

KERNEL_SOURCES := /lib/modules/$(shell uname -r)/build

When this is read the $(shell uname -r) part gets changed to whatever the output of the command 'uname -r' is.

Check that there really are kernel header files in that location. If not just edit the Makefile to set the correct location.

good advice for building from make...

/lib/modules/uname -r/build


To compile modules to get my graphics card working I needed the kernel header package that matched my precompiled kernel. If you have compiled your own kernel, you already have the headers on your computer, since these were needed to compile the kernel.

You should find them in the include foder where ever you unpacked the kernel source. They end in .h and there are lots of them in folders depending what their for: /net for network, /scsi for scsi etc.

Installing kernel modules, which are in fact part of the kernel (except loaded on demand rather than built in), so they have include the same bit of code as your kernel to work.


To get the Debian kernel source at the current maximum patchlevel, it is sufficient to install the latest linux-source-version package and unpack the source, for example: # apt-get install linux-source-2.6.18 $ tar jxf /usr/src/linux-source-2.6.18.tar.bz2


  • « Make not found
  • Lvm recovery »

Published

Feb 6, 2010

Category

linux

~607 words

Tags

  • build 3
  • from 24
  • linux 249
  • make 7
  • source 9