Re: [問題] Makefile賦值問題

作者: peterbrucele (DM5)   2021-10-22 12:04:07
※ 引述《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比較好

Links booklink

Contact Us: admin [ a t ] ucptt.com