[問題] makefile define macro問題

看板Linux作者 (My Chemical Romance)時間5年前 (2020/03/09 14:48), 5年前編輯推噓1(101)
留言2則, 2人參與, 5年前最新討論串1/1
在makefile撰寫上遇到了一個問題,以下是我makefile內的一段程式 define collect-names: cd $1; \ shopt -s nullglob; \ for f1 in $(foreach sub_dir,$2,'(sub_dir)'); do \ echo "Collect Files from...$1$$f1"; \ for f2 in $(foreach file_ext,$3,'$(file_ext)'); do \ echo "**Collect File Type : *$$f2"; \ files=( `echo$$f1$/*$(if $$f2,$$f2)` ); \ if (( $${#files[@] >0} )); \ then \ printf '"%s"\n' $${fiels[@]}; \ fi; \ echo ""; \ done \ done endef all: @$(call collect-names,/root_dir/,sub_dir1/ sub_dir2/,.v .sv) 但是我發現如果將第二層for loop內的 echo ""; \ 往上移至第一層for loop內,如下所示 define collect-names: cd $1; \ shopt -s nullglob; \ for f1 in $(foreach sub_dir,$2,'(sub_dir)'); do \ echo "Collect Files from...$1$$f1"; \ for f2 in $(foreach file_ext,$3,'$(file_ext)'); do \ echo "**Collect File Type : *$$f2"; \ files=( `echo$$f1$/*$(if $$f2,$$f2)` ); \ if (( $${#files[@] >0} )); \ then \ printf '"%s"\n' $${fiels[@]}; \ fi; \ done \ echo ""; \ done endef all: @$(call collect-names,/root_dir/,sub_dir1/ sub_dir2/,.v .sv) 程式便會產生error,想請問這是什麼緣故呢? 謝謝各位 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.72.173.145 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1583736482.A.A18.html

03/09 22:51, 5年前 , 1F
為什麼你的第一個 for 雙引號右邊是單引號?
03/09 22:51, 1F
※ 編輯: sshc (211.72.173.145 臺灣), 03/13/2020 11:38:39

03/13 11:39, 5年前 , 2F
sorry,是筆誤,已改正
03/13 11:39, 2F
文章代碼(AID): #1UPUQYeO (Linux)
文章代碼(AID): #1UPUQYeO (Linux)