hi..

Submitted by Anonymous
on March 21, 2007 - 2:40am

make is giving this error "command commence before target"
here is my make file

ifneq($(KERNELRELEASE),)
CC=gcc
MODCFLAGS := -Wall -DMODULE -D__KERNEL__ -DLINUX
obj-m := hello.o
$(CC) $(MODCFLAGS) -c hello.c

else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

endif

here iam trying to build kernel module hello.c which displays hello world frm kernel space.
can any body help me plz...

thanx in advance

hello..

on
March 21, 2007 - 3:30am

my dog ate my keyboard

plz help

:)

Bad Makefile

swm (not verified)
on
March 22, 2007 - 4:06pm

I am not very familiar with makefiles but I can tell you what is causing the error. The following Makefile runs ok on my system.

ifneq ($(KERNELRELEASE),)
	obj-m := hello.o
	CC=gcc
	MODCFLAGS := -Wall -DMODULE -D__KERNEL__ -DLINUX
#	$(CC) $(MODCFLAGS) -c hello.c

else
	KERNELDIR ?= /lib/modules/$(shell uname -r)/build
	PWD := $(shell pwd)
default:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

endif

Note the space after "ifneq". If you are not already doing so, reference http://lwn.net/images/pdf/LDD3/ch02.pdf

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.