[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: how do I compile a single file in kernel?



Dear Bao,

> Bao Zhao Wrote:
>    I changed a file a kernel. Before compiling the
> whole kernel , I want to  compile this file solely to
> see if syntax errors exist.But I donn't know the
> compiler option. where can I find them?

If you are using 2.6.x kernel then you have to use the following make
file to compile a single file. If you are using 2.4.x then it varies. 

Before compile your program copy the program to another directory and
change the names accordingly in the following make file then compile.

------------------------------------------------------------------------
---
#
# Makefile for hello.c file in 2.6.x kernel only.
#
KDIR:=/lib/modules/$(shell uname -r)/build
TRGT:=hello_world
OBJS:=hello.o

obj-m += $(TRGT).o
$(TRGT)-objs := $(OBJS)

default:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
	$(RM) .*.cmd *.mod.c *.ko *.o -r .tmp*

------------------------------------------------------------------------
---

If you want a Makefile for 2.4.x kernel mail me.

Regards,
Srinivas G

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/