怎么编写linux2.6.x下内核模块的Makefile

wwwspirit 2006-02-13 05:34:32
初学linux内核编程,这个我一直搞不定Makefile的编写。

最好能说明如下情况时Makefile的编写:
编写三个模块mod1、mod2、mod3(对应的文件分别为mod1.c、mod1.h;mod2.c、mod2.h;mod3.c、mod3.h),其中mod2要依赖到mod1.c中定义的某个变量。

哪位大虾能写个示范,并给出简单的分析,本人感激不尽!
...全文
288 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
gprsgsn 2006-02-24
  • 打赏
  • 举报
回复
http://dev.csdn.net/user/haoel

你去看看这位大虾写的《跟我写makefile》通俗易懂,边看边写,很快你就明白了,不难的。
wwwspirit 2006-02-21
  • 打赏
  • 举报
回复
下面是一个标准的Makefile文件,可是我看不懂,谁能帮我详细解释一下呢?
# If KERNELRELEASE is defined, we've been invoked from the

# kernel build system and can use its language.

ifneq ($(KERNELRELEASE),)

obj-m := hello.o



# Otherwise we were called directly from the command

# line; invoke the kernel build system.

else



KERNELDIR ?= /lib/modules/$(shell uname -r)/build

PWD := $(shell pwd)



default:

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



endif
wwwspirit 2006-02-21
  • 打赏
  • 举报
回复
没有高手肯帮忙吗?
float_sky 2006-02-15
  • 打赏
  • 举报
回复
请问你是否知道当只有一个模块时该怎么写?

4,465

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧