Makefile 想要寫的更精簡 - Linux

By Callum
at 2017-12-09T15:43
at 2017-12-09T15:43
Table of Contents
各位大大好,小弟想再這裡請問一下
下方是我專案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****不一樣而已,請問我該何把它縮短,用變數在執行的時候去讀$@
好像是不能讀的,感謝各位了ꨊ
--
下方是我專案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****不一樣而已,請問我該何把它縮短,用變數在執行的時候去讀$@
好像是不能讀的,感謝各位了ꨊ
--
Tags:
Linux
All Comments

By Andrew
at 2017-12-09T16:50
at 2017-12-09T16:50

By Edward Lewis
at 2017-12-11T05:07
at 2017-12-11T05:07

By Jacob
at 2017-12-14T02:19
at 2017-12-14T02:19

By Emma
at 2017-12-15T17:06
at 2017-12-15T17:06

By Cara
at 2017-12-17T23:34
at 2017-12-17T23:34
Related Posts
tar 多不同路徑檔,並移除絕對路徑

By Heather
at 2017-12-08T16:05
at 2017-12-08T16:05
centos 5有類似timeout指令嗎?

By Doris
at 2017-12-08T14:23
at 2017-12-08T14:23
啟動icfb遇到問題

By Erin
at 2017-12-08T12:09
at 2017-12-08T12:09
啟動icfb遇到問題

By Kama
at 2017-12-07T18:19
at 2017-12-07T18:19
spyder安裝 遇到lzh_tw 問題

By Lily
at 2017-12-07T15:26
at 2017-12-07T15:26