Kbuild's makefile Template

Source: Internet
Author: User

The makefile template is as follows:

#编译hello. o When combined with predefined debug_testcflags_hello.o + =-ddebug_test# Compile all time with predefined my_debugextra_cflags + =-dmy_debug# Specifies the final generated target # if only a single file can be written as "obj-m: = hello.o" Obj-m + = hello.o# Specify which modules are required to generate the hello.o file (if only a single file can delete the following line), # If the hello.o requires multiple file composition, it can be written like this: #isdn-objs: = isdn_net_lib.o isdn_v110.o isdn_common.o separate modules with spaces HELLO-OBJS: = src/ Hello.okid: =/lib/modules/$ (Shell uname-r)/buildpwd: = $ (shell pwd) All:        make-c $ (KID) m=${pwd} Modulesclean:        r m -rf *.o *.cmd *.ko *.mod.c .tmp_versions *.ko.unsigned *.order *.symvers        rm -rf src/*.o src/*.cmd src/*.ko src/*.mod . C Src/.tmp_versions src/*.ko.unsigned Src/*.order src/*.symvers

The hello.c file is as follows:

#include <linux/module.h>//header files required for all modules  #include <linux/init.h>  //INIT&EXIT related macro    module _license ("GPL");  static int __init hello_init (void) {         printk (kern_err "# # # Hello world\n");          return 0;  }  static void __exit hello_exit (void) {         printk (kern_err "# # # exit\n");}    Module_init (hello_init);  Module_exit (Hello_exit);

HELLO.C please put in makefile under the same directory under the SRC folder!!!




Kbuild's makefile Template

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.