寫於2023年1月5日
# nmake 工具的描述檔案例子
exe = test.exe
#指定輸出檔案
objs = x.obj \
y.obj
#需要的目標檔案
res = x.res
#需要的資源檔案
link_flag = /subsystem:windows
#鏈結選項
ml_flag = /c /coff
#編譯選項
#定義依賴關係和執行命令
$(exe):$(objs) $(res)
link $(link_flag) /out:$(exe) $(objs) $(res)
$(objs):commom.inc
#指定所有obj檔案都依賴commom.inc檔案
y.obj:y.inc
#指定y.obj除了依賴14行的規則,還依賴y.inc檔案
#定義彙編編譯和資源編譯的預設規則
#nmake遇到沒有指定產生命令的規則時,回到隱含規則中去尋找並執行生成命令
.asm.obj:
ml $(ml_flag) $<
.rc .res:
rc $<
#清除臨時檔案
clean:
del *.obj
del *.res
工程Makefile例項
1級makefil phony clean for subdir in subdirs do cd subdir make clean done 級makefile target lib notdir curdir a objs wildcard o cc flags fpic md 靜態庫合成動態...
makefile 簡單例項
3 複雜專案 makefile 編寫 變數定義和初始化 可選 目標 依賴項 指令目標 依賴項 指令.注 指令可以是編譯指令或其它可以在命令列執行的指令。定義變數後就可以在 目標 依賴 指令 中訪問 var name 檔案結構 檔案內容 main.c include extern intaddint ...
Makefile例項分析
目錄 makefile如下 arch x86 ifeq arch x86 cc gcc else cc arm linux gnueabihf gcc endif target build dir build src dir src module inc dir include cflags pat...