如何引用其它的 Makefile

2021-10-06 01:15:57 字數 1561 閱讀 4956

除了在 uboot 的頂層 makefile 中,我們常常在子目錄也會看到子 makefile,這樣是為了模組化,頂層 makefile 可以調集各個資料夾中的子目錄下的 makefile。

一、makefile 規則格式

(1)注釋用 「#」 字元。

(2)在 makefile 中的命令,必須要以 tab 鍵開始。

目標:依賴檔案集合

命令 // 命令列表中的每條命令必須以 tab 鍵開始,不能使用空格!

二、引用其它的 makefile

使用 include 關鍵字可以把別的 makefile 包含進來,類似 c 語言的 #include。

語法:include < filename >

例:主目錄下的 makefile

all:

@echo "$(fruit)"

include .

/subdir/makefile // 這裡用 include 把 subdir 子目錄下的 makefile 包含進來了

subdir 子目錄下的 makefile

fruit:

= orange

others:

@echo "this is banana"

在主目錄下執行 make others 命令之後,結果如下:

this is banana
有時,我們還需要向子 make 傳遞變數,使用 「export」 來匯出要傳遞給子 make 的變數:

export variable        		// 匯出變數給子 make 

unexport variable // 不匯出變數給子 make

注意:想讓 make 不理那些無法讀取的檔案,而繼續執行,可在 include 前加乙個減號 「-」。

語法:-include < filename > // 無論 include 過程**現什麼錯誤,都不要報錯繼續執行,sinclude 作用和它一樣

三、makeflags 變數

「shell」 和 「makeflags」 的值始終自動的傳遞給子 make。

如:makeflags += -rr --include-dir=$(curdir)

-rr:禁止使用內建的隱含規則和變數定義

–include-dir:指明巢狀指令碼的搜尋路徑

curdir:makefile 中內建的標準變數,指當前的工作目錄

四、make 工作時的執行步驟

1、讀入所有的 makefile

2、讀入被 include 的其它 makefile

3、初始化檔案中的變數

4、推導隱晦規則,並分析所有規則

5、為所有的目標檔案建立依賴關係鏈

6、根據依賴關係,決定哪些目標要重新生成

7、執行生成命令

android 關於mk如何引用其它so庫

android.mk jni android.mk local path call my dir include clear vars local module android ffmpeg local src files c ffmpeg build target arch abi libffmp...

python list中引用其它物件

昨天執行之前寫的pynessus client,發現程式解析的列表retvalue都是一樣的成員。程式 如下 retvalue list member dict element contents.find scans scanlist for elem in element.getchildren ...

MakeFIle 變數定義及引用 , ,

makefile中給變數賦值有以下兩種方式 1.遞迴展開式,使用 直接定義,例子如下 foo bar bar ugh ugh huh?all echo foo 執行 make 將會列印出 huh?整個變數的替換過程時這樣的 首先 foo 被替換為 bar 接下來 bar 被替換為 ugh 最後 ug...