Results 1 to 2 of 2
Hi all,
Does anybody know how should look gcc compilation line or Makefile
to compile kernel module for kernel 2.6
In 2.4 it looks like this:
----------------------------------------------------
TARGET := hello-1
...
- 10-03-2010 #1
gcc compile kernel 2.6 module
Hi all,
Does anybody know how should look gcc compilation line or Makefile
to compile kernel module for kernel 2.6
In 2.4 it looks like this:
----------------------------------------------------
TARGET := hello-1
WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC := gcc-3.0
${TARGET}.o: ${TARGET}.c
.PHONY: clean
clean:
rm -rf ${TARGET}.o
----------------------------------------------------
and for multiple source files, like this:
----------------------------------------------------
CC=gcc
MODCFLAGS := -O -Wall -DMODULE -D__KERNEL__
hello.o: hello2_start.o hello2_stop.o
ld -m elf_i386 -r -o hello2.o hello2_start.o hello2_stop.o
start.o: hello2_start.c
${CC} ${MODCFLAGS} -c hello2_start.c
stop.o: hello2_stop.c
${CC} ${MODCFLAGS} -c hello2_stop.c
----------------------------------------------------
Kind regards,
Dragoslav Zaric
MSc Astrophysics
Professional programmer
- 10-04-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,961
Why are you trying to do this manually? The kernel sources come with a Makefile, but before you build the kernel you need to run (as regular user) one of the configuration tools (make menuconfig, make xconfig, etc), then run make and make install (as root). Kernel make files are very complex and should not be edited manually, or things are likely to not work as expected.
If you need to create a make file for a kernel module and/or driver that you are adding to the kernel, then look at existing ones in your kernel build tree for a template.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
