2.6下的内核模块编译-Linux -华夏名网资讯中心 虚拟主机,域名注册,双线虚拟主机,...

来源:百度文库 编辑:神马文学网 时间:2024/05/01 19:18:41

    • 域名注册

    • 域名惊喜价格 cn域名1元注册
    • com域名39.9元

      虚拟主机

    • 主机按月支付,低至19元/月
    • 超大流量,可开子站点

      VPS主机

    • 特惠VPS168元/月,4-8M独享带宽保证
    • 独立操作系统,无限开站点
    1.一个模快中只有一个文件的编译
        Makefile如下:
        obj-m := hello.o
       运行时:make -C /lib/modules/`uname -r`/build M=`pwd`
    2.一个模块中多个文件的编译
        Makefile如下:
         obj-m := hello.o
         hello-objs := hello1.o hello2.o
        运行时:make -C /lib/modules/`uname -r`/build M=`pwd`
    3.多个文件编译多个模块,模快之间有引用
    文件结构:                   |
                   ------------------------------
                   |              |            |
                Makefile         foo/        bar/
                                   |          |
                               --------     -------
                               |       |    |      |
                        Makefile  hello1.c  Makefile hello2.c
    顶极Makefile文件的写法:
       obj-y := foo/  bar/
    下一级的Makefile文件写法同1和2
    在顶极Makefile所在的目录下运行:
       make -C /lib/modules/`uname -r`/build M=`pwd`