During the loading of the two makefile files of the linux driver to the driver, a Makefile file is required to complete the compilation Command. I often confuse the commands in Makefile. this time, I specially studied the stuff in the Makefile file. I will share it with you in a short form...
During the loading of the two makefile files of the linux driver to the driver, a Makefile file is required to complete the compilation Command. I often confuse the commands in Makefile. this time, I specially studied the stuff in the Makefile file. I will share with you a simple driver example: www.2cto.com [plain]/* ==================================== ========================================== A kernel module: book This example is to introduce module params The initial developer of the original code is Baohua Song. all Rights Reserved. ========================================================== ===================================== */# include # Include MODULE_LICENSE ("Dual BSD/GPL"); www.2cto.com static char * book_name = "dissecting Linux Device Driver"; static int num = 4000; static int book_init (void) {printk (KERN_INFO "book name: % s \ n", book_name); printk (KERN_INFO "book num: % d \ n", num); return 0 ;} static void book_exit (void) {printk (KERN_INFO "Book module exit \ n");} module_init (book_init); module_exit (book_exit); module_param (num, int, S _ IRUGO); module_param (book_name, charp, S_IRUGO); MODULE_AUTHOR ("Song Baohua, author@linuxdriver.cn"); MODULE_DESCRIPTION ("A simple Module for testing module params "); MODULE_VERSION ("V1.0"); two Makefile files can be written in either of the following ways: [html] # Add your debugging flag (or not) to CFLAGS ifneq ($ (KERNELRELEASE),) obj-m: = boot. o else KERNELDIR? =/Lib/modules/$ (shell uname-r)/build PWD :=$ (shell pwd) default: $ (MAKE)-C $ (KERNELDIR) M = $ (PWD) modules endif www.2cto.com another one is: [plain] # Add your debugging flag (or not) to CFLAGS ifneq ($ (KERNELRELEASE),) obj-m: = boot. o else KERNELDIR? =/Usr/src/linux-headers-2.6.38-8-generic PWD: = $ (shell pwd) default: $ (MAKE)-C $ (KERNELDIR) M = $ (PWD) modules endif compare the two, we can find that, the only difference between the two makefiles is the difference between KERNELDIR
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.