[問題] Makefile 想要寫的更精簡

看板Linux作者 (最後的等待)時間8年前 (2017/12/09 15:43), 編輯推噓1(105)
留言6則, 3人參與, 8年前最新討論串1/1
各位大大好,小弟想再這裡請問一下 下方是我專案makefile,裡面有大量重複的部份 utAtom: utAtom.o term.o g++ -o $@ $^ -lgtest -lpthread utAtom.o: utAtom.h atom.h touch $*.cpp && echo "#include \"$*.h\"" > $*.cpp && cat utTemplate.h >> $*.cpp g++ -c $*.cpp utTerm: utTerm.o term.o g++ -o $@ $^ -lgtest -lpthread utTerm.o: utTerm.h atom.h number.h variable.h touch $*.cpp && echo "#include \"$*.h\"" > $*.cpp && cat utTemplate.h >> $*.cpp g++ -c $*.cpp 兩組之間只差了ut****不一樣而已,請問我該何把它縮短,用變數在執行的時候去讀$@ 好像是不能讀的,感謝各位了ꨊ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.217.185.27 ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1512805402.A.22C.html

12/09 15:58, 8年前 , 1F
ut%m: ut%m.o term.o
12/09 15:58, 1F

12/09 15:58, 8年前 , 2F
wild card 可以在中間嗎?
12/09 15:58, 2F

12/09 16:12, 8年前 , 3F
什麼中間!?
12/09 16:12, 3F

12/09 16:23, 8年前 , 4F
一般都是 %.html: %.md 之類的放頭或尾,中間好像也行
12/09 16:23, 4F

12/09 16:28, 8年前 , 5F
看懂了 可以放中間 %就是匹配1~n個字元
12/09 16:28, 5F

12/11 09:42, 8年前 , 6F
大致看懂了,謝謝各位的幫忙
12/11 09:42, 6F
文章代碼(AID): #1QAvGQ8i (Linux)
文章代碼(AID): #1QAvGQ8i (Linux)