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

作者: wei840222 (最後的等待)   2017-12-09 15:43:20
各位大大好,小弟想再這裡請問一下
下方是我專案makefile,裡面有大量重複的部份
utAtom: utAtom.o term.o
g++ -o [email protected] $^ -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 [email protected] $^ -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****不一樣而已,請問我該何把它縮短,用變數在執行的時候去讀[email protected]
好像是不能讀的,感謝各位了ꨊ
作者: hijkxyzuw (i,j,k) ×(x,y,z)   2017-12-09 15:58:00
ut%m: ut%m.o term.owild card 可以在中間嗎?
作者: galic (嘎利)   2017-12-09 16:12:00
什麼中間!?
作者: hijkxyzuw (i,j,k) ×(x,y,z)   2017-12-09 16:23:00
一般都是 %.html: %.md 之類的放頭或尾,中間好像也行
作者: galic (嘎利)   2017-12-09 16:28:00
看懂了 可以放中間 %就是匹配1~n個字元
作者: wei840222 (最後的等待)   2017-12-11 09:42:00
大致看懂了,謝謝各位的幫忙

Links booklink

Contact Us: admin [ a t ] ucptt.com