8

My last kernel development was in version 2.6~ Now I try to compile a module, and I get the following error when compiling outside the kernel tree.

/bin/sh: 1: /home/blabla/workspace/kernel35/linux-3.5/scripts/recordmcount: not found

The object file is created properly, however the problem is within the kernel Makefile itself, something has changed and I wasn't updated ?

I'm using vanilla kernel sources from kernel.org, and I already did

make oldconfig && make prepare

I posted the Makefile that I'm using, it's a standard makefile for kernel modules

# Comment/uncomment the following line to disable/enable debugging
#DEBUG = y


# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
  DEBFLAGS = -O -g -DBLABLA_DEBUG # "-O" is needed to expand inlines
else
  DEBFLAGS = -O2
endif

ccflags-y += $(DEBFLAGS)
ccflags-y += -I..

ifneq ($(KERNELRELEASE),)
# call from kernel build system

obj-m   := blabla.o

else
KERNELDIR ?= /home/blabla/workspace/kernel35/linux-3.5
PWD       := $(shell pwd)

default:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

endif

clean:
    rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

depend .depend dep:
    $(CC) $(CFLAGS) -M *.c > .depend


ifeq (.depend,$(wildcard .depend))
include .depend
endif
stdcall
  • 27,613
  • 18
  • 81
  • 125
  • Did you try `make KERNELDIR=`. The file you have has a default of */home/blabla/../linux-3.5*. Is that where your kernel source is? Actually, it looks like `KERNELDIR` is a path to the build tree. Are build and source different? – artless noise Mar 03 '13 at 20:44

1 Answers1

12

OK, I figured out how to solve this. apparently, this is the first time I'm trying to compile a module without compiling the kernel beforehand. to solve the issue I run the following command from the kernel source tree.

make modules_prepare

this creates all the necessary infrastructure to support modules building.

stdcall
  • 27,613
  • 18
  • 81
  • 125