简体   繁体   中英

How to provide include directory path in kernel module Makefile

I was learning kernel interrupt using a small demo kernel module which use these two header include

asm/exception.h
asm/mach/irq.h

My Makefile is

ifeq (${KERNELRELEASE},)

    KERNEL_SOURCE := /lib/modules/$(shell uname -r)/build

    PWD := $(shell pwd)


default:
    make    -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules 

clean:
    make    -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean



else

obj-m := irq_demo.o

endif

The error I am getting

irq_demo.c:9:27: fatal error: asm/exception.h: No such file or directory
 #include <asm/exception.h>

I found asm/exception.h in my system in /usr/src/linux-headers-3.16.0-30-generic/arch/arm/include/

  • [1]But how to include this path in Makefile

  • [2]Is /usr/src/linux-headers-3.16.0-30-generic/include/asm-generic/ linked with arch/arm/include/asm/ ? if yes , than How ?

First try adding ARCH=arm after make ie

make ARCH=arm -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules 

============================= OR =============================

Can you try adding line before make

CARGS = -I /lib/modules/$(shell uname -r)/arch/arm/include/
make  $(CARGS) -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM