linux驅動之makefile詳解

來源:互聯網
上載者:User

# If KERNELRELEASE is defined, we've been invoked from the
# 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

當我們敲下make時,我們進入了這個權威的makefile二次。第一次進入makefile,發現KERNELRELEASE沒有被設定時,於是她根據build這個符號連結定位核心原始碼目錄,然後進入default,開始第二個make,-C選項進入核心原始碼目錄,找到頂層的makefile,然後-M返回目前的目錄執行makefile檔案,這就是第二次進入這個makefile,在這次,由於KERNELRELEASE變數已經定義,因此不需要進入else語言,在這裡,obj-m:=hello.o這個語句和我們以前不是驅動程式中的makefile不同,在這裡核心會幫你處理一切,這句話是告訴核心,需要從hello.o建立一個驅動模型(module)。

參考文獻 《linux device drivers 3》

本文來自CSDN部落格,轉載自:http://blog.csdn.net/abc19842008/archive/2008/02/14/2095836.aspx

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.