Building a kernel module from several source files which one of them has the same name as the module

后端 未结 5 1887
[愿得一人]
[愿得一人] 2020-12-02 17:24

Is it possible to build a kernel module from several source files which one of them has the same name as the module?

For example: I want to build \"mymodule.ko\" wit

5条回答
  •  盖世英雄少女心
    2020-12-02 18:08

    I found a solution, I placed my source file in a sub folder:

    Makefile
    src/mymodule.c
    src/mymodule_func.c

    #Makefile
    obj-m += mymodule.o
    mymodule-objs := ./src/mymodule.o ./src/mymodule_func.o
    
    all:
        make -C $(KERNEL_PATH) M=$(PWD) modules
    
    clean:
        make -C $(KERNEL_PATH) M=$(PWD) clean
    

提交回复
热议问题