Re: [問題] Makefile賦值問題

看板C_and_CPP作者 (DM5)時間2年前 (2021/10/22 12:04), 2年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《Windycelesti (雲の狐)》之銘言: : 開發平台(Platform): (Ex: Win10, Linux, ...) : Linux : 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) : Makefile : 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) : Nope : 問題(Question): : 根目錄底下剛開始有的檔案 : Makefile : Neko.bin : FUNCTION_0.txt : FUNCTION_1.txt : FUNCTION_2.txt : FUNCTION_3.txt : 依照生出來的Cat.bin去決定我要把哪個FUNCTION給送出去 : 餵入的資料(Input): : 直接執行make Makefile all : 預期的正確結果(Expected Output): : 原本的流程, Cat.bin是在這個Makefile才生出來的玩意兒 : 這裡為了模擬, 所以多做了cp ./Neko.bin ./Cat.bin的動作, 然後拿Cat.bin做計算 : TT的值預期會生出0~3隨機數字(因為每次執行, Neko.bin的size都會改變) : 預期在每次計算完Cat.bin的size後 : 選擇對應的FUNCTION_$(1).txt送到其他資料夾去.(在此單純用cp而已) : 錯誤結果(Wrong Output): : all 的第四行目前沒辦法正常取出TT的值帶入PATH的$(1) : 曾經用過define去定義expr `du -b ./Cat.bin|cut -f1` % 4 : 想當然而程式看不懂 : cp ./FUNCTIONexpr `du -b ./Neko_tmp.bin|cut -f1` % 4.txt ./YAAAAA.GG : 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) : #define TestDef : #expr `du -b ./Cat.bin|cut -f1` % 4 : #endef : PATH=./FUNCTION_$(1).txt : all: : cp ./Neko.bin ./Cat.bin : expr `du -b ./Cat.bin|cut -f1` % 4 > TT : cat TT : # cp $(call PATH, $(call TestDef)) ./ YAAAAAA.GG : cp $(call PATH, echo`cat TT`) ./YAAAAA.GG : rm Cat.bin TT : echo "TEST END....." : 如果有其他問題麻煩告知, 感謝. : 另外想問問, 有沒有可以模擬Makefile的模擬網頁...(囧 : 感謝C_and_CPP版 %% cat Makefile file = ./FUNCTION_$(1).txt n = $(shell expr `du -b ./Cat.bin|cut -f 1` % 4) all: cp ./Neko.bin ./Cat.bin cp $(call file,$(n)) ./YAAAAA.GG rm Cat.bin echo "TEST END....." .PHONY: all make的built-in function (shell)可以執行指令得到結果 另外如同元PO回文 直接寫shell script比較好 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.220.103.1 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1634875449.A.885.html ※ 編輯: peterbrucele (61.220.103.1 臺灣), 10/22/2021 12:07:21 ※ 編輯: peterbrucele (61.220.103.1 臺灣), 10/22/2021 12:09:51
文章代碼(AID): #1XSZWvY5 (C_and_CPP)
文章代碼(AID): #1XSZWvY5 (C_and_CPP)