Makefile for Linux drivers

Source: Internet
Author: User

# 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

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.