Hey Manoj,

You've defined what you want the end result to be.  You should also need to define what the source is for this result.

You might try looking at some other drivers (such as NVidia, or acerhk) that compile kernel modules.

In your makefile, you will have rules.  Rules are generally in the form of 'label:what do do'.  Labels define what you can type after your 'make' command eg 'make label'.

In the example below, TARGET is defined as 'acerhk.ko'.  This is the module we are trying to build.  The rule 'all: $(TARGET)' will therefore be interpreted as 'all: acerhk.ko'.  make will then find the rule named 'acerhk.ko' and see what else is to be done.

The rule 'acerhk.ko' defines the source and header files, and how make should run.

Hope this helps a bit.

What follows is from the acerhk Makefile, edited somewhat to remove all the kernel 2.4 stuff.  You can also add conditional statements (eg if) to Makefiles....

-- begin Makefile --
KERNELSRC?=/lib/modules/`uname -r`/build
KERNELVERSION=$(shell awk -F\" '/REL/ {print $$2}' $(KERNELSRC)/include/linux/version.h)
KERNELMAJOR=$(shell echo $(KERNELVERSION)|head -c3)

obj-m += acerhk.o

CC=gcc
CFLAGS+=-c -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe
INCLUDE=-I$(KERNELSRC)/include

TARGET := acerhk.ko
SOURCE := acerhk.c

all: $(TARGET)

acerhk.ko: $(SOURCE) acerhk.h
        $(MAKE) -C $(KERNELSRC) SUBDIRS=$(PWD) modules

asm:    $(SOURCE)
        $(CC) $(INCLUDE) $(INCLUDE)/asm-i386/mach-default $(CFLAGS) -fverbose-asm -S -DMODVERSIONS -DMODULE -D__KERNEL__ $(SOURCE)

clean:
        rm -f *~ *.o *.s *.ko *.mod.c

load:   $(TARGET)
        insmod $(TARGET)

unload:
        rmmod acerhk

install: $(TARGET)
        #cp -v $(TARGET) /lib/modules/$(KERNELVERSION)/kernel/drivers/char
        mkdir -p /lib/modules/$(KERNELVERSION)/extra
        cp -v $(TARGET) /lib/modules/$(KERNELVERSION)/extra/
        depmod -a
-- end Makefile --

 
Regards

Sean

Manoj Menon wrote:
Hi guys,

Finally I got around to reading "Linux Device Drivers"
3rd Edition. But unfortunately, I've hit a major snag
at the very begining. :-(

When I try to make (my first module) the "Hello World"
module I get a message like this.

make: Nothing to be done for `default'.

My makefile looks like this

obj-m := hello.o

I am running Fedora Core 4 (2.6.11-1.1369_FC4) and
I've also installed the kernel sources.

Any idea, where I am messing up ?

-Manoj.C




     
           
__________________________________
Yahoo! for Good - Make a difference this year.
http://brand.yahoo.com/cybergivingweek2005/


SPONSORED LINKS
Linux operating system Linux os Hosting linux unix web
Free linux operating system Linux migration Linux user


YAHOO! GROUPS LINKS




Reply via email to