# If kernelrelease is defined, we 've been invoked from
# Kernel build system and can use its language.
Ifneq ($ (kernelrelease ),)
OBJ-M: = Hello. o
# Otherwise we were called directly from the command
# Line; invoke the kernel build system.
Else
Kerneldir? =/Lib/modules/$ (shell uname-R)/build
PWD: = $ (shell PWD)
Default:
$ (Make)-C $ (kerneldir) M = $ (PWD) Modules
Endif
When we knocked on make, we entered this authoritative makefile twice. The first time she entered makefile and found that kernelrelease was not set, she located the kernel based on the build symbolic link.Source codeDirectory, and then enter default, start the second make,-C option to enter the kernel sourceCodeDirectory, find the makefile at the top level, and then-M returns to the current directory to execute the MAKEFILE file. This is the second time you enter the makefile. This time, because the kernelrelease variable has been defined, therefore, you do not need to enter the else language. Here, obj-M: = hello. o this statement is not a driverProgramThe makefile in is different. Here the kernel will help you handle everything. This statement tells the kernel that a driver model (module) needs to be created from Hello. O ).
References to Linux Device Drivers 3
This article from the csdn blog, reproduced from: http://blog.csdn.net/abc19842008/archive/2008/02/14/2095836.aspx