c - How do I write a makefile for my module -
here question:i want write kernel module , have writen files: a.c,b.c,b.h , d.h. a.c includes b.h , d.h , b.h includes d.h too. wrote makefile this:
ifneq ($(kernelrelease),) mymodule-objs :=a.c b.c obj-m += a.o b.o else pwd := $(shell pwd) kver := $(shell uname -r) kdir := /lib/modules/$(kver)/build all: rm -rf *.o *.mod.c *.symvers *order *.markers *.cmd *- $(make) -c $(kdir) m=$(pwd) clean: rm -rf *.o *.mod.c *.symvers *order *.markers *.cmd *- endif
but doesn't work,how should write correct makefile? want file name x.ko in end and.
after use 'make' command,and use 'insmod' give me message:
insmod: error: not insert module a.ko: unknown symbol in module
by way use unbuntu 14.10. kernel 3.16.0-37-generic
obj-m += a.o b.o
will create 2 modules, a.ko , b.ko
if want create single module out of both (which suppose because of line mymodule-objs
), replace line with
obj-m += mymodule.o
mymodule.o
built according mymodule-objs
, turned mymodule.ko
using modpost.
, said before, you're missing modules
in $(make)
line
Comments
Post a Comment