[问题] 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