Thanks Corona for the reply.
Actually I have in a folder "\CourseTemplates\CharDriver" in which I have made a simple kernel module file having a null char driver.
To build this folder "CourseTemplates" has three files, while subfolder "\CourseTemplates\CharDriver" has an empty makefile.
The three files of Folder "CourseTemplates" are:
1) Makefile
DIRS := $(filter-out Makefile README module.mk, $(wildcard *))
DIRS_CLEAN := $(DIRS:=_clean)
.PHONY: all ${DIRS} clean
all: ${DIRS}
${DIRS}:
@echo -n "Building $@ ... "
@${MAKE} -C $@ KERNEL_SOURCE=/home/netuser/RKP/linux-source/linux-2.6.27.14/linux-2.6.27.14-1mnb/ > /dev/null
@echo "done"
clean: ${DIRS_CLEAN}
%_clean:
@echo -n "Cleaning $* ... "
@${MAKE} -C $* KERNEL_SOURCE=/home/netuser/RKP/linux-source/linux-2.6.27.14/linux-2.6.27.14-1mnb/ clean > /dev/null
@echo "done"
2) Makefile.mixed
UNAME := $(shell uname -r)
KERNEL26 := 2.6
KERNELVERSION := $(findstring $(KERNEL26),$(UNAME))
ifeq ($(KERNELVERSION),2.6)
obj-m := hello10.o
INCLUDE := -I/usr/include/asm/mach-default/
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
all::
$(MAKE) -C $(KDIR) $(INCLUDE) SUBDIRS=$(PWD) modules
else
TARGET := skeleton
INCLUDE := -I/lib/modules/`uname -r`/build/include -I/usr/include/asm/mach-default/
CFLAGS := -O2 -Wall -DMODULE -D__KERNEL__ -DLINUX
CC := gcc
all:: ${TARGET}.o
${TARGET}.o: ${TARGET}.c
$(CC) $(CFLAGS) ${INCLUDE} -c ${TARGET}.c
endif
3) module.mk
# if KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
src-m := $(wildcard ${SUBDIRS}/*.c)
src-mod := $(wildcard ${SUBDIRS}/*.mod.c)
src-m := $(notdir ${src-m})
src-mod := $(notdir ${src-mod})
src-m := $(filter-out ${src-mod}, ${src-m})
obj-m := $(src-m:.c=.o)
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNEL_SOURCE := /home/netuser/RKP/linux-source/linux-2.6.27.14/linux-2.6.27.14-1mnb/
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(PWD) modules
clean:
$(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(PWD) clean
endif
---------- Post updated at 01:03 AM ---------- Previous update was at 01:00 AM ----------
I have suse linux "linux-2.6.31.5-0.1" on my PC.
Now I have created a new makefile in CharDriver folder with below content:
# if KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
src-m := $(wildcard ${SUBDIRS}/*.c)
src-mod := $(wildcard ${SUBDIRS}/*.mod.c)
src-m := $(notdir ${src-m})
src-mod := $(notdir ${src-mod})
src-m := $(filter-out ${src-mod}, ${src-m})
obj-m := $(src-m:.c=.o)
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNEL_SOURCE := /home/netuser/RKP/linux-source/linux-2.6.27.14/linux-2.6.27.14-1mnb/
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(PWD) modules
clean:
$(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(PWD) clean
endif
Now it gives me the following build error:
linux-8qbp:/home/netuser/RKP/CourseTemplates/CharDriver # make
make -C /home/netuser/RKP/linux-source/linux-2.6.27.14/linux-2.6.27.14-1mnb/ SUBDIRS=/home/netuser/RKP/CourseTemplates/CharDriver modules
make[1]: Entering directory `/home/netuser/RKP/linux-source/linux-2.6.27.14/linux-2.6.27.14-1mnb'
WARNING: Symbol version dump /home/netuser/RKP/linux-source/linux-2.6.27.14/linux-2.6.27.14-1mnb/Module.symvers
is missing; modules will have no dependencies and modversions.
CC [M] /home/netuser/RKP/CourseTemplates/CharDriver/char_driver.o
/home/netuser/RKP/CourseTemplates/CharDriver/char_driver.c:1: error: code model �kernel� not supported in the 32 bit mode
/home/netuser/RKP/CourseTemplates/CharDriver/char_driver.c:1: sorry, unimplemented: 64-bit mode not compiled in
make[2]: *** [/home/netuser/RKP/CourseTemplates/CharDriver/char_driver.o] Error 1
make[1]: *** [_module_/home/netuser/RKP/CourseTemplates/CharDriver] Error 2
make[1]: Leaving directory `/home/netuser/RKP/linux-source/linux-2.6.27.14/linux-2.6.27.14-1mnb'
make: *** [default] Error
Will you pls through some light as to what might be the issue and how to resolve it.