在文件系统上编译出树的内核模块,针对任何内核源代码树 [英] Compiling out-of-tree kernel module against any kernel source tree on the filesystem

查看:177
本文介绍了在文件系统上编译出树的内核模块,针对任何内核源代码树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译对文件系统上的任何源代码树一个模块,但我有Makefile文件的麻烦。这是原来的Makefile我不得不对指定的内核:

I am trying to compile a module against any source tree on the file system but I am having trouble with the Makefile. This was the original Makefile I had against the kernel specified:

obj-m += new-mod.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

这Makefile应正确编译,但目标是有它编译反对任何源代码树。我曾尝试过:

This Makefile would compile correctly, but goal is to have it compile against any source tree. I have tried just:

obj-m += new-mod.o

我认为一切:假设,但我得到的错误:

I thought that "all:" is assumed but I get error:

make: *** No targets.  Stop.

我还补充说:

all: 

与除错误信息没有什么区别的Makefile:

to the Makefile with no difference except for error message:

make: Nothing to be done for `all'

我已经尝试了大量的文档,但没有运气的。我将不胜AP preciate任何帮助。

I have tried a lot of documentation but no luck. I would greatly appreciate any help.

推荐答案

的目标是有它编译反对任何源代码树

雅你能做到这一点提供了一个编译源 - code路径

ya you can do it providing a compiled source-code path

只需更换让-C / lib / modules目录/ $(壳使用uname -r)/建造M = $(PWD)模块

让-C<路径来编译-src- code> M = $(PWD)模块

让-C /home/vinay/linux-3.9 M = $(PWD)模块

试试下面的makefile

try below makefile

Makefile文件 -

Makefile –

# if KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq (${KERNELRELEASE},)
obj-m := new-mod.o
# Otherwise we were called directly from the command line.
# Invoke the kernel build system.
  else
    KERNEL_SOURCE := /usr/src/linux
    PWD := $(shell pwd)
default:
      ${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules

clean:
      ${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean
endif

在上面你可以改变 KERNEL_SOURCE:=在/ usr / src / linux目录 - >到.-->您的SR-code KERNEL_SOURCE:=<路径编译-src- code>

In above you can change KERNEL_SOURCE := /usr/src/linux-->to.--> your sr-code KERNEL_SOURCE := <path to compiled-src-code>

有关进一步信息?看看下面链接才可

for further info find below liks

<一个href=\"http://stackoverflow.com/questions/19805244/while-building-kernel-modules-why-do-we-need-lib-modules/19808044#19808044\">while构建内核模块,为什么我们需要/ lib / modules目录?

<一个href=\"http://stackoverflow.com/questions/19586982/a-simple-program-on-linux-device-driver/19587151#19587151\">A在Linux设备驱动简单的程序

<一个href=\"http://stackoverflow.com/questions/19542631/how-to-make-a-built-in-device-driver-in-linux/19573806#19573806\">How做一个内置在linux 设备驱动程序

这篇关于在文件系统上编译出树的内核模块,针对任何内核源代码树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆