zoukankan      html  css  js  c++  java
  • 编译模块的Makefile解析

     Makefile

    # if not defined KERNELRELEASE, command is running from command line,need invoke kbuild system.

    ifeq ($(KERNELRELEASE),)  

      KERNELDIR ?= /linux-2.6.30.4 # the directory of kernel source file  

      PWD := $(shell pwd) # the directory of module source file

    modules:  

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

    modules_install:  

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

    clean:  

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

    .PHONY: modules modules_install clean # if defined KERNELRELEASE, kbuild running

    else  

      obj-m:= hello.o # the source file of module endif

    #################################################################

    该Makefile 在模块构造过程中一般将被调用两次。使用make 时,第一次 KERNELRELEASE 尚未定义。KERNELDIR 将被定义为内核源码路径,PWD 将被赋值为模块源码文件所在路径。然后通过 $(MAKE) -C $(KERNELDIR) M=$(PWD) modules进入内核源码目录调用顶层Makefile 。顶层Makefile 会通过 M=$(PWD) 获得指定的模块源码所在路径,并调用其下的 Makefile。即该Makefile 将被调用第二次,此时将会执行else 后的语句,通过内核顶层Makefile 构建出模块。

  • 相关阅读:
    在ASP.NET MVC中使用DropDownList引用。呵呵。
    获取泛型对象
    Tomcat JVM 初始化加大内存
    Tomcat6.0 连接池的配置
    @ResponseBody与Ajax
    c3po数据库连接池中取出连接
    SpringMVC
    JQuery发送Ajax请求
    Java生成验证码
    Spring初学
  • 原文地址:https://www.cnblogs.com/youngvoice/p/5268198.html
Copyright © 2011-2022 走看看